首先要做的第一件事情 -> 关闭防火墙或者开发80端口如下命令
#查看防火墙状态
[root@localhost ~]# systemctl status firewalld
#开启防火墙
[root@localhost ~]# systemctl start firewalld
关闭防火墙 [root@localhost ~]# systemctl stop firewalld
#开启防火墙 [root@localhost ~]# service firewalld start
#若遇到无法开启
#先用: [root@localhost ~]# systemctl unmask firewalld.service
#然后: [root@localhost ~]# systemctl start firewalld.service
#开放端口 #开放端口 [root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
#查询端口号80是否开启: [root@localhost ~]# firewall-cmd --query-port=80/tcp
#重启防火墙: [root@localhost ~]# firewall-cmd --reload
#查询有哪些端口是开启的:
[root]# firewall-cmd --list-port
80/tcp
出现这个说明你的80端口已经开放出来。。。。
接下来就是配置了。。。。
vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
location / {
root /data/www;
index index.html index.php index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root /data/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
nginx 重启出现问题
[root@conf]# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[root@conf]# ^C
[root@conf]# nginx -s stop
[root@conf]# nginx
[root@conf]# ps -aux | grep nginx
root 4542 0.0 0.0 20552 636 ? Ss 16:18 0:00 nginx: master process nginx
nobody 4543 0.0 0.1 20924 1100 ? S 16:18 0:00 nginx: worker process
root 4549 0.0 0.0 112708 976 pts/0 S+ 16:18 0:00 grep --color=auto nginx
直接配置啊好啦,然后直接配置php-fpm是否开启,
直接域名访问即可!!!