I generally use Nginx to serve static content on my server, with Apache handling PHP content using PHP-FPM. However, I’m not able to get a WordPress blog homepage to display and I’ve tried all the configuration examples I can find on the web without much luck.
Here is my Nginx config:
server {
listen XXX.XXX.XXX.XXX:80;
server_name wptest.mydomain.com;
access_log /var/log/nginx/testblog_access.log combined;
error_log /var/log/nginx/testblog-error.log;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://127.0.0.1:80;
}
location = /50x.html {
root /var/www/nginx-default;
}
# No access to .htaccess files.
location ~ /\.ht {
deny all;
}
}
My Apache config is as follows:
<VirtualHost 127.0.0.1>
ServerName wptest.mydomain.com
ServerAdmin [email protected]
LogLevel warn
ErrorLog /var/log/apache2/testblog-error.log
CustomLog /var/log/apache2/testblog-access.log combined
Options +FollowSymLinks +ExecCGI -Indexes -MultiViews
AddHandler php-fastcgi .php
Action php-fastcgi /wordpress
Alias /wordpress /var/www/wordpress
FastCgiExternalServer /var/www/wordpress -host 127.0.0.1:9000
RewriteEngine on
DocumentRoot /var/www/wordpress
DirectoryIndex index.php
<Directory />
DirectoryIndex index.php
AllowOverride All
Options +FollowSymLinks +ExecCGI +SymLinksIfOwnerMatch
</Directory>
<Directory /var/www/wordpress>
AllowOverride All
Options +FollowSymLinks +ExecCGI +SymLinksIfOwnerMatch
</Directory>
</VirtualHost>
I am not able to view “http://wptest.mydomain.com/” or “http://wptest.mydomain.com/wp-admin” but “http://wptest.mydomain.com/wp-login.php” does work. What am I doing wrong?
Version information:
+ OS: Debian 5/Lenny
+ Apache: 2.2.9
+ Nginx: 0.7.65
+ WordPress: 3.1.2
3 Answers
Both servers are listening to the same port. You have Nginx set to listen to 80 and nothing is set for Apache unless it’s in your ports.conf.
Your also proxy passing to Apache port 80 in your Nginx conf.
In the Nginx conf change
proxy_pass http://127.0.0.1:80;
to
proxy_pass http://127.0.0.1:9000;
change listen XXX.XXX.XXX.XXX:80;
to listen 80;
In your Vhosts
add
NameVirtualHost *:9000
Listen 9000
Above the <VirtualHost>
tag or in the ports.conf file (If you have other vhost that don’t use Nginx add it to the top of your vhost. Change virtual host to look like this:
<VirtualHost *9000>