I'm new to Nginx but was interested in trying it out.
I now have Nginx listening to port 80 and serving static html content from /srv/www for a main "promo site". I've also set up apache2 to the serve content from the same location to localhost:8080. Under that location I have a folder called beta which contains a Drupal installation that I would like to serve with Apache instead of Nginx.
I've successfully managed to configure Nginx so that requests going to example.com/beta are served by Apache and the files are correctly visible in browser, except for any Drupal related php files. info.php (<?php phpinfo(); ?>
) also works. For any of the Drupal related php files I get a standard 500 error.
My config files for both apache and nginx below:
Apache:
<VirtualHost 127.0.0.1:8080>
ServerAdmin webmaster@localhost
DocumentRoot /srv/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /srv/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
AddType application/x-httpd-php .php
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Nginx:
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.html index.php index.htm;
# Make site accessible from http://localhost/
server_name example.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
#THIS BIT IS FOR DRUPAL
location ~ ^/beta {
proxy_pass http://127.0.0.1:8080;
include /etc/nginx/proxy_params;
index index.php index.html index.htm;
}
}