静态页面的配置
server {
listen 90;
server_name 127.0.0.1;
location / {
root /home/wwwroot/default;
index index.html index.htm;
}
}
#php文件的配置
listen 80 ; 代表的是端口,若是其他端口,可以把80换成你想要的端口
server_name 是访问名称,可以填域名或者IP,一开始是server_name _; 这个低杠是默认本服务器的IP
#index 是访问的默认文件,一般不需要修改
#root 是配置网站的项目绝对路径
伪静态
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
这个是TP的nginx伪静态,lnmp安装好之后是没有的,这个一定要加
nginx.conf
server
{
listen 80;
# listen [::]:80 default_server ipv6only=on;
server_name 127.0.0.1;
index index.html index.htm index.php;
root /home/wwwroot/xiangmu/src/public;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/access.log;
}