进入Nginx虚拟主机配置目录:
cd /etc/nginx/sites-enabled
新建一个虚拟主机文件:
vim learning-phalcon.localhost
内容如下:
server {
listen 80;
server_name learning-phalcon.localhost;
index index.php;
set $root_path "/var/www/learning-phalcon.localhost/public";
root $root_path;
client_max_body_size 10M;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php _url=/$1;
}
location ~ \.php {
fastcgi_index /index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED
$document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
让Nginx重新载入配置:
service nginx reload
然后添加本地hosts解析:
127.0.0.1 learning-phalcon.localhost
如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。
如本文对您有用,捐赠和留言 将是对我最好的支持~(捐赠可转为站内积分)
如愿意,请向朋友推荐本站,谢谢。
尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。
留言