文章目录
Nginx 安装配置
-
下载nginx安装包1.17.8版本,nginx安装包( .tar⽂件)下载地址:http://nginx.org
-
安装Nginx依赖,pcre、openssl、gcc、zlib(推荐使⽤yum源⾃动安装)
[root@10 software]# yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
作为依赖被升级:
...
完毕!
- 解包Nginx软件包,解压完成之后会在当前目录生成一个nginx-1.17.8安装目录
[root@10 software]# tar -xvf nginx-1.17.8.tar
- 进⼊解压之后的⽬录 nginx-1.17.8
[root@10 software]# cd nginx-1.17.8/
- 命令⾏执⾏./configure
[root@10 nginx-1.17.8]# ./configure
...
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
- 命令⾏执⾏ make
[root@10 nginx-1.17.8]# make
...
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
make[1]: 离开目录“/home/laosan/software/nginx-1.17.8”
- 命令⾏执⾏ make install,完毕之后在/usr/local/下会产⽣⼀个nginx⽬录
[root@10 nginx-1.17.8]# make install
...
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
-e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \
-e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
< man/nginx.8 > objs/nginx.8
make[1]: 离开目录“/home/laosan/software/nginx-1.17.8”
- 进⼊sbin⽬录中,执⾏启动nginx命令
[root@10 sbin]# pwd
/usr/local/nginx/sbin
[root@10 sbin]# ./nginx
[root@10 sbin]# ps -ef|grep nginx
root 18289 1 0 20:32 ? 00:00:00 nginx: master process ./nginx
nobody 18290 18289 0 20:32 ? 00:00:00 nginx: worker process
root 18293 11483 0 20:32 pts/4 00:00:00 grep --color=auto nginx
- 关闭防火墙
#关闭iptables
[root@10 nginx]# systemctl stop iptables
Failed to stop iptables.service: Unit iptables.service not loaded.
#关闭firewalld
[root@10 nginx]# systemctl stop firewalld
#设置每次启动不开启防火墙
[root@10 nginx]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
-
然后访问服务器的80端⼝(nginx默认监听80端⼝)
-
Nginx主要命令
- ./nginx 启动nginx
- ./nginx -s stop 终⽌nginx
- ./nginx -s reload (重新加载nginx.conf配置⽂件)