Centos nginx安装

1、下载nginx

  http://nginx.org/en/download.html

2、上传到服务器上,并解压:

  rz 后选择上传的文件

  tar -zxvf /fish/download/nginx-1.14.0.tar.gz

3、安装:

  环境配置:

  ./configure

  编译:

  make

  make install (需要root用户,创建文件夹权限)

4、检查是否安装成功

  whereis nginx

  

5、启动nginx:

   进入目录:/usr/local/nginx/sbin

  执行:

  ./nginx (需要root用户,其他用户没有权限生成日志文件)

  重启nginx:

  先停止:

  ./nginx -s quit

  加载配置文件:

  ./nginx -s reload

6、验证:

  http://127.0.0.1/ (换成实际IP地址)

  能访问即可。

7、设置开机启动:

  进入etc目录,编辑 rc.local

  vim rc.local (root用户)

   

  添加数据:

  /usr/local/nginx/sbin/nginx

  Esc,wq退出即可。

0、错误处理

  1)./configure:报错:

  

  yum -y install openssl openssl-devel

1、编译 https 模块:

  参考:https://www.cnblogs.com/eaglezb/p/6074811.html  

 2、http 跳转 https :

   参考:https://www.cnblogs.com/smail-bao/p/5735664.html

原文地址:https://www.cnblogs.com/sshoub/p/9002168.html