Howto nginx + wordpress + ubuntu shortest setup

Please refer to my previous post on how to setup nginx + php5 + mysql on Ubuntu Lucid 10.04 LTS. This tutorial is based on the setup of that tutorial.

First, you need to grab WordPress

$ cd ~/Sites
$ wget http://wordpress.org/latest.zip
$ unzip latest.zip

WordPress package will be extracted to $HOME/Sites/wordpress. Next create a virtual host rule for WordPress:

$ sudo nano /etc/nginx/sites-available/wordpress

Paste following rules into the file:

server{
        listen 80; #or change this to your public IP address eg 1.1.1.1:80
        server_name wordpress; #change this to the domain name, for example www.myblog.com
        access_log /var/log/wordpress.access_log;
        error_log /var/log/wordpress.error_log;

        location / {
          root /home/your-user-name/Sites/wordpress;
          index index.php index.html index.htm;

          # this serves static files that exist without running other rewrite tests
          if (-f $request_filename) {
              expires 30d;
              break;
          }

          # this sends all non-existing file or directory requests to index.php
          if (!-e $request_filename) {
              rewrite ^(.+)$ /index.php?q=$1 last;
          }
        }

        location ~ \.php$ {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME /home/your-user-name/Sites/wordpress$fastcgi_script_name;
            include         fastcgi_params;
        }
}

Make sure you replace ‘your-user-name’ with your home folder user. Now we need to enable this vhost

sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
sudo nano /etc/hosts

Append the ‘wordpress’ into 127.0.0.1 line

127.0.0.1	localhost phpmyadmin wordpress

Now restart the nginx server

sudo service nginx start

Then after you configure your WordPress wp-config.php, WordPress is ready for raw-serve. Fire up your Firefox and type in http://wordpress. Enjoy!

About Jones Lee

Nothing much about me..

24 responses to “Howto nginx + wordpress + ubuntu shortest setup

  1. how to configure wp-config.php ? I still confused …

  2. David

    Do you know how to get the wordpress 3.0 rc autoupdate to work. I’ve tried some of the way I found on the internet but nothing has worked.

  3. Thank you!!!
    Just found a little correction that might help others:
    sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
    cheers!!!

  4. Hi,

    I think your tutorial is outdated. PHP-fastcgi can be replaced with PHP-FPM which has this built in. PHP-FPM is also built in PHP 5.3. I’ve written a tutorial on it too:

    http://tutspundit.com/howto-install-nginx-php-fpm-mysql-php533-wordpress-ubuntu-part-1/

    Regards,
    Pranav

  5. Hi,

    I Tried with multiple virtual servers with nginx and found that all the http://www.wordpress.com were replaced by ip.. and thus not working (as I have multiple virtual servers). I can no longer login, although i can see the blog.
    My site is http://www.frenchoverture.me

  6. Csanch

    I’m with previous commenter. On my install, I get to WP config/install page, I enter details, enter. I get no error page but return to the very same installation page. No fun at all.

  7. tim

    I followed the instructions, but it seems that I’m only getting to phpmyadmin… any ideas?

  8. How to working with nginx cache?

  9. Anybody knows how to handle nginx work with joomla?

  10. For Joomla,

    http://wiki.nginx.org/Joomla

    Then in the Joomla administration, turn on mod_rewrite rules. Nevermind what it says about Apache and .htaccess

  11. Max Williams

    In case anyone else has the problem of getting this error message: “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”, i did a reboot and it was fine after that.

  12. Thx for this!
    My site is running nginx now too

  13. erick

    This is a pathetic configuration, which will work slower than Apache. The “IF” conditions are idiotic.

    I’d recommend you to read the Wiki a little more closely, and there are many resources now (google for them) that show how, in much fewer lines, the WP rules can be set. No need for any rewrite at all.

  14. Pingback: ¿Cómo configurar wordpress en ubuntu con nginx? « Tomas Zulberti

  15. Pingback: Howto: Debian Squeeze+Nginx+WordPress

  16. Pingback: Installation et Configuration de Nginx avec php-fpm | Notes !

  17. Pingback: Setup nginx + wordpress + ubuntu shortest in Ubuntu | TurboLinux Blog

  18. Pingback: Setup nginx + wordpress + ubuntu | Nginx Lighttpd Tutorial

  19. Pingback: Wordpress + Nginx | fabian.lenczewski

  20. Pingback: What issues would you face if you use Nginx | CL-UAT

  21. Pingback: Configuring Routing Rules for WordPress Nginx and WP-SuperCache? | CL-UAT

  22. Pingback: » wordpress:What issues would you face if you use Nginx

Leave a comment