0. 说明
记录下过程下次用的时候好找嘿嘿。
centos 7.6
gcc 4.8.5
nginx 1.20.2
1. 查找和下载安装包
先从这里找到一个合适的版本,下载下来传到 Linux系统。
2. 安装各种依赖包
命令
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
3. 安装 Nginx
下载
[root@VM-16-4-centos software]# wget http://nginx.org/download/nginx-1.20.2.tar.gz
解压
[root@VM-16-4-centos software]# tar -zxvf nginx-1.18.0.tar.gz
进入目录
[root@VM-16-4-centos software]# cd nginx-1.20.2/
配置,后面带的参数根据需要写
[root@VM-16-4-centos nginx-1.20.2]# ./configure --with-http_stub_status_module --with-http_ssl_module
安装
[root@VM-16-4-centos nginx-1.20.2]# make
[root@VM-16-4-centos nginx-1.20.2]# make install
4. 测试
启动服务
[root@VM-16-4-centos nginx-1.20.2]# /usr/local/nginx/sbin/nginx
查看服务
[root@VM-16-4-centos nginx-1.20.2]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7594/nginx: master
访问网址
5. 其他开关命令
-
如过没自定安装路径的话,配置文件在
/usr/local/nginx/conf/nginx.conf
-
启动
[root@VM-16-4-centos nginx-1.20.2]# /usr/local/nginx/sbin/nginx
-
关闭
[root@VM-16-4-centos nginx-1.20.2]# /usr/local/nginx/sbin/nginx -s stop
-
重启
[root@VM-16-4-centos nginx-1.20.2]# /usr/local/nginx/sbin/nginx -s reload
-
检查配置文件是否正确
[root@VM-16-4-centos nginx-1.20.2]# /usr/local/nginx/sbin/nginx -t
6. 参考
参考了如下两篇博客
[1]. centos 安装 nginx
https://blog.csdn.net/turingoal_wan/article/details/121530094
[2]. centos7安装nginx及nginx配置
https://blog.csdn.net/weixin_38521984/article/details/121499343
.
.
.
.
.
.
桃花仙人种桃树,又摘桃花换酒钱_