1、下载nginx安装包,然后解压到/usr/local/software
2、#配置configure --prefix 代表安装的路径,--with-http_ssl_module 安装ssl,--with-http_stub_status_module查看nginx的客户端状态
./configure --prefix=/usr/local/software/nginx-1.20.0 --with-http_ssl_module --with-http_stub_status_module
3、执行成功后会多出一个Makefile文件
make & make install #编译安装nginx
4、在cd /usr/local/software/nginx-1.20.0/sbin目录下执行./nginx -t,测试启动nginx(.nginx是启动)
5、如果报一下信息
错误信息:
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2016/09/13 19:08:56 [emerg] 6996#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)
则在/usr/local/software/nginx-1.20.0下执行
mkdir logs
chmod 700 logs
6、启动nginx
cd /usr/local/software/nginx-1.20.0/sbin
执行./nginx
7、配置nginx开机自启动
进入vim /etc/rc.d/rc.local
加上/usr/local/software/nginx-1.20.0/sbin/nginx
cd /usr/local/software/nginx-1.20.0/sbin
./nginx -t # 验证配置文件是否能正常启动
./nginx #启动nginx
./nginx -s quit #正常停止
./nginx -s stop #快速停止
./nginx -s reload #重新加载
./nginx -V #查看版本信息