我在/var/www中有一个CodeIgniter项目。我们将这个项目称为proj。因此,我在/var/www中有大量文件,在/var/www/proj中有一个CodeIgniter项目。我迫切需要一个支持这一点的Nginx配置。我应该只做一个虚拟主机吗?例如:/var/www/omewebsite.com/和/var/www/proj.omewebsite.com/。你能提供一个支持这个功能的Nginx + CodeIgniter配置吗?
我目前没有使用域名。我只是在VPS上。
谢谢!
发布于 2013-06-04 19:39:15
是。你必须使用虚拟主机,或者创建服务器来监听不同的端口,否则服务器如何知道要服务的位置?除非你指的是像localhost/myporject1/和localhost2/myproject2这样的?然后,只需将服务器设置为指向根/var/www,并在配置项的fastcgi中调整路径
server {
listen 80;
server_name localhost;
root /var/www/;
location ~ /\. {
deny all;
}
#you codigniter project
location /yourcodigniterproject {
index index.html index.php;
try_files /cache$uri @web;
}
#your other project (if usign php replicate the top with difrent directives)
location /yourotherproject {
index index.html index.php;
try_files /cache$uri $uri
}
location @web {
client_max_body_size 10M;
expires 0;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/yourcodigniterproject/index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
}但是如上所述,创建虚拟主机更容易维护。在sites-available中为每个站点创建条目(假设您使用的是linux),然后在使用ln -s in站点时添加然后删除它们-启用`
我有这样的配置。一个虚拟服务器有一个站点代码设置,另一个只是一个简单的静态网站,一个用于phpmyadmin,等等。
https://stackoverflow.com/questions/16906672
复制相似问题