June 29, 2012

Beginner

How To Install Wordpress with nginx on Ubuntu 12.04

Tagged In: Nginx, Ubuntu, Word Press

About Wordpress


Wordpress is a free and open source website and blogging tool that uses php and MySQL. It was created in 2003 and has since then expanded to manage 22% of all the new websites created and has over 20,000 plugins to customize its functionality.

Step One—Prerequisites!


This tutorial covers installing Wordpress. Before you go through it, make sure your server is ready for Wordpress.

You need root privileges (check out steps 3 and 4 for details):
Initial Server Setup

You need to have nginx, MySQL, and PHP-FPM installed on your server:
LEMP tutorial

Only once you have the user and required software should you proceed to install wordpress!

Step Two—Download WordPress


We can download Wordpress straight from their website:
wget http://wordpress.org/latest.tar.gz

This command will download the zipped wordpress package straight to your user's home directory. You can unzip it the the next line:
tar -xzvf latest.tar.gz 

Step Three—Create the WordPress Database and User


After we unzip the wordpress files, they will be in a directory called wordpress in the home directory on the virtual private server.

Now we need to switch gears for a moment and create a new MySQL directory for wordpress.

Go ahead and log into the MySQL Shell:
mysql -u root -p

Login using your MySQL root password, and then we need to create a wordpress database, a user in that database, and give that user a new password. Keep in mind that all MySQL commands must end with semi-colon.

First, let's make the database (I'm calling mine wordpress for simplicity's sake; feel free to give it whatever name you choose):
CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)

Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:
CREATE USER wordpressuser@localhost;
Query OK, 0 rows affected (0.00 sec)

Set the password for your new user:
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");
Query OK, 0 rows affected (0.00 sec)

Finish up by granting all privileges to the new user. Without this command, the wordpress installer will not be able to start up:
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

Then refresh MySQL:
FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Exit out of the MySQL shell:
exit

Step Four—Setup the WordPress Configuration


The first step to is to copy the sample WordPress configuration file, located in the WordPress directory, into a new file which we will edit, creating a new usable WordPress config:
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

Then open the wordpress config:
sudo nano ~/wordpress/wp-config.php

Find the section that contains the field below and substitute in the correct name for your database, username, and password:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');
Save and Exit.

Step Five—Copy the Files


We are almost done uploading Wordpress to the server. We need to create the directory where we will keep the wordpress files:
sudo mkdir -p /var/www

