配置如下:
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
server {
listen 80;
listen [::]:80;
server_name www.tp5.com;
root /home/dujinshuai/tp5/public;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=/$1 last;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
#With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}