server {
listen 80;
listen [::]:80;
server_name demo.zhuchenglin.cn;
#前端资源配置
location / {
root /var/www/html/demo/public;
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
# 后端配置,到index.php
location ~ \.php$ {
root /var/www/html/demo/public;
fastcgi_pass unix:/run/php/php7.0-fpm.sock; #此处要和上面查看的php-fpm保持一致
#或 fastcgi_pass 127.0.0.1:9000
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
到此为止,在浏览器地址栏上输入demo.zhuchenglin.cn就可以正常访问PHP网站了。
注:本文操作在ubuntu系统上进行的,在其他Linux系统上安装软件的命令可能不一样(比如Centos用yum)
如需转载请注明出处:https://cloud.tencent.com/developer/article/1421771
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有