很多人第一次配Nginx一脸懵,其实核心就那几行。
虚拟主机配置:
server {
listen 80;
server_name 你的域名.com;
root /www/wwwroot/你的站点;
index index.php index.html;
}
PHP解析:
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
伪静态:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
配置完记得 nginx -t 检查一下,再 reload。
虚拟主机配置:
server {
listen 80;
server_name 你的域名.com;
root /www/wwwroot/你的站点;
index index.php index.html;
}
PHP解析:
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
伪静态:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
配置完记得 nginx -t 检查一下,再 reload。
广告
成都招摇科技
| 专业网站建设服务,从域名到上线一站式搞定,咨询微信:-62040
评论
还没有评论,来抢沙发。
登录后可以发表评论。去登录 · 免费注册