linux(centos7)上部署nginx-1.9.9

第一步:选择自己想要安装的位置,创建nginx的相关文件夹,然后执行wget https://nginx.org/download/nginx-1.9.9.tar.gz

第二步:解压 tar -zxvf nginx-1.9.9.tar.gz,解压后进入解压后的文件中如 cd nginx-1.9.9

第三步:执行./configure --prefix=/opt/tools/nginx/nginx-1.9.9 --conf-path=/opt/tools/nginx/nginx-1.9.9/nginx.conf --with-http_ssl_module (prefix和path后的内容都是你自己安装的路径),此时可能出现报错

<1>,./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre= option.

解决方式:安装pcre-devel解决问题 yum -y install pcre-devel

<2>,./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib= option.

解决方式:安装zlib wget http://www.zlib.net/zlib-1.2.11.tar.gz ,解压 tar -xzvf zlib-1.2.11.tar.gz依次执行

cd zlib-1.2.11

./configure

make

make install

此时过程中若出现报错:checking for OS Linux 3.10.0-957.el7.x86_64 x86_64 checking for C compiler . 则需安装:yum -y install gcc

<3>,./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl= option.

则安装yum -y install openssl openssl-devel,安装完毕再重新执行添加ssl的命令,完毕后执行make和make install

第五步:启动,停止,重启的方式

<1>,启动:进入nginx的sbin目录下./nginx即可

<2>,停止:ps -ef | grep nginx 找到进程id然后kill -9 进程id

<3>,重启:通常修改了nginx的配置文件需要重启一下nginx,修改完毕配置文件先进入sbin目录下./nginx -t检查修改无误,然后重启使修改生效,./nginx -s reload

你可能感兴趣的:(服务器相关,nginx,linux)