远程服务器安装nginx

肯定有前端的小伙伴在腾讯云或者阿里云上购买了服务器,却不知道怎么访问使用它,那我们就一起来安装学习下?

  1. xshell 登录服务器,输入公网ip和密码登录
  2. ls 查看目录,which nginx ,查看是否已经安装过nginx;
  3. 安装编译工具及库文件
    yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
    4.首先要安装 PCRE
    http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
    5.解压安装包:tar zxvf pcre-8.35.tar.gz
  4. 进入安装包目录 : cd pcre-8.35
  5. 编译安装 : ./configure make && make install
    8.查看pcre版本 : pcre-config --version
    9.安装 Nginx : wget http://nginx.org/download/nginx-1.6.2.tar.gz
  6. 解压安装包 : tar zxvf nginx-1.6.2.tar.gz
  7. 进入安装包目录 : cd nginx-1.6.2
  8. 编译安装: ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
    make,make install
  9. 查看nginx版本 (如果没有安转成功,说明12步有问题)
  10. Nginx 配置:全局找到nginx,nginx/conf/nginx.conf 文件, 进行vim写入编辑,把ip或者域名输入进行;

server
{
listen 80;#监听端口
server_name localhost;#域名
index index.html index.htm index.php;
root /usr/local/webserver/nginx/html;#站点目录
}

  1. 启动 Nginx nginx -s reload
原文地址:https://www.cnblogs.com/panax/p/10548175.html