Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 23rd April 2012, 13:25
cyprus cyprus is offline
Member
 
Join Date: Oct 2011
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default Wordpress Multisite get an 502

Hello last week I got ISPConfig to run after 2 weeks of hard work.
I resolved each task to get ISPcontig running on my server but the main point why I even thought about to switch my configuration is still not accomplished.

Before I start to describe the Problem here is my server config.
Debian Squeeze, Nginx , php-fpm, Postfix / Dovecot ,MySQL 5.5

Most stuff is fine ISPconfig seems to work like it should be. Postfix / Dovecot works as well.

I´ve uploaded a Flash Site to one of my webs and it works

I tried to move one of my Wordpress ms installation from an Apache environment, and this fails.
I know I can´t use the Apache .htaccess rules anymore and have to tell nginx what to do. I took the Nginx Config from the wordpress.org codex.
http://codex.wordpress.org/Nginx

The configuration is clear in most cases but there is one point which is not clear
Quote:
# Upstream to abstract backend connection(s) for PHP.
upstream php {
server unix:/tmp/php-fpm.sock;
# server 127.0.0.1:9000;
}
I implemented it as described but if I call a site I get an 502 Error.
Quote:
Folgender Fehler ist aufgetreten:

Dieser Server hat eine ungültige Antwort von einem Upstream-Server erhalten, auf den zugegriffen wurde, um die Anforderung zu erfüllen.
I get an invalid request from the Upstream Server.
And now I´m a littlebit lost. And need your inspiration to solve the problem.

Thank you in advance.
Cyprus
Reply With Quote
Sponsored Links
  #2  
Old 23rd April 2012, 13:35
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,977
Thanks: 825
Thanked 5,369 Times in 4,216 Posts
Default

The nginx configuration for php is done by ispconfig, so you should not duplicate this with your manual configuration or nginx will fail. The guide you followed is for a complete nginx configuration for servers without a controlpanel thats uses different paths etc., if you use a controlpanel like ispconfig, then dont touch nginx.conf file or site configuration file. Instaed you just add the wordpress rules in the custom nginx directives field in ispconfig.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 23rd April 2012, 14:07
cyprus cyprus is offline
Member
 
Join Date: Oct 2011
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Instaed you just add the wordpress rules in the custom nginx directives field in ispconfig.
I read about such field but where should this be?

Thank you for your reply
Reply With Quote
  #4  
Old 23rd April 2012, 14:13
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,977
Thanks: 825
Thanked 5,369 Times in 4,216 Posts
Default

Options tab of the website settings.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #5  
Old 23rd April 2012, 14:42
cyprus cyprus is offline
Member
 
Join Date: Oct 2011
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay thank you I found it.

But there are a few questions remaining.
1) Do you recommend to turn " Use Socket for PHP-FPM" on?
2) Do you agree that I only have to drop the rewrite rules for Nginx into the Nginx topic

Quote:
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}

# Pass uploaded files to wp-includes/ms-files.php.
rewrite /files/$ /index.php last;

# For multisite: Use a caching plugin that creates symlinks to the correct subdirectory structure to get some performance gains.
set $cachetest "$document_root/wp-content/cache/ms-filemap/${host}${uri}";
if ($uri ~ /$) {
set $cachetest "";
}
if (-f $cachetest) {
# Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the next rule.
rewrite ^ /wp-content/cache/ms-filemap/${host}${uri} break;
}

if ($uri !~ wp-content/plugins) {
rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-ms-subdir-wp-super-cache.conf;
# include global/wordpress-ms-subdir-w3-total-cache.conf;

# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
Thanx in advance
Cyprus
Reply With Quote
  #6  
Old 23rd April 2012, 15:29
cyprus cyprus is offline
Member
 
Join Date: Oct 2011
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So I deleted everything I´ve changed in the nginx.conf and orx.org vhost config and dropped the rewrite rule I posted above without the part for the caching plugin into nginx configuration in the ispconfig backend and the result is a 500 Error.
Not shure what to check next.
Reply With Quote
  #7  
Old 24th April 2012, 00:14
cyprus cyprus is offline
Member
 
Join Date: Oct 2011
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

While I´m trying to solve this issue. I had a look at my ispconfig backend and I ask myself whether I missed something in the configuration cause. In the row IP-Address there is no Ip to choose theres is just a star. Could this cause my error and how can I solve it.

Thanx in advance
Cyprus
Reply With Quote
  #8  
Old 24th April 2012, 14:14
cyprus cyprus is offline
Member
 
Join Date: Oct 2011
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay I fixed my mistake. Start all over again. And it works to load the site and get into the backend. At this moment I´ve changed nothing in the options tab.
But I got still stucked, cause I don´t know what to implement in the options tab and what will be solved by ispconfig.
Can anybody provide a working rewrite rule. Or give me a hint what ispconfig does and what not?

Thanx in advance
Cyprus
Reply With Quote
  #9  
Old 24th April 2012, 14:56
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

This is what I use in the nginx Directives field on the Options tab in ISPConfig for a Wordpress site (with the W3 Total Cache plugin):

Code:
       location / {
                try_files $uri $uri/ /index.php?$args;
       }

       # Add trailing slash to */wp-admin requests.
       rewrite /wp-admin$ $scheme://$host$uri/ permanent;

       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
       }

       include /var/www/mysite.de/web/nginx.conf;

       location ~ /nginx.conf {
                deny all;
                access_log off;
                log_not_found off;
       }
