【发布时间】:2016-06-25 01:22:30
【问题描述】:
我的localhost 上有一个Codeigniter 应用程序。我这样配置主机文件:
127.0.0.1 localhost
127.0.0.1 myapp
所以我可以用链接打开我的项目
http://myapp/
但是当我尝试通过http://localhost/myapp 或http://192.168.1.10/myapp 打开项目时,它不起作用。但是使用 apache 一切正常。我想在 nginx 上解决这个问题。
我的 nginx 配置:
server {
listen 80;
listen [::]:80;
root /var/www/nginx/myapp;
index index.html index.htm index.php;
server_name myapp www.myapp;
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
【问题讨论】:
标签: php codeigniter nginx server localhost