How to install wordpress with nginx

I recently installed wordpress to create this site. This is my second attempt to create a site where I can share some how-tos, interview tips and journal my thoughts. Initially I tried to create the site from scratch where I created everything, from css to backend server but that became too much work in itself so much so that I never got time to write any posts. Hope this goes well. Sorry, I digress.

Since I already had the server from my first attempt, I decided  to reconfigure it to install some ready made CMS solution. The obvious choice was wordpress. It was really simple to set it up. Here are some pointers:

  • Download wordpress in /var/www/html/src using the following command:

sudo wget http://wordpress.org/latest.tar.gz

  • Make sure to extract the latest file as www-data user

sudo -u www-data tar -xvf latest.tar.gz

  • Copy the wordpress files in /var/www/html/public_html

cp /var/www/html/src/wordpress/* /var/www/html/public_html/

  • Change the owner of public_html folder to www-data, since nginx runs as www-data, you can check this in the nginx.conf file usually the first line will give you the user info.
  • Also make sure to change the ‘root’ value in your site config for nginx.
  • Install mysql and setup a user with password. Keep a note of this user and password you will need this value later during wordpress setup.

sudo apt-get install mysql-server

  • Install php too!

sudo apt-get install php7.0-cli php7.0-cgi php7.0-fpm php7.0-mysql

  • Configure your ufw to enable http

sudo ufw allow http/tcp

  • Remember to restart nginx, mysql and php at the end of the setup to reload the new configuration.

That’s it! Visit your site to set up rest of the wordpress admin and site. Best of luck! Please let me know if you have any questions.

One thought on “How to install wordpress with nginx

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.