Linux (阿里云) 配置nginx与php

首先要做的第一件事情 -> 关闭防火墙或者开发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是否开启,

直接域名访问即可!!!

 


 

 

 

 

 


 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值