CentOS7.9+Nginx1.20+PHP8.1+MySQL5.7运行环境搭建部署
操作系统:CentOS7.9
Nginx版本:Nginx1.20.1
PHP版本:PHP8.1.29
MySQL版本:MySQL5.7.44
一、Nginx安装
1、列出可用的Nginx包:
[root@localhost /]# yum list|grep nginx
2、安装Nginx
[root@localhost /]# yum install nginx.x86_64
3、启动Nginx
[root@localhost nginx]# systemctl start nginx
4、查看Nginx运行状态
[root@localhost nginx]# systemctl status nginx
5、将Nginx加入开机自动启动
[root@localhost nginx]# systemctl enable nginx
6、查看Nginx服务是否在开机自动列表中
[root@localhost nginx]# systemctl list-unit-files --type=service|grep enabled
7、修改Nginx服务默认端口为81
[root@localhost nginx]# cd /etc/nginx/
[root@localhost nginx]# vi nginx.conf
将
listen 80;
listen [::]:80;
改为
listen 81; #因系统80端口已被占用,故改为81,如果80端口可用这里不改也可以
listen [::]:81;
重启nginx
[root@localhost nginx]# systemctl restart nginx
8、防火墙开放81端口
查看当前防火墙规则:
[root@localhost log]# firewall-cmd --list-all
开放指定的端口(以开放TCP端口81为例),以便于网络访问数据:
firewall-cmd --zone=public --add-port=81/tcp --permanent
重新加载防火墙以应用更改:
firewall-cmd --reload
9、通过浏览器访问:http://192.