请知悉:本文最近一次更新为 8年 前,文中内容可能已经过时。

进入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》相关的博文:


留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