/var/www/mysite.de/web/nginx.conf contains:

Code:
# BEGIN W3TC Page Cache cache
location ~ /wp-content/w3tc/pgcache.*html$ {
    add_header X-Powered-By "W3 Total Cache/0.9.2.4";
    add_header Vary "Accept-Encoding, Cookie";
}
location ~ /wp-content/w3tc/pgcache.*gzip$ {
    gzip off;
    types {}
    default_type text/html;
    add_header X-Powered-By "W3 Total Cache/0.9.2.4";
    add_header Vary "Accept-Encoding, Cookie";
    add_header Content-Encoding gzip;
}
# END W3TC Page Cache cache
# BEGIN W3TC Browser Cache
gzip on;
gzip_types text/css application/x-javascript text/x-component text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
location ~ \.(css|js|htc)$ {
    add_header X-Powered-By "W3 Total Cache/0.9.2.4";
}
location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
    add_header X-Powered-By "W3 Total Cache/0.9.2.4";
}
location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
    add_header X-Powered-By "W3 Total Cache/0.9.2.4";
}
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
rewrite ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 last;
set $w3tc_rewrite 1;
if ($request_method = POST) {
    set $w3tc_rewrite 0;
}
if ($query_string != "") {
    set $w3tc_rewrite 0;
}
if ($http_host != "mysite.de") {
    set $w3tc_rewrite 0;
}
set $w3tc_rewrite2 1;
if ($request_uri !~ \/$) {
    set $w3tc_rewrite2 0;
}
if ($request_uri ~* "(sitemap(_index)?\.xml(\.gz)?|[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?)") {
    set $w3tc_rewrite2 1;
}
if ($w3tc_rewrite2 != 1) {
    set $w3tc_rewrite 0;
}
set $w3tc_rewrite3 1;
if ($request_uri ~* "(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|\/feed\/|wp-.*\.php|index\.php)") {
    set $w3tc_rewrite3 0;
}
if ($request_uri ~* "(wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php)") {
    set $w3tc_rewrite3 1;
}
if ($w3tc_rewrite3 != 1) {
    set $w3tc_rewrite 0;
}
if ($http_cookie ~* "(comment_author|wp\-postpass|wordpress_\[a\-f0\-9\]\+|wordpress_logged_in)") {
    set $w3tc_rewrite 0;
}
if ($http_user_agent ~* "(W3\ Total\ Cache/0\.9\.2\.4)") {
    set $w3tc_rewrite 0;
}
set $w3tc_ua "";
set $w3tc_ref "";
set $w3tc_ssl "";
set $w3tc_enc "";
if ($http_accept_encoding ~ gzip) {
    set $w3tc_enc _gzip;
}
set $w3tc_ext "";
if (-f "$document_root/wp-content/w3tc/pgcache/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl.html$w3tc_enc") {
    set $w3tc_ext .html;
}
if ($w3tc_ext = "") {
  set $w3tc_rewrite 0;
}
if ($w3tc_rewrite = 1) {
    rewrite .* "/wp-content/w3tc/pgcache/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl$w3tc_ext$w3tc_enc" last;
}
# END W3TC Page Cache core
This is based on the following tutorial: http://www.howtoforge.com/running-wo...e-ubuntu-11.04
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #10  
Old 2nd May 2012, 15:03
cyprus cyprus is offline
Member
 
Join Date: Oct 2011
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Thank you falko for sharing your entries.
These may be fine on a single wordpress installation but didn´t help in a multisite environment.

This has done the job for me:
Quote:
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}

# Pass uploaded files to wp-includes/ms-files.php.
rewrite /files/$ /index.php last;

# For multisite: Use a caching plugin that creates symlinks to the correct subdirectory structure to get some performance gains.
set $cachetest "$document_root/wp-content/cache/ms-filemap/${host}${uri}";
if ($uri ~ /$) {
set $cachetest "";
}
if (-f $cachetest) {
# Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the next rule.
rewrite ^ /wp-content/cache/ms-filemap/${host}${uri} break;
}

if ($uri !~ wp-content/plugins) {
rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-ms-subdir-wp-super-cache.conf;
# include global/wordpress-ms-subdir-w3-total-cache.conf;

# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
BUT there´s a big BUT! I still have errors on sites which have an different theme than the main twenty11. For my these sites I´m still getting an 502 and 500 Error. Which is not acceptable.
My question is, are there any suggestions what to do?
And I´m a little bit frustrated about nginx, is the a way back to apache whithout starting all over?

Thanx for your support Cyprus
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Updating and Uploading to Wordpress website on ISPConfig3 - Fedora 13 MrCompTech Tips/Tricks/Mods 8 25th August 2014 14:18
wordpress multisite a0011010011 Installation/Configuration 8 14th February 2012 22:44
ISPConfig 3.x - First Steps (Creating Web Sites, Email Addresses, Etc.) sighkick Suggest HOWTO 18 7th October 2010 00:12
ispconfig wordpress and directory/file permissions willebanks Installation/Configuration 4 9th March 2010 21:52
wordpress u Amorphous Installation/Configuration 2 10th July 2009 10:00


All times are GMT +2. The time now is 23:31.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.