linux下安装nginx
写在前面:虚拟机安装linux系统为Centos7 64位。
安装步骤:
第一步:官网下载安装包(.tar.gz),下载当前的稳定版 。下载地址:https://nginx.org/en/download.html
第二步:解压压缩包
执行命令:
tar -zxvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
第三步:配置(默认配置)
执行命令:
./configure
第四步:编译安装
执行命令:
make
make install
查找nginx
whereis nginx
启动、停止nginx
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload
注: ./nginx -s quit
:此方式停止步骤是待nginx进程处理任务完毕进行停止。 ./nginx -s stop
:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
查询nginx进程:
ps aux|grep nginx
启动成功后用浏览器访问
安装过程中遇到的问题
执行 make后报错:
make: *** No targets specified and no makefile found. Stop
解决 :记得先执行./configure再执行make命令
执行./configure报错:
./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=<path> option.
解决:yum -y install openssl openssl-devel