{"id":411,"date":"2009-07-02T17:48:09","date_gmt":"2009-07-02T10:48:09","guid":{"rendered":"http:\/\/adityo.blog.binusian.org\/?p=411"},"modified":"2009-07-15T19:05:13","modified_gmt":"2009-07-15T12:05:13","slug":"how-to-set-wpmu-with-nginx-wp-super-cache-apache","status":"publish","type":"post","link":"https:\/\/adityo.blog.binusian.org\/?p=411","title":{"rendered":"How to set wpmu with nginx + wp super cache + apache"},"content":{"rendered":"<p style=\"text-align: justify;\">Recently i am working with nginx and apache on wpmu. I am trying to test and bencmark both web server. Yes i have browse and heard that nginx is more fastest than apache but i also having difficulties with the nginx mod rewrite setting to wpmu supercache on the other side there were no problem with apache mod rewrite but i have a lot memory and resource when i use apache. Okay then when i stumble on this article <a href=\"http:\/\/tech.nocr.at\/tech\/how-to-speed-up-wordpress-with-nginx-and-wp-super-cache\/\" target=\"_blank\">http:\/\/tech.nocr.at\/tech\/how-to-speed-up-wordpress-with-nginx-and-wp-super-cache\/<\/a> it will be a great idea if i can apply the article on the wpmu, i already have wpmu , wp supercache , nginx and apache. The main idea with that article is to split the static and dynamic content process, nginx will process the static content and the apache will process the dynamic content.<\/p>\n<p style=\"text-align: justify;\">System requirement:<\/p>\n<p style=\"text-align: justify;\">&#8211; Centos 5.3<\/p>\n<p style=\"text-align: justify;\">&#8211; Apache ( httpd-2.2.8 )<\/p>\n<p style=\"text-align: justify;\">&#8211; Nginx (nginx-0.6.36-1.el5)<\/p>\n<p style=\"text-align: justify;\">&#8211; wp super cache plugin <strong>Version:<\/strong> 0.9.4.3<\/p>\n<p style=\"text-align: justify;\">\n<p style=\"text-align: justify;\">Okay let&#8217;s start the changes<\/p>\n<p style=\"text-align: justify;\">1.\u00a0 I assume you have installed apache and wpmu first of all we need to changes the apache(httpd) port firstwe can changes it on the httpd.conf at \/etc\/httpd\/conf\/httpd.conf<\/p>\n<p><code># vi \/etc\/httpd\/conf\/httpd.conf<\/code><br \/>\n<code>Listen 80<br \/>\nListen 8080<\/code><\/p>\n<p>2. Next we are going to turn KeepAlives off on Apache since Nginx will be dealing with all of the actual browser connections. This will ensure that all of the child processes in Apache die quickly and don\u2019t hang around chewing up memory. Find the KeepAlive entry in your \/etc\/httpd\/conf\/httpd.conf file and set it to off<\/p>\n<p><code># vi \/etc\/httpd\/conf\/httpd.conf<\/code><br \/>\n<code>KeepAlive Off<\/code><\/p>\n<p>3. You need to changes your virtual directory to match the nginx config. Here is my config<\/p>\n<p><code># vi \/etc\/httpd\/conf\/httpd.conf<\/code><br \/>\n<code><br \/>\nNameVirtualHost localhost:8080<br \/>\nServerName *.blog.myblog.org<br \/>\n&lt; VirtualHost localhost:8080&gt;<br \/>\nDocumentRoot \/blog.myblog.org\/public_html\/<br \/>\n&lt; Directory \"\/blog.myblog.org\/public_html\" &gt;<br \/>\nAllowOverride All<br \/>\nOptions All<br \/>\nOrder allow,deny<br \/>\nAllow from all<br \/>\n&lt; \/ Directory&gt;<br \/>\nErrorLog logs\/blog.myblog.org-error_log<br \/>\nCustomLog logs\/blog.myblog.org-access_log combined<br \/>\n&lt; \/ VirtualHost&gt;<br \/>\n&lt; VirtualHost localhost:8080 &gt;<br \/>\nServerName myotherweb.com<br \/>\nDocumentRoot \/myotherweb.com\/public_html\/<br \/>\n&lt; Directory \"\/myotherweb.com\/public_html\" &gt;<br \/>\nAllowOverride All<br \/>\nOptions All<br \/>\nOrder allow,deny<br \/>\nAllow from all<br \/>\n&lt; \/ Directory &gt;<br \/>\nErrorLog logs\/myotherweb.com-error_log<br \/>\nCustomLog logs\/myotherweb.com-access_log common<br \/>\n&lt; \/ VirtualHost&gt;<\/code><\/p>\n<p>5. You neew to reload your httpd service<br \/>\n<code># \/etc\/init.d\/httpd reload <\/code><\/p>\n<p>6.\u00a0 Okay we will set the nginx , if you did not have nginx yet on centos you can insstall it from EPEL repository you can refer to here <a href=\"http:\/\/www.cyberciti.biz\/faq\/rhel-fedora-install-configure-nginx-php5\/\" target=\"_blank\">http:\/\/www.cyberciti.biz\/faq\/rhel-fedora-install-configure-nginx-php5\/<\/a><\/p>\n<p>Okay we will set the nginx.conf on \/etc\/nginx\/nginx.conf<br \/>\n<code> # vi \/etc\/nginx\/nginx.conf <\/code><br \/>\n<code><br \/>\n#user  nginx;<br \/>\nuser  apache;<br \/>\nworker_processes  10;<br \/>\nerror_log         \/var\/log\/nginx\/error.log;<br \/>\npid               \/var\/run\/nginx.pid;<br \/>\nevents {<br \/>\nworker_connections  1024;<br \/>\n}<br \/>\nhttp {<br \/>\ninclude       \/etc\/nginx\/mime.types;<br \/>\ndefault_type  application\/octet-stream;<br \/>\nlog_format  main  '$remote_addr - $remote_user [$time_local] $request '<br \/>\n'\"$status\" $body_bytes_sent \"$http_referer\" '<br \/>\n'\"$http_user_agent\" \"$http_x_forwarded_for\"';<br \/>\naccess_log  \/var\/log\/nginx\/access.log  main;<br \/>\nsendfile        on;<br \/>\ntcp_nopush     on;<br \/>\ntcp_nodelay    on;<br \/>\ngzip  on;<br \/>\nserver {<br \/>\nlisten       80;<br \/>\nserver_name  blog.myblog.org *.blog.myblog.org;<br \/>\n# Main location<br \/>\nlocation \/ {<br \/>\nproxy_pass         http:\/\/127.0.0.1:8080\/;<br \/>\nproxy_redirect     off;<br \/>\nproxy_set_header   Host             $host;<br \/>\nproxy_set_header   X-Real-IP        $remote_addr;<br \/>\nproxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;<br \/>\nclient_max_body_size       10m;<br \/>\nclient_body_buffer_size    128k;<br \/>\nproxy_connect_timeout      90;<br \/>\nproxy_send_timeout         90;<br \/>\nproxy_read_timeout         90;<br \/>\nproxy_buffer_size          4k;<br \/>\nproxy_buffers              4 32k;<br \/>\nproxy_busy_buffers_size    64k;<br \/>\nproxy_temp_file_write_size 64k;<br \/>\n}<br \/>\nlocation ~ wp-login.php$ {<br \/>\nroot \/blog.myblog.org\/public_html;<br \/>\nfastcgi_pass   127.0.0.1:9000;<br \/>\nfastcgi_index  wp-login.php;<br \/>\nfastcgi_param  SCRIPT_FILENAME  \/blog.myblog.org\/public_html$fastcgi_script_name;<br \/>\ninclude        fastcgi_params;<br \/>\n}<br \/>\n# Static files location<br \/>\nlocation ~*^.+^.+^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {<br \/>\nroot \/blog.myblog.org\/public_html;<br \/>\n# if the requested file exists, return it immediately<br \/>\nif (-f $request_filename) {<br \/>\nbreak;<br \/>\n}<br \/>\nset $supercache_file '';<br \/>\nset $supercache_uri $request_uri;<br \/>\nif ($request_method = POST) {<br \/>\nset $supercache_uri '';<br \/>\n}<br \/>\n# Using pretty permalinks, so bypass the cache for any query string<br \/>\nif ($query_string) {<br \/>\nset $supercache_uri '';<br \/>\n}<br \/>\nif ($http_cookie ~* \"comment_author_|wordpress|wp-postpass_\" ) {<br \/>\nset $supercache_uri '';<br \/>\n}<br \/>\n# if we haven't bypassed the cache, specify our supercache file<br \/>\nif ($supercache_uri ~ ^(.+)$) {<br \/>\nset $supercache_file \/wp-content\/cache\/supercache\/$http_host\/$1index.html;<br \/>\n}<br \/>\n# only rewrite to the supercache file if it actually exists<br \/>\nif (-f $document_root$supercache_file) {<br \/>\nrewrite ^(.*)$ $supercache_file break;<br \/>\n}<br \/>\n# all other requests go to WordPress<br \/>\nif (!-e $request_filename) {<br \/>\nrewrite . \/index.php last;<br \/>\n}<br \/>\n}<br \/>\n# Static files location<br \/>\nlocation ~*^.+^.+^.+ (jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {<br \/>\nroot \/myotherweb.com\/public_html;<br \/>\n}<\/p>\n<p>}<br \/>\n}<br \/>\n <\/code><br \/>\nyou can remove the wp-login.php because i set my wp-login.php to be process with the nginx php_cgi ( i use ldap and ldap session will refer to blog.myblog.org:8080 and i need blog.myblog.org port 80 )<br \/>\n<code><br \/>\nlocation ~ wp-login.php$ {<br \/>\nroot \/blog.myblog.org\/public_html;<br \/>\nfastcgi_pass   127.0.0.1:9000;<br \/>\nfastcgi_index  wp-login.php;<br \/>\nfastcgi_param  SCRIPT_FILENAME  \/blog.myblog.org\/public_html$fastcgi_script_name;<br \/>\ninclude        fastcgi_params;<br \/>\n}<br \/>\n<\/code><br \/>\n7. And the final steps is to start your nginx<br \/>\n<code># \/etc\/init.d\/nginx start <\/code><br \/>\nand in my case since i process the wp-login.php on nginx i need to turm on the spawn-fcgi \/php_cgi<br \/>\n<code># \/etc\/init.d\/php_cgi start <\/code><\/p>\n<p>8. And that&#8217;s it you can start test your  sites  http:\/\/blog.myblog.org<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently i am working with nginx and apache on wpmu. I am trying to test and bencmark both web server. Yes i have browse and heard that nginx is more fastest than apache but i also having difficulties with the nginx mod rewrite setting to wpmu supercache on the other side there were no problem [&hellip;]<\/p>\n","protected":false},"author":386,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[489],"tags":[],"class_list":["post-411","post","type-post","status-publish","format-standard","hentry","category-freebsd"],"_links":{"self":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/users\/386"}],"replies":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=411"}],"version-history":[{"count":17,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions"}],"predecessor-version":[{"id":515,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions\/515"}],"wp:attachment":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}