是的。你必須使用虛擬主機,或者創建服務器來監聽不同的端口,否則服務器將如何知道服務的位置?除非你的意思是像localhost/myporject1/
和localhost2/myproject2
?然後就設置服務器指向根/var/www
和FastCGI的調整路徑CI
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
網站,enabled`
我配置一樣,去刪除它們。一個虛擬服務器有一個站點codeignoter設置,另一個只是普通的靜態網站,一個用於phpmyadmin等...