Transfer the unzipped WordPress files to the website's root directory.
sudo cp -r ~/wordpress/* /var/www

We can modify the permissions of /var/www to allow future automatic updating of Wordpress plugins and file editing with SFTP. If these steps aren't taken, you may get a "To perform the requested action, connection information is required" error message when attempting either task.

First, switch in to the web directory:
cd /var/www/

Give ownership of the directory to the nginx user, replacing the "username" with the name of your server user.
sudo chown www-data:www-data * -R 
sudo usermod -a -G www-data username

Step Six—Set Up Nginx Server Blocks


Now we need to set up the WordPress virtual host. Create a new file for the for WordPress host, copying the format from the default configuration:
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/wordpress

Open the WordPress virtual host:
sudo nano /etc/nginx/sites-available/wordpress

The configuration should include the changes below (the details of the changes are under the config information):
server {
        listen   80;


        root /var/www;
        index index.php index.html index.htm;

        server_name 192.34.59.214;

        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
                try_files $uri =404;
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
                 }
        

}
Here are the details of the changes:

  • Change the root to /var/www/

  • Add index.php to the index line.

  • Change the server_name from local host to your domain name or IP address (replace the example.com in the configuration)

  • Change the "try_files $uri $uri/ /index.html;" line to "try_files $uri $uri/ /index.php?q=$uri&$args;" to enable Wordpress Permalinks with nginx

  • Uncomment the correct lines in “location ~ \.php$ {“ section

Save and Exit that file.

Step Seven—Activate the Server Block

Although all the configuration for worpress has been completed, we still need to activate the server block by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress

Additionally, delete the default nginx server block.
sudo rm /etc/nginx/sites-enabled/default

Install php5-mysql:
sudo apt-get install php5-mysql

Then, as always, restart nginx and php-fpm:
sudo service nginx restart
sudo service php5-fpm restart

Step Eight—RESULTS: Access the WordPress Installation


Once that is all done, the wordpress online installation page is up and waiting for you:

Access the page by visiting your site's domain or IP address (eg. example.com/wp-admin/install.php) and fill out the short online form (it should look like this).

See More


Once Wordpress is installed, you have a strong base for building your site.

If you want to encrypt the information on your site, you can Install an SSL Certificate



By Etel Sverdlov

Share this Tutorial

Vote on Hacker News

Try this tutorial on an SSD cloud server.

Includes 512MB RAM, 20GB SSD Disk, and 1TB Transfer for $5/mo! Learn more

Create an account or login:

245 Comments

Write Tutorial
  • Gravatar zhangwl87 over 1 year

    Hi, I followed all steps, but when i do sudo service nginx restart, warn conflicting server name xxx.xxx.xx.xx on 0.0.0.0:80 ignored nginx. I am not able to access wordpress by keying in IP address on my browser. Any ideas?

  • Gravatar Moisey over 1 year

    This is because you have two server {} blocks that are both listening on the same IP and port. In your case I'm guessing its either 0.0.0.0 and port 80 or you used the same servername twice which was your public facing IP. If you remove one server block it will work. Or if you want both active make sure they have different servernames and/or different ports.

  • Gravatar nick over 1 year

    After following these steps, I see "unable to connect to database" when viewing my WordPress site index. Could this be a permissions issue? (I installed WordPress not as root but as another super user.)

  • Gravatar Moisey over 1 year

    The error unable to connect to database indicates that a connection can not be established to the MySQL server which means it has not yet even had a chance to check if the provided credentials, user, pass, and db are valid. The most common causes of this error are that MySQL is in fact not running, or there is a misconfiguration between the IP address you provided to wordpress to connect to and what IP/port MySQL is actually listening on. By default MySQL will listen on all IPs and port 3306 so connecting to localhost and the default port in the wordpress configuration should be enough. You can check to see if MySQL is runnning by either doing: # ps auxw | grep -i mysql Or # telnet localhost 3306 The telnet command will attempt to connect to the IP and port that MySQL should be listening on. If the connection is established then its working, if it doesn't then MySQL is most likely not started.

  • Gravatar nick over 1 year

    Thanks, raiyu. That's been very helpful. I've rebooted the server and all's well now. Very impressed with Digital Ocean and will be signing up. I also had to tweak the permissions of /var/www in order to get WordPress automatic updates and plugin installs to work, using this line: sudo chown -R www-data:www-data /var/www Secondly, I've made this change to allow editing of files directly via SFTP if required: sudo usermod -a -G www-data myusername sudo chmod -R g+rw /var/www Are these worthwhile additions to the tutorial, or are there likely to be any problems caused by these changes?

  • Gravatar Moisey over 1 year

    Both changes are more or less ok, in terms of security you want to avoid having too many directories that are writeable by the user that the web server runs as because wordpress has had exploits in the past which would allow users to upload files directly to your system. Keeping wordpress running on the latest version avoids the majority of those issues, however it is still something to keep in mind. I'm going to have Etel run through this tutorial and see about getting the specified changes added to allow for automatic updates and plugin installs - its a good suggestion and should be noted. We do go back through the tutorials as we get comments on them to make updates, so keep them coming! Thanks

  • Gravatar nick over 1 year

    The only other tweak I'd suggest is to change this line in the location{} block of the virtual host file: try_files $uri $uri/ /index.html; to this instead, which enables WordPress' pretty permalinks under Nginx: try_files $uri $uri/ /index.php?q=$uri&$args; You then just need to set the Permalink Settings in the WordPress dashboard to use the "Custom Structure" (the last option), with the relevant tags, for example: /%postname%/

  • Gravatar Etel over 1 year

    Thank you for the suggestion! The configuration has been changed to facilitate Permalinks. :)

  • Gravatar Daniel over 1 year

    At Step Six i have this error: Sudo: In: command not found

  • Gravatar Etel Sverdlov over 1 year

    Is it possible that you typed in In with "i" as the first letter of the command? The command is actually ln with "L" as the first letter. Let me know if the issue continues.

  • Gravatar Daniel over 1 year

    Thank you Etel. That solution solved the problem (me). One sugestion: i've got the same error as zhangwl87 reported. The solution was remove the default nginx configuration because nginx detects two configs with the same domain name.

  • Gravatar Etel Sverdlov over 1 year

    Thanks for the update! I'm glad that resolved the issue. I went ahead and added a step to the tutorial to delete the default server block which conflicted with the wordpress one.

  • Gravatar oasis.mk over 1 year

    Very nice tutorial. But after going through all the steps mentioned, when I go to 'localhost/wordpress' the error i get is "File Not Found". Please help!

  • Gravatar Moisey over 1 year

    You should be running it from a public IP/domain to make it accessible on the internet. Localhost is a definition which allows a computer or server to access itself for testing. If you are still having issues you can paste us the servername line from your nginx config.

  • Gravatar saad.18 over 1 year

    I did everything thats written here but I am getting this error Your PHP installation appears to be missing the MySQL extension which is required by WordPress. any suggestions please

  • Gravatar Moisey over 1 year

    That error means that your PHP was installed without mysql support so you want to do: apt-get install php5-mysql

  • Gravatar lestaby over 1 year

    Thanks for a great guide. Just a question regarding step 4, sudo usermod -a -G www-data username Should the username not be in the sudoer list. Thanks again

  • Gravatar Etel Sverdlov over 1 year

    No— that user does not need to be in the sudoers file as they will not be running any sudo commands.

  • Gravatar casias.adge over 1 year

    Hello, thank you for the information it was very helpful.... I do have one issue I was hoping someone could help me with. When I go to my domain I am getting... ); Any suggestions would be greatly appreciated....

  • Gravatar casias.adge over 1 year

    Front to the wordpress application. This file doesn't do anything but loads wp-blog-head.php which does and tells wordpress to load the theme. Sorry tried to copy and paste up there, didnt work.

  • Gravatar Etel Sverdlov over 1 year

    What is the error that you are getting? Perhaps it may be easier to show it through a screenshot.

  • Gravatar casias.adge over 1 year

    Error: PHP is not running Wordpress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.

  • Gravatar Etel Sverdlov over 1 year

    Make sure that your server block configuration file matches the one in the tutorial. I would imagine the most issues would arise with an error there. Additionally, take care that you followed all of the steps in the preliminary LEMP tutorial here: https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04

  • Gravatar casias.adge over 1 year

    Ok, I'll check out my server block configuration file. I definitely followed all the steps in the LEMP tutorial. Thank You.

  • Gravatar casias.adge over 1 year

    I was able to fix my server block config file, and I installed WordPress. I also used your tutorial to setup Nginx as a front end web server and apache at the back end, all went well. I can now get to my domain.com/wp-admin page but if I try to access just my domain.com I get an error from FireFox: "The page isn't redirecting properly. Firefox has detected that server is redirecting the request for this address in a way that will never complete." Any insight to this?

  • Gravatar Moisey over 1 year

    Wordpress works by redirecting all requests back to domain.com/index.php which does all of the processing of the homepage and blogs that you write. It sounds like there is a misconfig there. Are you running wordpress straight through nginx or you also using a reverse proxy back to Apache? Also if you paste your server { } and/or VirtualHost configs we could see if there's anything that may be causing an issue there.

  • Gravatar casias.adge over 1 year

    Sorry tried copying and pasting my config and puts an unhappy smily face lol Let me try a screenshot instead...

  • Gravatar casias.adge over 1 year

    php Front to the WordPress application. This file doesn't do anything, but loads wp-blog-header.php which does and tells WordPress to load the theme. @package WordPress Tells WordPress to load the WordPress theme and output it. @var bool define('WP_USE_THEMES', true); Loads the WordPress Environment and Template require('./wp-blog-header.php');

  • Gravatar casias.adge over 1 year

    This is my virtual host config file for nginx.... server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /var/www/; #the root is changed to the website directory. #Be sure to replace this with the appropriate extension. index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name sniffyourkid.com; #change the server name to reflect yours location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.php?q=$uri&$args; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } location ~ \.php$ { #this block is responsible for processing php requests #these lines pass on the IP address of the site visitors to the backend server proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; #this line changes the default configuration which usually doesn’t usually #forward host header information proxy_set_header Host $host; #this command lets nginx the address of the proxied server. proxy_pass http://127.0.0.1:8080; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }

  • Gravatar Etel Sverdlov over 1 year

    We've cleaned up that article and configuration yesterday (https://www.digitalocean.com/community/articles/how-to-configure-nginx-as-a-front-end-proxy-for-apache). I would recommend using the new version that we have up. In the meantime, open up a ticket with us and we'll take a look at the error. Thank you.

  • Gravatar casias.adge over 1 year

    ok thank you.

  • Gravatar Waleed A over 1 year

    Hey, I followed Step 4 but when I try to add a plugin/theme in wordpress it always asks for my FTP information. I proceed to enter the information I use to login in to SSH and it does not work. Any ideas ?

  • Gravatar info over 1 year

    When I visit my sites IP in the browser I am downloading the index.php instead of seeing it. Any ideas where I went wrong?

  • Gravatar Moisey over 1 year

    In regards to the FTP issue make sure that you are using a user other than root as root is usually restricted from logging in. Also make sure that the user you are logging in as has permissions to write to the directory where plugins and themes are stored and that the user is allowed to navigate to that directory. Alternatively you can upload themes directly through the web but you will need to set the plugins directory to permissions of 777 and then return them back to 755 after you have installed your themes and plugins as a security precaution. As for the issue with downloading the index.php that happens because PHP isn't being parsed/executed and instead it's being treated as a regular file. Since it isn't mime-typed to be interpreted anyway by the browser it ends up being downloaded so that would indicate an issue with the configuration/setup. In the above example fastcgi is used to parse PHP so you have to make sure that is install and processing in order to render PHP scripts. We are going to update the documentation for that to make it clearer.

  • Gravatar Moisey over 1 year

    We setup the LEMP stack in another tutorial which would gets fastcgi setup to process your PHP files: https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04 Run through that first then this tutorial on installing and configuring wordpress for LEMP and you should be good to go.

  • Gravatar Waleed A over 1 year

    I was using another user to log in and I also tried chmod to 777 but didn't work.

  • Gravatar Etel Sverdlov over 1 year

    You can try granting permissions to the nginx user: From within the web directory, run the following commands, replacing username with the name of your specific user: sudo chown * -R www-data:www-data sudo usermod -a -G www-data

  • Gravatar Waleed A over 1 year

    what part of that should i replace with my username?

  • Gravatar Waleed A over 1 year

    Im getting "cannot access `www-data:www-data': No such file or directory" after i type in the first command

  • Gravatar Etel Sverdlov over 1 year

    There was a typo in the command that I have now corrected. The username in the command should be replaced with the user that you are logged in as.

  • Gravatar Waleed A over 1 year

    OK I got it working. Quick question, when I type in "sudo chown www-data:www-data * -R " it says cannot access '*': No such file or directory

  • Gravatar Etel Sverdlov over 1 year

    It's because of the order of the steps above. The directory was empty when you ran that command (because the step to copy the files came after); with the steps rearranged the command should complete without issue.

  • Gravatar Naushad Shaikh about 1 year

    I was getting 403 Forbidden at the IP address after i followed the steps. When i thought that default dir /var/www doesnt have an index file, i changed the root to "root /var/www/wordpress;". But still the same issue.

  • Gravatar Moisey about 1 year

    A 403 forbidden usually indicates a permissions problem so check the ownership of your /var/www and /var/www/wordpress directories to ensure that the user as which you have setup your nginx to run has access to read those directories.

  • Gravatar hoopaleo about 1 year

    "Your PHP installation appears to be missing the MySQL extension which is required by WordPress." At the end of the tutorial I have the same problem as 'saad.18' above. I tried the suggestion from 'raiyu'. "That error means that your PHP was installed without mysql support so you want to do: apt-get install php5-mysql" (I tried running this code on a clean LEMP and after the installation of wordpress tutorial.) What's next? :)

  • Gravatar Moisey about 1 year

    Thats correct you need to get php5-mysql installed as wel, after you did that did you get any new errors?

  • Gravatar hoopaleo about 1 year

    Okay! Last night I installed php5-mysql and after it still had the error. Although I looked at it today and it works. It must have taken a little time for some of the changes to come through. Cheers

  • Gravatar Moisey about 1 year

    After you install php5-mysql you will need to restart nginx, that's probably the step you were missing.

  • Gravatar vikrant about 1 year

    CAN'T select database ERROR : I'm getting the following message on the wp-admin/install.php page : We were able to connect to the database server (which means your username and password is okay) but not able to select the wordpress database. Are you sure it exists? Does the user wordpressuser have permission to use the wordpress database? On some systems the name of your database is prefixed with your username, so it would be like username_wordpress. Could that be the problem?

  • Gravatar Moisey about 1 year

    Looks like an issue with granting permissions to the MySQL user to access the DB that was setup for wordpress. Rerun this line in the MySQL command line and be sure to update it for your wordpress DB, wordpress User, and set a strong password, then try to connect: # GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password'; Also you can test MySQL access by doing the following: > mysql -u wordpressuser -p Enter your password and if it connects that means your User and Pass are in the MySQL DB. Then try to switch to using your wordpress DB: > use wordpress_database; If it connects then you are all set, if it doesn't that means you grant statement above had an issue.

  • Gravatar raphaelsuzuki about 1 year

    This line is useless to edit files with your normal user inside 'wp-content' (the directory you'll probably edit the most) through SFTP: $ sudo usermod -a -G www-data username Since it ships by default blocking read/write to group. You'll need to do at least: sudo chmod -R g+rw /var/www/site.com/public_html/wp-content In order to able to edit this directory.

  • Gravatar desiredpersona about 1 year

    Thanks Raphael :-)

  • Gravatar raphaelsuzuki about 1 year

    Hey, can't we edit our own messages? I hate went I make typos and other errors. :/

  • Gravatar rob about 1 year

    step 7 - neeeded a sudo service php5-fpm restart for me before it would work.

  • Gravatar babu.srinivasan about 1 year

    I want to move my existing wordpress blog to DigitalOcean but want to use nginx+wordpress not apache. I already have nginx and php5-fpm setup at DO and am using it for serving static pages and php photo gallery. Can you update the instructions for installing wordpress with backup of sql database from existing wordpress install?Or let me know if this info is already present in a separate article. Thanks.

  • Gravatar bojan.cincur about 1 year

    Just to add, after you install php-mysql you need to restart php5-fpm and nginx services: sudo service php5-fpm restart this will solve problems with: "Your PHP installation appears to be missing the MySQL extension which is required by WordPress."

  • Gravatar local8 about 1 year

    I changed my permalinks after this in wordpress and set them back and now index.php is in all my urls, can you me set it back?

  • Gravatar michael about 1 year

    Every time I complete this tutorial set Wordpress prompts me to enter FTP information inorder to install plugins. What is the best way to give Wordpress permissions to access its directory (so it can add/update plugins + core files) without configuring an FTP server?

  • Gravatar synergywp about 1 year

    Hello, if anyone is still reading this.. I did this tut exactly as it was explained, yet I am getting an "Error establishing database connection" I know this happens usually when the wp-config.php file doesn't have the proper info, but i've tried over and over again, creating different users, etc, but nothing works. Any ideas? Thanks.

  • Gravatar ozan 12 months

    I cant add any plugin or theme. upload or web install mode didnt work. Redirect me to ftp login but it didnt work because sftp not a option (error: Failed to connect to FTP Server 198.199.xx.xxx:21 ) Could you please help me ?

  • Gravatar eticonleong 12 months

    Followed all the steps but when go to final set to setup wordpress http://198.199.104.247/wp-admin/install.php I'm getting the following error on browser. "The page you are looking for is temporarily unavailable. Please try again later. " Not sure what is going wrong. Any idea?

  • Gravatar Matt 11 months

    @eticonleong -- i too get same error. http://198.199.87.220/info.php http://198.199.87.220/wp-admin/install.php It must be an error on Digital Ocean for I have done this three times, each time without one single error.

  • Gravatar Matt 11 months

    **status update** I created a second droplet (which generated a second IP) Started from begin to end, had zero errors. WP + Ngix + Ubuntu 12.10 x64 Server Tricky stuff dude... Onwards to setting up Varnish + DNS (change from IP to Domain) + WP Multisite check this link for DNS = https://www.digitalocean.com/community/articles/how-to-set-up-a-host-name-with-digitalocean

  • Gravatar fanlinsheng 11 months

    hi, i request my ip *.*.*.*, it says that 502 bad gate way, how can I find errors?

  • Gravatar Kamal Nasser 11 months

    @fanlinsheng it means php5-fpm is down. Make sure it's running and check the error logs in /var/log.

  • Gravatar jtbowlin 11 months

    I have the same "The page is temporarily unavailable...". I checked the logs and it says php5-fpm is running. I've restarted it and it still says it's running. Not reporting any errors of any kind. Quite confused... [26-May-2013 14:34:32] NOTICE: fpm is running, pid 26302 [26-May-2013 14:34:32] NOTICE: ready to handle connections

  • Gravatar Kamal Nasser 11 months

    @jtbowlin check nginx's error logs in /var/log/nginx - what are the last few lines?

  • Gravatar jtbowlin 11 months

    @Kamal - It says the following quite a few times, with different * numbers (like below is *4)...: [crit] 3067#0: *4 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 81.99.233.5, server: 198.199.89.126, request: "GET $ "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "198.199.89.126" I've noticed this is affecting all php pages, not just the wordpress one. I also just re-installed and tried the test info.php from the "How to Install Linux, nginx, MySQl..." guide and got the same error message.

  • Gravatar jtbowlin 11 months

    Fixed It. Fixed it.. the key is a tiny change in /etc/nginx/sites-available/default location ~ \.php$ { #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; change to: location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; # With php5-fpm: #fastcgi_pass unix:/var/run/php5-fpm.sock; which is just swapping which line has the # in front of it. This changes it from socket to IP. I don't know quite what that means as I'm a beginner, but it worked. :-)

  • Gravatar Kamal Nasser 11 months

    @jtbowlin php5-fpm is listening on port 9000, you can edit the config to listen on a socket. Both are fine and work well :] Glad you've been able to fix it.

  • Gravatar andre 11 months

    Hi there! Thanks for the Guide! There is just one problem...I can't add any photos, plugins or themes with an upload. Adding plugins from wordpress.org directrly is fine, but no other interaction on my part to add things is working. I tried set the permissions to 777 and nothing happened different. Thank you in advance!

  • Gravatar Kamal Nasser 11 months

    @andre did you follow Step Five (specifically the "Give ownership of the directory to the nginx user, replacing the "username" with the name of your server user." part)?

  • Gravatar andre 10 months

    Hi @Kamal , I did! For some weird reason I was able to upload files a while ago, but now I'm stuck, I tried many things, even start a new droplet to test this tutorial again and still nothing. That's the funny thing, I was able to upload files in the first place. I have the site with 50 + images and many plugins. But all of a sudden it stoped working. First it gave me an weird error, but after updating php to 5.4 with this guide ( http://rtcamp.com/wordpress-nginx/tutorials/ubuntu-php-apc-mysql-postfix/ ) I got it working again. But now I can't manage to upload files, even in the new droplet that I build to test this hole tutorial again. Any chance you know what's happening? Thank you!!!

  • Gravatar andre 10 months

    @Kamal , another thing. I also can't update posts nor add new ones.

  • Gravatar Kamal Nasser 10 months

    @andre: do you see any errors? Check the error logs in /var/log/nginx/error.log and /var/log/php5-fpm.log Also make sure MySQL is running and that the user you're using for wordpress has the proper permissions.

  • Gravatar patrick.alan 10 months

    Hi, I followed all the steps here and then when I load up my root url, I still get the "Welcome to nginx!" message instead of the wordpress site. All of my wordpress files are in /var/www/ and there is no wordpress folder there, and yet, if i go to myip/wordpress/ there's my wordpress site. The files are in my root web dir, so I'm confused why my root url isn't showing my wordpress installation. Thanks for any help! Alan

  • Gravatar patrick.alan 10 months

    Nevermind.. Fixed!

  • Gravatar dan_paul 10 months

    I had some issues getting this to work with passenger. I used some information from this tutorial to get things working: http://leepowers.net/ruby-rails-nginx-and-php-ubuntu-1204-lts-server I believe the configuration detail that needed to be changed was to add the following line to the nginx conf. file server block: passenger_enabled off; Also, I needed to install the php/mysql module: apt-get install php5-mysql libmysqld-dev

  • Gravatar ceo 10 months

    Well, following these instructions hosed my web server. These instructions are for 12.04, NOT 13.04. 13.04 uses the "html" directory not the "www" directory. Not sure where I screwed up. I am now getting the following in my NGINX log file: 2013/06/26 01:19:22 [error] 1285#0: *8 FastCGI sent in stderr: "Unable to open primary script: /var/html/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.133.1, server: 192.168.133.200, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "192.168.133.200"

  • Gravatar Kamal Nasser 10 months

    @ceo Does /var/html exist? "ls /var/html"

  • Gravatar ceo 10 months

    Hi Kamal, No, /var/html does not exist

  • Gravatar Kamal Nasser 10 months

    @ceo You have /var/html in your nginx config - I believe you're supposed to use /var/www and not /var/html.

  • Gravatar ceo 10 months

    Thanks Kamal. I will make the changes suggested here and here :https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04....My point is that the designers of 13.04 will be expecting the html directory in the future (or not)? Also are you on FB or G+?

  • Gravatar Kamal Nasser 10 months

    @ceo I believe /var/www is going to stick there for a while - as for the update in https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04, it meant that in Ubuntu 13.04+ /usr/share/nginx/www will be replaced by /usr/share/nginx/html

  • Gravatar ceo 10 months

    So then WHICH instructions do I follow? I am running 13.04 Server.

  • Gravatar Kamal Nasser 10 months

    @ceo: You can follow this article - it'll work perfectly on Ubuntu 12.04+.

  • Gravatar jifenkui 10 months

    I get the same problem as alan said " patrick.alan Hi, I followed all the steps here and then when I load up my root url, I still get the "Welcome to nginx!" message instead of the wordpress site. All of my wordpress files are in /var/www/ and there is no wordpress folder there, and yet, if i go to myip/wordpress/ there's my wordpress site. The files are in my root web dir, so I'm confused why my root url isn't showing my wordpress installation. Thanks for any help! Alan" But he didn't give the method. So how can I fix this?! Thanks very much!

  • Gravatar Kamal Nasser 10 months

    @jifenkui please pastebin your virtualhost config and the output of "ls /var/www"

  • Gravatar jifenkui 10 months

    server { listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default ipv6only=on; ## listen for ipv6 root /usr/share/nginx/www; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name 50.116.56.22; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.php?q=$uri&$args; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } # Only for nginx-naxsi : process denied requests #location /RequestDenied { # For example, return an error code #return 418; #} error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { #fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone: #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } ls /usr/share/nginx/www/ 50x.html wp-activate.php wp-content wp-mail.php index.html wp-admin wp-cron.php wp-settings.php index.php wp-blog-header.php wp-includes wp-signup.php info.php wp-comments-post.php wp-links-opml.php wp-trackback.php license.txt wp-config.php wp-load.php xmlrpc.php readme.html wp-config-sample.php wp-login.php Thanks

  • Gravatar jifenkui 10 months

    Works after deleted index.html, but now both http://IP/ and http://IP/wordpress/ display my homepage.

  • Gravatar Kamal Nasser 10 months

    @jifenkui: Please follow what this article says as it would be a cleaner way to get Wordpress set up.

  • Gravatar maina.gidi 10 months

    Very good keep it up !

  • Gravatar raffi jamgotchian 10 months

    I had this working yesterday with 13.x but I went back and re-did it using 12.04 when I hosed something up (trying to restore an existing wordpress site that was built on LAMP on a VPS to a new ubuntu server and LEMP). But I'm getting this: 2013/07/02 16:07:58 [crit] 5120#0: *2 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: xx.xx.xx.xx, server: xx.xx.net, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xx.xx.net"

  • Gravatar Kamal Nasser 10 months

    @raffi: Is php5-fpm running? "service php5-fpm restart"

  • Gravatar raffi jamgotchian 10 months

    I figured it out. I had a typo in one of the earlier configs.

  • Gravatar Brad Griffin 10 months

    @Matt (or anyone else) can someone shoot me an email at [email protected] to see what I can do about getting this set up, done one, finished, moved on, ..... I've been trying for a month now ...with no success. ...and I'm tired of messing it up! I'd like to ask someone who has done this successfully if we can do a video tutorial of this using join.me and/or screenr.com I'll volunteer my actual account (hell, it's only $5) to use for the tutorial. I'm sick and tired of being sick and tired. I do NOT want someone doing this for me. HOWEVER, I would like ONE simple, clean, set of instructions to follow. That do not assume I've done this before. Anyone want to join in on the fun?!?! Let's make one definitive, specific, tutorial that will make this work! [email protected]

  • Gravatar Brad Griffin 10 months

    In step 5, when it says: Give ownership of the directory to the nginx user, replacing the "username" with the name of your server user. sudo chown www-data:www-data * -R sudo usermod -a -G www-data username Is the 'username' referring to the "alternative root user" we created in step 3 of this article? https://www.digitalocean.com/community/articles/initial-server-setup-with-ubuntu-12-04

  • Gravatar Brad Griffin 10 months

    I got the info.php up correctly, but when I go to http://198.199.111.221/wp-admin/install.php it simply says, "Access Denied" ...and now I don't even know where to look to find the problem.

  • Gravatar Brad Griffin 10 months

    Dead Gummit!!! Now I get a "file not found" for the ipa.ddr.ess.123/info.php!!! This is NUTS!!! I hate following directions and not getting results.

  • Gravatar Kamal Nasser 10 months

    @Brad please pastebin your nginx virtualhost config file

  • Gravatar dbendt 9 months

    Having a similar issue following these instructions. Site appeared to install properly, but now the static assets aren't appearing properly. Here is my conf file: https://gist.github.com/anonymous/6006528

  • Gravatar Kamal Nasser 9 months

    @dbendt: Check nginx's error logs, do you see any errors?

  • Gravatar dbendt 9 months

    No errors in the access log. Looks like the static files are 301 redirecting for some reason.

  • Gravatar Kamal Nasser 9 months

    I'm not sure if this is what's causing it, but try replacing try_files $uri $uri/ /index.php?q=$uri&$args; with try_files $uri $uri/ /blog/index.php$is_args$args;

  • Gravatar joelmblain 9 months

    Ok I have done this before but now its not working. I'm getting a server not found error when I go to my ip. Here's my nginx.conf file user www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/x-javascript text/xml application/x$ ## # nginx-naxsi config Here's my server config file You may add here your server {# ... # } # statements for each of your virtual hosts to this file ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /var/www; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name MYIP; } location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.php?q=$uri&$arges; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } # Only for nginx-naxsi : process denied requests #location /RequestDenied { # For example, return an error code #return 418; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # root html; # index index.html index.htm; # # location / { # try_files $uri $uri/ /index.html; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # # root html; # index index.html index.htm; # # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # # ssl_session_timeout 5m; # # ssl_protocols SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP; # ssl_prefer_server_ciphers on; # # location / { # try_files $uri $uri/ /index.html; # } #}

  • Gravatar joelmblain 9 months

    I'm not getting any error on an nginx restart either. Here's my error log 2013/07/31 17:50:07 [error] 12192#0: *2 directory index of "/usr/share/nginx/www/wordpress/" is forbidden$ 2013/07/31 17:50:19 [error] 12192#0: *2 directory index of "/usr/share/nginx/www/wordpress/" is forbidden$ 2013/07/31 17:50:20 [error] 12192#0: *2 directory index of "/usr/share/nginx/www/wordpress/" is forbidden$ 2013/07/31 18:36:24 [emerg] 12756#0: "location" directive is not allowed here in /etc/nginx/sites-enabled$ 2013/07/31 18:36:24 [emerg] 12757#0: "location" directive is not allowed here in /etc/nginx/sites-enabled$ 2013/07/31 18:40:45 [emerg] 12802#0: "location" directive is not allowed here in /etc/nginx/sites-enabled$ 2013/07/31 18:40:45 [emerg] 12803#0: "location" directive is not allowed here in /etc/nginx/sites-enabled$

  • Gravatar joelmblain 9 months

    I fixed the location directive, because nginx was outputing an error on restart but now i get the wordpress error.

  • Gravatar Kamal Nasser 9 months

    @joelmblain: Can you please paste your nginx.conf file on http://p.kk7.me? Thanks!

  • Gravatar johnb2b 9 months

    hi all..new buddy here, first of all Digital Ocean..you rock! with nginx +ssd my worpress site goes faast! Im totally new to linux self hosting and so i'm naturally struggling with some issues. Here is one: I log in through filezzilla ftp and upload a theme to wp-content/themes..its shows in the server var/www/wp-content/themes but WP does not see anything. Moreover if i upload from WP GUI, it show in WP ok but I can't find in the server! I followed instructions is it possible to have 2 different directories in WP? i really don't know what going on..any help much appreciated

  • Gravatar johnb2b 9 months

    ok I just found it..in my root directory home/user/ i have a directory /www/..its from there that actual WP reads and works..instead of var/www/..how did i end up with this by following instructions..and which is the correct directory to run my wordpress site? and why..the ftp filezilla with proftp go to the latter directory instead of showing also the first. Thanks for your help and sorry it it is all too basic but im a total noob with linux command line :)

  • Gravatar Kamal Nasser 9 months

    Did you follow this article on installing wordpress? If so, did you copy the commands carefully?

  • Gravatar nguyentien.jobs 8 months

    Dear raiyu, Sometime, mysql on my server is down and I got "Error establishing a database connection" error. After power cycle the server, every work well again. Don't know why, but I met this problem two times today. Hope you can help. Thank you.

  • Gravatar Kamal Nasser 8 months

    @nguyentien.jobs: Your droplet might be running out of memory. Try checking mysql's error logs -- what do you see?

    tail /var/log/mysql.err

  • Gravatar nguyentien.jobs 8 months

    Dear Kamal Nasser, The file is blank now. Have any other way to check. Thank you, Tien

  • Gravatar Kamal Nasser 8 months

    @nguyentien.jobs: Try adding swap to your droplet: https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04

  • Gravatar nguyentien.jobs 8 months

    OK @Kamal Nasser. I will install swap and let you know when finish. But I think problem is not from RAM. I checked by command "top" from console. BR.

  • Gravatar nguyentien.jobs 8 months

    @Kamal Nasser I added Swap. Below is log: Last login: Tue Aug 27 17:17:05 2013 from 115.79.200.165 root@blogger:~# sudo swapon -s Filename Type Size Used Priority root@blogger:~# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/vda 20642428 1974084 17619768 11% / udev 247832 4 247828 1% /dev tmpfs 100648 220 100428 1% /run none 5120 0 5120 0% /run/lock none 251620 0 251620 0% /run/shm none 102400 0 102400 0% /run/user root@blogger:~# sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k 524288+0 records in 524288+0 records out 536870912 bytes (537 MB) copied, 3.6579 s, 147 MB/s root@blogger:~# sudo mkswap /swapfile Setting up swapspace version 1, size = 524284 KiB no label, UUID=9b8d5c72-f5df-444b-847d-ad92156ceb88 root@blogger:~# sudo swapon /swapfile root@blogger:~# swapon -s Filename Type Size Used Priority /swapfile file 524284 0 -1 root@blogger:~# sudo nano /etc/fstab root@blogger:~# sudo chown root:root /swapfile root@blogger:~# sudo chmod 0600 /swapfile root@blogger:~# Then what next step dear? BR

  • Gravatar Kamal Nasser 8 months

    @nguyentien.jobs: Now that you've added swap, leave your droplet as is for a while and see if MySQL still crashes.

  • Gravatar nguyentien.jobs 8 months

    Dear Kamal Nasser. After added swap, I waited some mins, then power cycle server, first time can access but when click to wp-admin, it's crashed again.. So I resized droplet to 1024MB RAM, and seem it's working now, but not sure no problem in future. After increase RAM size, do I need to reconfig Swap? Thank you very much. Tien

  • Gravatar Kamal Nasser 8 months

    @nguyentien.jobs: Why did you power cycle your server? You shouldn't press that button unless it's not responding and you have to power cycle it. You should reboot your droplet from the command line by running

    sudo reboot
    instead. If you get that much visitors that your droplet starts crashing, you certainly need to upgrade your droplet to the next level as swap won't solve all the issues.

  • Gravatar amm892 7 months

    I follow your wonderful tutorials, initial setup, LEMP setup, and so i didnt need this "Install php5-mysql: sudo apt-get install php5-mysql" bit. I already have its latest version installed just fine

  • Gravatar ge3k- 7 months

    Hello, Very good article, every things works well, but there issue when i Enable Permalink in my wordperss the links show '/index.php/' like : http://ip/index.php/hello-world/ , also in Dashboard show /index.php/ (see: http://i.imgur.com/d5xvvnO.png ) i try to fix to by remove '/index.php/' from '/index.php/%postname%/' then works well, but i don't know how it come. also is there way to remove it from my dashboard ? Thank you

  • Gravatar Kamal Nasser 7 months

    @ge3k-: Try installing this plugin: http://wordpress.org/plugins/nginx-helper/

  • Gravatar ge3k- 7 months

    Kamal, Thank you works well,

  • Gravatar Kamal Nasser 7 months

    @ge3k-: Sweet!

  • Gravatar gee2711 7 months

    Thanks for the cool tut. I want to remove the index.php from my permalinks, Ive searched and found a wordpress plugin called nginx. Not sure if this will help me as I have varnish cache on too. Anyone found any solutions?

  • Gravatar Kamal Nasser 7 months

    @gee2711: Try installing the nginx-helper plugin I linked above. I'm pretty sure it should work fine.

  • Gravatar leo 6 months

    Thx for the intro. I tried to installed it according to the above steps but somehow fail with 'File not found' resp. 'FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.1.3, server: , request: "GET /wp-admin/install.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "192.168.1.175" I pasted the config in http://pastebin.com/a4HC0Mx1 which has an additional config with my second web-app. I tested it and the proper settings are retrieved from the wp-dir. The debug-log from nginx I pasted as well http://pastebin.com/pBsADUsb. Any ideas what to check? Rem.: Creating a link on the root with /wp-admin/ didn't change either the result.

  • Gravatar Kamal Nasser 6 months

    @leo: Add root /path/to/your/website/files; right after listen *:80; and restart nginx.

  • Gravatar leo 6 months

    I tried like this, but without luck. First of all I would have assumed, that `alias` and `root` are similar/equal in usage. But to cut out possibilities I tried like you mentioned (Q: Does it matter if is `listen *:80` or just `listen 80`? cause in your above sample ...) Anyway, I pasted once more my current config in http://pastebin.com/L0uR7QZ4 the debug-logs in http://pastebin.com/pWf1ZaaM What I tried additionally? I traced as well with strace and the result gives me headache (http://pastebin.com/3ky8hdCW), namely there seems to be some conflict with socket-binding. I would have expected that everything would be handled smoothly under the hood. Any idea what to check additionally?

  • Gravatar leo 6 months

    After endless testing I found a solution. I guess this is mainly that I unpacked everything under root, linked the wordpress-dir to the structure I mentioned. But somehow there was no read-access to the files and moving around and assigning a new user solved finally the problem. I didn't track down, what the real source of the problem is/was, but I'm happy for the very moment. So, my only question left: In the command usermod -a -G www-data username you have a username. Are there any advices to have a consitent setup? e.g. create an own user accessing for the nginx-structure? Or does this make to much mess? But then how to maintain on the long run different users for differents aps? etc. A hint resp. some words from your experience would be great.

  • Gravatar Chris Black 6 months

    The last location block of: ~~~~ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9$ location ~ \.php$ { #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } ~~~~ This should be changed to include `try_files $uri =404;` This closes a pretty big security hole: http://forum.nginx.org/read.php?2,88845,page=3 To close it make the block look like: ~~~~ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9$ location ~ \.php$ { try_files $uri =404; #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } ~~~~

  • Gravatar Chris Black 6 months

    D'oh. Ignore all the ~~~~'s. I thought we could use Markdown in our comments. :)

  • Gravatar alex 6 months

    "Give ownership of the directory to the nginx user, replacing the "username" with the name of your server user. sudo chown www-data:www-data * -R sudo usermod -a -G www-data username" what should 'username' be if I have not changed anything? nginx? root?

  • Gravatar alex 6 months

    Also with the above configuration in the nginx config, I get sitename.com/index.php/hello-world/ instead of sitename.com/hello-world server { listen 80; listen [::]:80 default_server ipv6only=on; root /var/www/sitename.com/; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name emeastudio.co.uk; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.php?q=$uri&$args; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location ~ \.php$ { #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }

  • Gravatar Kamal Nasser 6 months

    @Chris: Thanks. I've updated the article.

  • Gravatar Kamal Nasser 6 months

    @alex: username should be the user you created in the initial setup of your droplet: https://www.digitalocean.com/community/articles/initial-server-setup-with-ubuntu-12-04 Also see: http://codex.wordpress.org/Nginx#URL_Rewrites_.2F_Permalinks

  • Gravatar iainelder 6 months

    I agree with alex and an Waleed A: Step 5 could be clearer. When I read this: """ Give ownership of the directory to the nginx user, replacing the "username" with the name of your server user. """ I thought: "What is my server user? nginx? www-data?" I had to read through the comments to find that it means my user (iain). I don't call my user a "server user", that's why I got confused. Perhaps this would be best spelled out by example: """ If you use the server as bob, the you would use the command "sudo usermod -a -G www-data bob". """ Or you could modify the command to let Linux work it out for us: sudo usermod -a -G www-data $(whoami) where $(whoami) resolves to my username, whatever it happens to be.

  • Gravatar Juan Diego Gonzales 6 months

    Hi, I can't get the pretty permalinks to work. I'm stuck. This is my site http://162.243.131.104/wordpress/, this is the /etc/nginx/sites-avaible/wordpress file http://pastebin.com/raw.php?i=BSnQBBvF and this is a screenshot showing the permalinks config https://www.dropbox.com/s/83kjr4ijhe6g8pq/Screenshot%202013-10-17%2000.03.54.png Thanks for the tutorial btw.

  • Gravatar Juan Diego Gonzales 6 months

    live site /etc/nginx/sites-avaible/wordpress screenshot (I followed this tutorial and the LEMP one from the community articles.)

  • Gravatar Kamal Nasser 6 months

    @Juan: See http://wordpress.org/plugins/nginx-helper/

  • Gravatar Nicholas Ong 6 months

    Got a couple of questions. So, I got LEMP + WordPress setup. Now, I got a sub-domain setup to serve static files (cookie free domain). I got the sub-domain pointed to the same root of my main domain. See my config below. sub-domain block server { listen 80; server_name cdn.mydomain.com; root /var/www/mydomain/htdocs; location ~* \.(?:js|css|ogg|ogv|wav|mp4|jpg|jpeg|gif|png|ico)$ { expires max; log_not_found off; add_header Pragma public; add_header Cache-Control "public"; access_log off; break; } location / { return 404; } } main domain block location ~* \.(?:js|css|ogg|ogv|wav|mp4|jpg|jpeg|gif|png|ico)$ { if ($http_referer ~ "wp-admin") { break; } if ($request_filename ~* jquery\.js$) { break; } return 404; } My questions: 1. The subdomains seem to be working but how do I get wordpress to pickup the js/css and image files from cdn.mydomain.com? I am hoping this can be done with a plugin. 2. assuming i have to install the W3TC plugin and use the self-hosted CDN function, it's asking for FTP host, FTP user, FTP password... Pretty sure my SSH credentials are not gonna work yes? In that case, what can be done? Basically, all i really wana do is to have my static files dumped on the subdomain so GTmetrix stops telling me about cookie free domains... Thoughts anyone?

  • Gravatar Kamal Nasser 6 months

    @Nicholas: 1. The subdomains seem to be working but how do I get wordpress to pickup the js/css and image files from cdn.mydomain.com? I am hoping this can be done with a plugin. I'm not sure if this would work, but try editing your theme to use the subdomain instead of the main domain. Also see http://www.webmasterview.com/2009/11/wordpress-media-sub-domain/ 2. assuming i have to install the W3TC plugin and use the self-hosted CDN function, it's asking for FTP host, FTP user, FTP password... Pretty sure my SSH credentials are not gonna work yes? In that case, what can be done? It appears to be a permissions issue. Have you followed the Give ownership of the directory to the nginx user, replacing the "username" with the name of your server user. section?

  • Gravatar Nicholas Ong 6 months

    @Kamal, I gave permission to the /var/www/ directory. Or should I give permission to my /var/www/mydomain.com/htdocs directory? Just to be sure, permission meaning this yes? sudo chown www-data:www-data * -R sudo usermod -a -G www-data MYUSER

  • Gravatar dokterlisin 6 months

    wordpress installed, but when accessing ip address it show "welcome to ngingx" instead my wordpress home page, please help me to fix it

  • Gravatar Kamal Nasser 6 months

    @dokterlisin: Please pastebin your nginx config files.

  • Gravatar Kamal Nasser 6 months

    @Nicholas: The "-R" flag means "recursive" so if you ran that command on /var/www it'll be applied to /var/www/mydomain.com/htdocs as well.

  • Gravatar Nicholas Ong 6 months

    @Kamal. Thanks, got it.

  • Gravatar Kamal Nasser 6 months

    @dokterlisin: Try rebooting your droplet. Does that fix it?

  • Gravatar Rahul Sutariya 6 months

    @jtbowlin Socket is better than TCP on performance basis . So its Advisable to use "fastcgi_pass unix:/var/run/php5-fpm.sock;" not "fastcgi_pass 127.0.0.1:9000;"

  • Gravatar PigGy 6 months

    In this tutorial, can i repeat the same steps whenever I want to add additional wordpress in nginx (mult-wordpress in a single droplet/vps?

  • Gravatar PigGy 6 months

    I created 3 different domain+wordpress in a single Nginx but i got [Restarting nginx: nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignored] when i restart sudo service nginx restart

  • Gravatar Kamal Nasser 6 months

    @PigGy: Please pastebin all of your server blocks/virtual hosts.

  • Gravatar PigGy 6 months

    @Kamal Nasser |Error| Restarting nginx: nginx: [warn] conflicting server name "example.cc" on 0.0.0.0:80, ignored nginx: [warn] conflicting server name "example.cc" on 0.0.0.0:80, ignored nginx. /etc/nginx/sites-available/wordpress http://pastebin.com/k29VBYQh (follow your guide exactly) /etc/nginx/sites-available/site2 http://pastebin.com/mGKq43iv (follow your guide but edit the filename/location/permission and excluded sudo apt-get install php5-mysql because already did once for wordpress) /etc/nginx/sites-available/site3 http://pastebin.com/a41drbB7 (follow your guide but edit the filename/location/permission and excluded sudo apt-get install php5-mysql because already did once for wordpress)

  • Gravatar Kamal Nasser 6 months

    @PigGy: Apparently you have two server blocks with server_name set to example.cc. What's the output of the following command?

    sudo grep -ri 'example.cc' /etc/nginx

  • Gravatar PigGy 6 months

    @Kamal Nasser sudo grep -ri 'example.cc' /etc/nginx output: http://pastebin.com/5zf8hR6Q

  • Gravatar idaviddesmet 6 months

    Hi, I've followed the tutorial and the WordPress site is working and showing up, but when I try to install a plugin, specifically WooCommerce, I'm getting the following error: "You do not have sufficient permissions to access this page." I've applied the chown and usermod commands correctly with my username. The folder permissions are identical to a shared hosting which I'm migrating the data. So I'm a bit lost here. If anyone could please give me hand, I would really appreciate it. Thanks

  • Gravatar Kamal Nasser 6 months

    @PigGy: /etc/nginx/sites-enabled/site3, /etc/nginx/sites-enabled/site2, and /etc/nginx/sites-enabled/wordpress all have server_name set to example.cc. You can have only one virtualhost/server block per domain. Try fixing your server blocks, perhaps rewrite them from scratch properly :]

  • Gravatar PigGy 6 months

    @idaviddesmet I remember I have the same problem 3 weeks ago. I think i applied chmod 777 to the whole folder after that.

  • Gravatar PigGy 6 months

    @Kamal Nasser I don't understand what you mean and I google around but no information available. Are you saying: a) 3 domain x 3 nginx to be setup or b) 3 domain x 1 nginx to be setup (I'm under this line, so is it mean I just need to modify further to fix my problem?) I hope you can enlighten me by telling me should I be going for A or B?

  • Gravatar idaviddesmet 6 months

    Hi PigGy, Do you mean, the woocommerce plugin folder, or the entire wordpress folder? Btw, I created a virtual machine and did exactly the same steps as I did when setting up the VPS. The interesting thing is that it works in the virtual machine... :-\ Thanks, Dave

  • Gravatar sngliwei 6 months

    I've followed all the instructions above but when I go to my IP address nothing shows up. Tried accessing / , /index.php , /wp-admin/install.php and all of them show a totally blank page, not even an error. Any idea what could be the cause?

  • Gravatar idaviddesmet 6 months

    Hi sngliwei, Could you share the vhost (/etc/nginx/sites-enabled/) file you created?

  • Gravatar PigGy 6 months

    @idaviddesmet I applied chmod 777 on the whole directory of wordpress e.g var/www/wordpress

  • Gravatar sngliwei 6 months

    idaviddesmet, here's what it currently looks like: http://pastebin.com/bnLpHSwR I've tried both localhost and my IP address under server_name and it's the same. Thanks for the help

  • Gravatar sngliwei 6 months

    I found the problem: there was a missing ' in my wp-config.php. Caught by a typo!

  • Gravatar PigGy 6 months

    @Kamal Nasser The issue is solved. Thanks

  • Gravatar idaviddesmet 6 months

    Hi PigGy, I found the problem. Somehow the mentioned plugin didn't add all values to the database when activated for the first time. So I drop the whole db, and created a new one. This time when I activated the plugin, I was able to complete the setup. Glad I did this, since I was considering starting all over again the whole process. Cheers,

  • Gravatar idaviddesmet 6 months

    @sngliwei Glad you make it work! Sometimes the simplest solution is often the best.

  • Gravatar Tamara Zuk 5 months

    I recently started 2 new droplets and noticed that WordPress was not generating thumbnail. After a lot of research I tried installing php-gd with success! sudo apt-get install php5-gd I am not sure if something has changed since the last time I built a WP droplet in July, but I don't remember having this problem them (and in fact all WP installs generate thumbnails on that droplet) so I thought I should post this here. Maybe the OP can investigate and add to the tutorial if they think it is needed. Thanks

  • Gravatar ariel 5 months

    Hi I Get this: Welcome to nginx! when using my http://IP or http://IP/wordpress or http://IP/wp-admin/install.php I have done reboots, not helped Any help would be appreciated, Cheers

  • Gravatar Kamal Nasser 5 months

    @ariel: Please pastebin your nginx virtualhost config files.

  • Gravatar dahunsilanre 5 months

    @Kamal @anyone: Database keeps crashing, have created swap file and still no luck. Have bin battling with it for the past one week now. The droplet config : 40GB, 2GB RAM The MySQL Error Log shows: 131124 13:35:34 [Note] Plugin 'FEDERATED' is disabled. 131124 13:35:34 InnoDB: The InnoDB memory heap is disabled 131124 13:35:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins 131124 13:35:34 InnoDB: Compressed tables use zlib 1.2.3.4 131124 13:35:34 InnoDB: Initializing buffer pool, size = 128.0M 131124 13:35:34 InnoDB: Completed initialization of buffer pool InnoDB: Unable to lock ./ibdata1, error: 11 InnoDB: Check that you do not already have another mysqld process InnoDB: using the same InnoDB data or log files. 131124 13:35:34 InnoDB: Retrying to lock the first data file InnoDB: Unable to lock ./ibdata1, error: 11 Please help, database keeps crashing.

  • Gravatar Kamal Nasser 5 months

    @dahunsilanre: You probably have more than one mysqld process running. Try rebooting your droplet and see if that fixes it.

  • Gravatar raymond 5 months

    Anyone facing the problem not able to install themes or plugins (zip file) through the WordPress themes or plugins upload?

  • Gravatar hardeeps 5 months

    Hi, Thanks for the fantastic tutorial. Once I finished the tutorial though and checked my ip address. It says 'File not found.' I think it is to do with that file we edited, I have pasted it here: http://pastebin.com/P0Wid1nj Did I do anything wrong? Thanks in advance.

  • Gravatar Kamal Nasser 5 months

    @raymond: It appears to be a permissions issue. Have you followed the Give ownership of the directory to the nginx user, replacing the "username" with the name of your server user. section?

  • Gravatar Kamal Nasser 5 months

    @hardeeps: Try adding

    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    after the line that begins with fastcgi_index. Restart nginx, does that fix it?

  • Gravatar hardeeps 5 months

    Thanks Kamal. Unfortunately it still doesn't work. I updated the pastebin file to show where I pasted it. Is that correct? I restarted nginx and php5-fpm, but it still says the same. Thank you.

  • Gravatar raymond 5 months

    @kamal. Thanks for the reply. I did give sudo chown www-data:www-data * -R sudo usermod -a -G www-data username to my public_html directory. But it still fail. It will display a page not available (chrome) after trying to upload the zip file.

  • Gravatar raymond 5 months

    @kamal. Thanks for the reply. I did give the www-data:www:data to my public_html (WordPress files are inside) directory. But it still fail. It will display a page not available (chrome) after trying to upload the zip file.

  • Gravatar Kamal Nasser 5 months

    @hardeeps: Are you sure that /root/www exists? I believe that should be /var/www instead.

  • Gravatar Kamal Nasser 5 months

    @raymond: Check nginx's error logs:

    sudo tail -15 /var/log/nginx/error.log

  • Gravatar raymond 5 months

    What should I look out for in the error log?

  • Gravatar raymond 5 months

    This is the error I saw. *65 client intended to send too large body: 12883570 bytes, client: 218.186.17.248, server: consistenttp.com, request: "POST /wp-admin/update.php?action=upload-theme HTTP/1.1", host: "www.consistenttp.com", referrer: "http://www.consistenttp.com/wp-admin/theme-install.php?tab=upload"

  • Gravatar hardeeps 5 months

    Thank you Kamal. That worked. I have no idea why I put root there instead of var. However it works now. Thank you so much! :D

  • Gravatar service 4 months

    I followed all instructions and I get file not found when I got to the my-ip-address/wp-admin/install.php here is the /etc/nginx/sites-available/wordpress config file: # You may add here your # server { # ... # } # statements for each of your virtual hosts to this file ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /var/www; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name MY-IP-ADDRESS; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } # Only for nginx-naxsi : process denied requests #location /RequestDenied { # For example, return an error code #return 418; #} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # #error_page 500 502 503 504 /50x.html; #location = /50x.html { # root /usr/share/nginx/www; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # root html; # index index.html index.htm index.php; # location / { try_files $uri $uri/ /blog/index.php$is_args$args; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # # root html; # index index.html index.htm; # # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # # ssl_session_timeout 5m; # # ssl_protocols SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP; # ssl_prefer_server_ciphers on; # # location / { # try_files $uri $uri/ /index.html; # } #}

  • Gravatar Kamal Nasser 4 months

    @service: See my comment above (Posted November 29th, 2013 20:45).

  • Gravatar hopefloatt 4 months

    Hi, I'm really confused by step 5 "sudo usermod -a -G www-data username". Please clarify what is server user? is it referring to step 3 of this tutorial when i created a wordpress user in MySQL? or does it refer to the alternative root user i created (not from this tutorial). Thanks.

  • Gravatar Kamal Nasser 4 months

    @hopefloatt: The alternative user that you created (Initial Server Setup).

  • Gravatar hopefloatt 4 months

    thanks Kamal :)

  • Gravatar hopefloatt 4 months

    Hi, I installed phpMyAdmin (before installing wordpress) and was able to login to phpmyadmin. But after i installed wordpress (my wordpress is working fine), when i tried to go to http://123.123.123/phpmyadmin, i didnt get to the login page of phpmyadmin. instead, i see my wordpress site. Do you know why is my login page of phpmyadmin missing? I suspect it had something to do with deleting of the nginx server block but i'm not sure as i'm totally new with all this! will re-installing phpmyadmin fix this? Thank you once again!

  • Gravatar Kamal Nasser 4 months

    @hopefloatt: How did you install Wordpress? Did you follow an article?

  • Gravatar hopefloatt 4 months

    I followed this tutorial. I installed them in this order, 1) Initial Server Setup, 2) LEMP, 3) phpMyAdmin, 4)wordpress. For 3), I used this tutorial https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server/ When i did steps 1,2,3, I was able to get the login screen page of phpMyAdmin. After installing wordpress, the login screen page is gone. Instead i see my wordpress home page for http://mydomain/phpmyadmin I was searching for answers in https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server/. Seems like my problem is similar to Abraham Laria. However, i did not see any solution to his question. How can I fix this? Thanks

  • Gravatar joseph 4 months

    Can you explain why this is necessary? sudo usermod -a -G www-data username

  • Gravatar Kamal Nasser 4 months

    @joseph: It adds `username` to the `www-data` group so that `username` can write to the files that have their group set to `www-data` which is everything in /var/www/ assuming you followed this article (sudo chown www-data:www-data * -R ).

  • Gravatar postatender 4 months

    Hi. I followed this tutorial. However, I am installing W3Total Cache and have the following messages: 1 - FTP credentials don't allow to write to file /var/www/nginx.conf 2 - W3 Total Cache Error: Files and directories could not be automatically created to complete the installation. Please execute commands manually or use FTP form to allow W3 Total Cache make it automatically. What should I do about it? It looks like although I followed the instructions chown and cmod I am not allowed to use ftp and my plugins can't right to files? Thanks for any help

  • Gravatar postatender 4 months

    BTW: I am also running my blogs in multisite so I also followed this tutorial: https://www.digitalocean.com/community/articles/how-to-set-up-multiple-wordpress-sites-using-multisite

  • Gravatar postatender 4 months

    Sorry, not that one, this one: https://www.digitalocean.com/community/articles/how-to-configure-single-and-multiple-wordpress-site-settings-with-nginx

  • Gravatar Kamal Nasser 4 months

    1 - FTP credentials don't allow to write to file /var/www/nginx.conf
    Good. You shouldn't edit system files via FTP. Use SFTP instead.
    2 - W3 Total Cache Error: Files and directories could not be automatically created to complete the installation.
    What directories does it need to write to?

  • Gravatar postatender 3 months

    apparently only the file nginx.conf in var/www However, as I noticed that the file wasn't even created, it probably means that var/www doesn't have permissions to write. On the other hand, as I followed the tutorial exactly I should probably point w3tc to "demo" the file in sites-available and allow wordpress to write to that file. Don't know, merely speculating.

  • Gravatar Kamal Nasser 3 months

    @postatender: Try running

    touch /var/www/index.html
    chown www-data. /var/www/index.html
    as root.

  • Gravatar persiu20 3 months

    Please help me. How to solve it ? > CREATE USER wordpressuser@localhost; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query OK, 1 row affected (0.00 sec) CREATE USER wordpressuser@localhost' at line 1 mysql> Query OK, 0 rows affected (0.00 sec)

  • Gravatar Kamal Nasser 3 months

    @persiu20: You're not supposed to enter the "Query OK" lines. Just "CREATE USER wordpressuser@localhost;".

  • Gravatar persiu20 3 months

    ok thx. Next problem persu@ubuntu:/var/www$ sudo service php5-fpm restart php5-fpm: unrecognized service persu@ubuntu:/var/www$ sudo service nginx restart Restarting nginx: nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/wordpress:69 nginx: configuration file /etc/nginx/nginx.conf test failed

  • Gravatar Kamal Nasser 3 months

    @persiu20:

    php5-fpm: unrecognized service
    Did you install php5-fpm?
    sudo apt-get install php5-fpm
    "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/wordpress:69
    Have you read the error? You have fast_cgi twice the "wordpress" file (Line 69).

  • Gravatar persiu20 3 months

    ok i Deleted it. and know after restart command is ersu@ubuntu:~$ sudo service nginx restart Restarting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) it is normal ?

  • Gravatar persiu20 3 months

    i try to restart persu@ubuntu:~$ sudo service php5-fpm restart php5-fpm: unrecognized service i dont know why is unrecognized but wordpress is running

  • Gravatar persiu20 3 months

    my last question . I install wordpress and after crash is message that there is server unavaible Apache/ Why not nginx?? Ho to show/check that is nginx ? I have to do performance test between nginx and apache.

  • Gravatar Kamal Nasser 3 months

    @persiu20:

    Restarting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    Apache is listening on port 80. You have to stop it first:
    sudo service apache2 stop
    php5-fpm: unrecognized service
    Did you install php5-fpm?
    sudo apt-get install php5-fpm

  • Gravatar persiu20 3 months

    yes i installed it from your tutorial

  • Gravatar persiu20 3 months

    what is www catalog for apache and nginx? This same ?

  • Gravatar Kamal Nasser 3 months

    @persiu20: What do you mean by catalog?

  • Gravatar persiu20 3 months

    catalog where should will be my index.html / php my www files.

  • Gravatar persiu20 3 months

    I want to test performance nginx and apache so i have to copy my website to nginx and apache and ping it using APache Benchmark.

  • Gravatar Kamal Nasser 3 months

    In Apache it's the DocumentRoot while in nginx it's called "root". You can set it to whatever you want, you would usually need to set it to the same directory e.g. /var/www.

  • Gravatar victor.duarte 3 months

    Great instructions! I followed them but when I load any page other than the nginx welcome, it displays my original wp-config.php file. I say original because I didn't see the line to copy the sample so I just created the file with the lines you supplied. I've since done it the right way, restarted everything but the contents of the original wp-config.php file keep displaying. Any thoughts?

  • Gravatar Kamal Nasser 3 months

    @victor.duarte: Try clearing tour browser's cache, does that fix it?

  • Gravatar tnuglf 3 months

    Hi guys, I insalled lemp with this tutorial https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04 And then I installed wordpress but this is for a single site. I read this other tutorial https://www.digitalocean.com/community/articles/how-to-configure-single-and-multiple-wordpress-site-settings-with-nginx But what happen with my single wordpress site if I use the the tutorial above. What steps do I need to follow or be carefull to not affect the already installed single wordpress site? thanks for your help. thx

  • Gravatar rogerpibernat 3 months

    Hi, I've been following this tutorial but I just can't make it work... There's two different things happening. On one hand, I must set the root location to /usr/share/nginx/html/ for it to work, not /var/www as suggested above. The other problem is that if *.html files seem to work fine, but *.php files throw a 403 error. Probably that should be solved in the .../sites-available/whatever file. So here's mine (copy-paste from above with my own settings) server { listen 80; root /usr/share/nginx/html/wu; #root /var/www/wu; index index.php index.html index.htm; server_name wucollective.com; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { try_files $uri =404; #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } Any ideas on what am I doing wrong?

  • Gravatar preetham 3 months

    Hi i have been facing the same problem getting 403 forbidden error ,can u please guide on where i am going wrong

  • Gravatar Kamal Nasser 3 months

    @tnuglf: Take a snapshot of your droplet (assuming it's in a working state currently) and then try it out, if it breaks anything you can simply restore your droplet from the snapshot :]

  • Gravatar Jason 3 months

    I followed all of the instructions installing LEMP with Ubuntu 12.04 and this page as well -- however I noticed that the Image Edit button in WordPress is no longer visible. I believe this is because some requirements for that were not installed -- http://php.net/manual/en/book.image.php. In face, there may be more missing; however I'm not yet sure because I haven't fully tested all the features on my install yet. Here is a list of all the requirements (though from 2012 so I'm not sure if it's still 100% relevant) http://wordpress.stackexchange.com/questions/42098/what-are-php-extensions-and-libraries-wp-needs-and-or-uses Hopefully someone else who is having issues with this will be helped.

  • Gravatar sichevoi 3 months

    Re: downloading index.php issue Had the same problem - figured that I did not have "fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;" param in my nginx fastcgi_params. After fixing that (simply adding the line to location ~ \.php$ {} section) I was able to install wp - but could not load the site. Happened to be browser cache problem - worked in a different browser and also after clearing cache. Hope this helps someone!

  • Gravatar a.markovic 2 months

    Hello and thanks for a great guide. It helped me a lot! I completed all the steps above and I got a working "Hello World" wordpress site. Unfortunately after moving my production site files to my /var/www folder, configuring new database, etc.. I run into problems. I login to my wp-admin, go to the appearance> themes and after enabling my production site theme I get white screen and http 500 internal server error response. I think the problem might be with files and folders permission as I suspect I messed something up. Here is the link to the screenshot after going to /var/www and typing ls -l to see files permission http://imgur.com/PeWPerr Can someone point me to the right direction? Thanks a lot for your support guys, appreciate it!

  • Gravatar Kamal Nasser 2 months

    @a.markovic: Check the error logs in /var/log/nginx/error.log and /var/log/php5-fpm.log — are there any errors?

  • Gravatar a.markovic 2 months

    @kamal nasser: Hello Kamal, thanks for the reply. I took a look at the logs and thankfully I managed to resolve the problem. The problem was caused by wordpress and theme because it looked for a php file and couldn't find it so I've ended up with 500 internal error. I used sftp to transfer theme files again, reinstalled and is working properly. This is the paste of error if someone has the same issue and find this useful http://pastebin.com/a9Vk09Pj Thanks for support, best regards!

  • Gravatar 4uankur 2 months

    I have followed all steps as written. 1. Installed LEMP 2. Insalled phpmyadmin. I could access it from my-site-ip/phpmyadmin 3. Installed wordpress using above guide Now when i visit my site IP, I get nothing. No wordpress setup etc. Also, my-site-ip/phpmyadmin dont work now. This makes sense as after this guide my site try to access phpadmin which is not in /var/www But problem is why I dont see anything now. If i change in /etc/nginx/sites-enabled/wordpress root /var/www; to root /usr/share/nginx/www; and restart nginx then I again see nginx welcome page and can access my-site-ip/phpmyadmin So, I dont understand why I cant access anything when I change root to /var/www Thanks in advance.

  • Gravatar hopefloatt 2 months

    Hi, how do I know if my wordpress is updating plugins through FTP, SFTP or SSH? I'm really confused! thank you

  • Gravatar 4uankur 2 months

    UPDATE: I fixed it. It was not nginx error but I missed a quote in wpconfig.php I read error log of nginx to fix this.

  • Gravatar Jason 2 months

    Im getting 403 errors - checked my error log: 2014/02/08 13:09:02 [error] 9748#0: *1 directory index of "/var/html/" is forbidden, client: xx.xxx.xx.xx, server: xxx.xxx.xxx.xxx, request: "GET / HTTP/1.1", host: "mydomain.com" I'm really at a loss as to what's going on here, my permissions & owner/group below: (in /var/html) drwxr-xr-x 4 www-data www-data 4096 Feb 7 20:41 ./ drwxr-xr-x 13 root root 4096 Feb 7 20:47 ../ drwxr-xr-x 3 www-data www-data 4096 Jan 28 16:07 staging.mydomain.com/ drwxr-xr-x 3 www-data www-data 4096 Feb 8 13:00 mydomain.com/ (in mydomain.com directory) drwxr-xr-x 3 www-data www-data 4096 Feb 8 13:00 ./ drwxr-xr-x 4 www-data www-data 4096 Feb 7 20:41 ../ drwxr-xr-x 5 www-data www-data 4096 Jan 28 21:34 public_html/

  • Gravatar Jason 2 months

    OK - I seemed to have fixed the issue, though I'm not sure it's the right way so please let me know if this will cause an issue down the road: I set the root in my /etc/nginx/sites-available/mydomain to be root /var/html/mydomain.com/public_html; Now, ALL of the WordPress files exist in this directory, but when I originally set up WordPress with nginx (and it was working fine) I didn't need to do this. I followed these directions and only used /var/www (it's html instead of www now since nginx has upgraded). Why was I able to just specify the parent directory before but now I have to be so specific?

  • Gravatar Kamal Nasser 2 months

    @Jason: That's because you configured nginx to serve files from /var/www. It doesn't contain any index files so nginx is returning a 403 error. Since your files are in /var/html/mydomain.com/public_html, you have to set root to that directory so that nginx can serve files from there.

  • Gravatar Paul Oaten 2 months

    @kamal I have followed instructions and rechecked everything bu just het "Welcome to NGINX". I have restarted everything too (including droplet). Here's my etc/nginx/sites-available/wordpress file: http://pastebin.com/6MaVR3AL Any help appreciated!

  • Gravatar Paul Oaten 2 months

    @kamal my droplet ip address is: 188.226.153.128

  • Gravatar Kamal Nasser 2 months

    @Paul: Does it exist in /etc/nginx/sites-enabled? If not, symlink it:

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

  • Gravatar Paul Oaten 2 months

    @kamal yes it is symlinked

  • Gravatar Kamal Nasser 2 months

    @Paul: Hmm. What's the output of

    ls -lah /etc/nginx/sites-enabled
    ? I'm not able to access 188.226.153.128, please make sure that nginx is running.

  • Gravatar Paul Oaten about 1 month

    @kamal - does it make a difference if my domain name uses a subdomain? My actual URL is: http://web.pca-uk.com. I'm pretty sure this is where it's going wrong. How does the nginx.conf need to be setup for subdomains? Or am I on the wrong track here? Appreciate your help!

  • Gravatar Paul Oaten about 1 month

    @kamal ls -lah /etc/nginx/sites-enabled total 8.0K drwxr-xr-x 2 root root 4.0K Feb 14 04:40 . drwxr-xr-x 6 root root 4.0K Feb 9 13:32 .. lrwxrwxrwx 1 root root 34 Feb 9 13:45 example -> /etc/nginx/sites-available/example lrwxrwxrwx 1 root root 41 Feb 14 04:40 web.pca-uk.com -> /etc/nginx/sites-available/web-pca-uk.com lrwxrwxrwx 1 root root 36 Feb 8 17:48 wordpress -> /etc/nginx/sites-available/wordpress

  • Gravatar Kamal Nasser about 1 month

    @Paul: It doesn't matter what the url is as long as server_name is set to it. Can you also pastebin the contents of the three files in /etc/nginx/sites-enabled?

  • Gravatar eli about 1 month

    I'm getting a blank page too, can i get some help?

  • Gravatar pedromuraki 22 days

    Installed WordPress and it's working fine, but I can't send files by FTP program (Filezilla). Can anyone help me? Thanks in advance.

  • Gravatar Kamal Nasser 21 days

    @pedromuraki: See https://www.digitalocean.com/community/articles/how-to-use-filezilla-to-transfer-and-manage-files-securely-on-your-vps.

  • Gravatar pedromuraki 21 days

    Hello Kamal, thanks for the answer. I think the problem is on the permissions.. Thanks!

Leave a Comment

Create an account or login:
Ajax-loader