1 首先安裝LNMP (使用LNMP一鍵安裝包,感謝軍哥) 下載地址,步驟LNMP上面都有。
2 使用 vhost 增加一個虛擬主機
3 關鍵
去除 index.php 增加pathinfo支持
server{
listen 80;
#listen [::]:80;
server_name 你的域名;
index index.html index.htm index.php default.html default.htm default.php;
root 你的網(wǎng)站在服務器目錄;
include other.conf;
#error_page 404 /404.html;
## pathinfo支持
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
}
## 去除index.php
location /{
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?$1 last;
break;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log /mnt/wwwlogs/you log name.log access; ## log目錄
}