开发者

nginx + php with drupal + codeigniter in separate folders

开发者 https://www.devze.com 2023-03-26 10:25 出处:网络
I have a Slicehost slice for a dev server, with nginx and PHP. I\'m trying to get drupal running on localhost/drupal and a codeigniter app running on localhost/codeigniter.

I have a Slicehost slice for a dev server, with nginx and PHP.

I'm trying to get drupal running on localhost/drupal and a codeigniter app running on localhost/codeigniter.

I can get one or the other to work, but not both -- the rewrite and fastcgi seem to be interfering with one another.

Does anyone know how to have /drupal and /codeignit开发者_开发问答er both working, with rewrite rules (for SEF URLs), in separate folders in my /var/www?

Cheers.


Ok, you have to create a file (no extension needed) in /etc/nginx/sites-available that represents the name of your folder/domain (ex: drupal, yoursite.com).

Here's a sample file:

server {
 server_name yourdomain.com;
 root /var/www/yourdomain;

 index index.php;

   location / {
     autoindex on;
     try_files $uri $uri/ /index.php;
   }
   location ~ \.php$ {
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_index index.php;
     include fastcgi_params;
   }
}

In the sample above it will actually send url rewrites to $_SERVER['REQUEST_URI']. For more nginx rewrites, you can take a look at http://wiki.nginx.org/HttpRewriteModule for more reference.

Then you want to enable it by creating a symlink of this file in your /etc/nginx/sites-enabled folder

Example: # ln -s /etc/nginx/sites-available/yoursite /etc/nginx/sites-enabled/yoursite

Then restart/reload nginx

 # services nginx reload
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号