进入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
未经允许不得转载:阿藏博客 » 零基础学Phalcon 2 配置Nginx