Nginx 安装配置

Nginx 安装

  系统平台:CentOS 64位。

   1、创建nginx目录,下载nginx。

 wget http://nginx.org/download/nginx-1.9.9.tar.gz

 2、解压文件

 tar -zxvf nginx-1.9.9.tar.gz

 3、配置、编译及安装

 ./configure
 make
 make install

 4、nginx启动测试

[root@VM_0_9_centos nginx]# cd /usr/local/nginx/sbin/
[root@VM_0_9_centos sbin]# ./nginx -t

 如果返回 test is successful

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

 重新读取配置出错:

[root@VM_0_9_centos nginx]# /usr/local/nginx/sbin/nginx -s reload 
提示 nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"

解决方法: 
[root@VM_0_9_centos nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

  配置一个https的server,你可能会碰到如下报错

nginx: [emerg] unknown directive "ssl"

 需要加载OpenSSL的相关模块,解决方法如下: 

./configure --with-http_ssl_module      // 重新config并指定其他模块http_ssl_module
make     // 不要make install
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak     // 先将原来的nginx备份想删除也可以
cp objs/nginx /usr/local/nginx/sbin/nginx     // objs 目录中是编译后产生的文件
/usr/local/nginx/sbin/nginx -t     // 在测试一下  

  

 

  

 

 

 

posted @ 2022-04-06 14:43  loytime  阅读(39)  评论(0编辑  收藏  举报