Running on Ubunty 10.04 Nginx (one of latest) with Wordpress subdomain multisite using the plugin.

APC i have latest version same with php, I am running 4 websites with almost no traffic (30 hits per day on each) and the cloud server with rackspace (2gig ram, basic model) seems 50% ram use is normal. It works, but

1) I am using batcache, apc plugins, but i am not sure how much memory to give them, currently 128megs. I put APC at 128 megs due to errors in log asking for more memory and see below how it looks. http://i.imgur.com/dKTmz.jpg <--- image of apc.php page graph

2) javascript not getting gzipped.

3) index.php is inside every single url, and if removed wordpress throws errors.

Below is my cfg files, Please help me see what is missing, I looked at 50 nginx pages for configs and adapted this one from them since none of them were exactly suited for my setup


user www-data;
worker_processes 2;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
      use epoll; #v1
     # multi_accept on; #v1

http {

    # Basic Settings

    sendfile on;
    tcp_nopush on;
      #tcp_nodelay off; #v1
    tcp_nodelay on; #v2
    server_tokens off;

    include mime.types;

    default_type  application/octet-stream;
    index index.php index.htm index.html redirect.php;

    keepalive_timeout 15;
    keepalive_requests 2000;
    types_hash_max_size 2048;

    ##necessary if using a multi-site plugin
    server_name_in_redirect off;
    ##necessary if running Nginx behind a reverse-proxy
    port_in_redirect off;
    server_names_hash_bucket_size 64;

    open_file_cache max=1000 inactive=300s;
    open_file_cache_valid 360s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;

    client_body_buffer_size 128K;
    client_header_buffer_size 1k;
    client_max_body_size 2m;
    large_client_header_buffers 4 8k;

    client_body_timeout   10m;
    client_header_timeout 10m;
    send_timeout          10m;

    # Logging Settings

    error_log /var/log/nginx/error.log;
        access_log off;

    # Gzip Settings

    gzip on;

    gzip_vary on;
    gzip_proxied any; #v2
      #gzip_proxied     expired no-cache no-store private auth; #v1
    gzip_comp_level 6;
    gzip_min_length  1000;
    gzip_buffers 32 8k; #v1
   # gzip_buffers 16 8k; #v2
    gzip_http_version 1.1;

    gzip_disable "MSIE [1-6].(?!.*SV1)";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    # Fast cgi

  #  fastcgi_intercept_errors on;
  #  fastcgi_ignore_client_abort on;
  #  fastcgi_buffers 8 16k;
   # fastcgi_buffer_size 32k;
 #   fastcgi_read_timeout 120;
    #fastcgi_index  index.php;
  #  limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

    # Virtual Host Configs

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

sites available

map $host $wp_dir_id {
        .my-website-with-id-1-in-wordpress.com      1;
        site2.com      2;
        site3.com      3;
        site4.com      4;
server {
        ## Ports
        listen          80;

        ## server name
        # . acts as wildcard

        server_name     .my-website-with-id-1-in-wordpress.com;

        ## root

        root            /var/www/;

        ## global rewrites
        # WordPress Network sites files (map is above)

        if ( $wp_dir_id != 1 )
                rewrite ^/files/(.*)$ /wp-content/blogs.dir/$wp_dir_id/files/$1 last;
        # fallback if site is not mapped
        if ( $wp_dir_id = 1 )
                rewrite ^(.*)/files/(.*)$ /wp-includes/ms-files.php?file=$2 last;
        ## locations

        location / {
                # enable browser cache for images
                # not location, because this applies for PHP served images as well in WP Network
                if ( $uri ~ \.(ico|gif|jpg|jpeg|png)$  ) {
                        expires 31d;
                        add_header Pragma public;
                        add_header Cache-Control "public, must-revalidate, proxy-revalidate";

                # enable browser cache for css / js
                # not location, because this applies for PHP served files as well in WP Network
                if ( $uri ~ \.(css|js)$  ) {
                        expires 7d;
                        add_header Pragma public;
                        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
                # default uri
                try_files $uri $uri/ @rewrites;
        # rewrite rules
        location @rewrites {
                rewrite ^(.*)$ /index.php?q=$1 last;
        ## hide files starting with .
        location ~ /\. {
                deny all;
                log_not_found off;
        ## enable nginx status screen, optional
        location /nginx_status {
                stub_status on;
        ## pass to PHP5-FPM server in the background
        location ~ .php {
                fastcgi_param   QUERY_STRING            $query_string;
                fastcgi_param   REQUEST_METHOD          $request_method;
                fastcgi_param   CONTENT_TYPE            $content_type;
                fastcgi_param   CONTENT_LENGTH          $content_length;
                fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
                fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
                fastcgi_param   REQUEST_URI             $request_uri;
                fastcgi_param   DOCUMENT_URI            $document_uri;
                fastcgi_param   DOCUMENT_ROOT           $document_root;
                fastcgi_param   SERVER_PROTOCOL         $server_protocol;
                fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
                fastcgi_param   SERVER_SOFTWARE         nginx;
                fastcgi_param   REMOTE_ADDR             $remote_addr;
                fastcgi_param   REMOTE_PORT             $remote_port;
                fastcgi_param   SERVER_ADDR             $server_addr;
                fastcgi_param   SERVER_PORT             $server_port;
                fastcgi_param   SERVER_NAME             $server_name;
                # PHP only, required if PHP was built with --enable-force-cgi-redirect
                fastcgi_param   REDIRECT_STATUS         200;
                fastcgi_index                           index.php;
                fastcgi_connect_timeout                 60;
                fastcgi_send_timeout                    180;
                fastcgi_read_timeout                    180;
                fastcgi_buffer_size                     128k;
                fastcgi_buffers                         4       256k;
                fastcgi_busy_buffers_size               256k;
                fastcgi_temp_file_write_size            256k;
                fastcgi_intercept_errors                on;
                fastcgi_ignore_client_abort             on;
                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;

I partially can answer since after a day or two of reading

1) APC is still as fragmented as the link to the image above. I will try to get to it and if I figure out what is causing the fragmentation, but the biggest fragmented files are the batcache and apc wordpress plugins.

2) javascript was not getting gzipped because it was sent as application/javascript and I saw that I had two javascripts in my cfg alreeady including text/javascript (which I always thought was javascript by default.

So now everything coming off the server is getting gzimed. So After I added application/javascript to line starting with 'gzip_types' in the first block of code in my question, the javascript began to work.

3) The index.php was not getting rewritten since I didn't have all the nginx rewrite rules for subdomain multisite (there are 3 main ones to get pretty perma-links). However this caused an additional problem to surface for which I will open a new question.

These are the three rewrite lines, and I only had the last one

rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
rewrite ^/(.*)$ /index.php?q=$1 last;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.