Most of us are happy with the shared hosting but there are good reasons to migrate to VPS solutions. But always remember, VPS solutions are ideal for power users who has hands on experience with Unix environment. You should always know what you are doing and you need to make sure that you take periodical backups.
Digital Ocean Ubuntu Server
I’ve been using Digital Ocean for about an year now. It’s a cost effective service with awesome community and support. Checkout their pricing, you will be amazed that you can buy a VPS server in cloud for as low as $5. Crazy right?
So for this experiment I decided to use a $5 droplet (that’s how they call it) and install WordPress on top of it. When you launch your droplet you need to select an OS for your server. I usually go with Ubuntu as it’s proven and there is a big community around the world. When you run into issues, it’s always easy to get some help from someone in official or unofficial forums and IRC channels.
Apache Vs nginx
Once my server is ready, I had to decide on the web server. I know I’m going to go with nginx because of several reasons.
Apache is powering many servers around the world as far as I know and still they are continuing to dominate in many web hosting companies, but then a Russian geek came up with this nginx and it’s kind of start to dominate the web server market lately.
The best thing about nginx is that it’ll run on a low end server as it consumes less amount of resources compare to Apache. But don’t mistake it for a silly product, it’s as powerful as Apache. If you want more technical details checkout this article.
You may follow this tutorial to set up your web server.
MySQL and PHP
As we already know, WordPress will need MySQL and PHP to run. Simply follow this tutorial, then you will have an idea no how to install the PHP and MySQL with nginx.
Next steps are clear, you need to download the WordPress zip file from server into your designated directory inside www directory. Then access your domain and you should be able to see the screen which invokes the WP installation process.
Here another detailed tutorial specific to nginx and WordPress. Upto this state you can pretty much rely on Google to install WordPress on Ubuntu VPS powered by digital ocean.
If you are looking for a nginx server config I had inside “sites-available” directory. Here it is. It’s WordPress proof as currently this config file is running a latest version of WordPress blog (3.9 as I’m writing this).
server { listen 80; client_max_body_size 100m; root TYPE_YOUR_WWW_FOLDER_PATH; index index.php index.html index.htm; server_name valaipathivu.com; rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last; rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; 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; } }
WordPress Core Update Issue in VPS
As I was implementing my server, I was not giving much thought about the users and permissions. Though the WordPress worked just fine, when I was trying to do auto-update on WordPress Core, Plugin and Themes, I was directed to a FTP screen which asked me for the ftp details. Apparently I knew I did something wrong.
After searching for a while, I realized that we need to provide the rights of the WWW folder to www-data user. So to fix up this issue I had to run the below command
sudo chown -R www-data:www-data /var/www/
Importing XML files to populate the content
I’ve been importing contents from one of the old blogs into this new blog. For that I tried using the xml import method. The problem was that the server was not accepting the file that is around 4MB of size. I thought why not zip it and upload it. Voila it worked.
- Open terminal in your Mac
- type “gzip”
- drag and drop the xml file to terminal
- press return
That’s it, I had my 4MB file zipped and size reduced to 700KB. Ridiculously awesome yeah? 😛 When I uploaded the zip file it just worked fine. No issues at all.
Uploading even larger files
I know what I did above was not a great solution. We should be able to upload larger files to server, especially themes and plugins. So I decided to change the php.ini config file. You can spot the file inside “/etc/php5/fpm”. Open it with vi editor or nano or any other text editor of your choice. Look for following lines and change the value to minimum 25 MB.
; Maximum allowed size for uploaded files. upload_max_filesize = 40M ; Must be greater than or equal to upload_max_filesize post_max_size = 40M
Also make sure you have the following line in your nginx config file. If you are using my config file then no worries as I’ve included it in the file.
client_max_body_size 100m;
These settings will make sure that your WordPress installation on Ubuntu VPS can cope up with larger files.
Sitemap xml files
As you already know, sitemaps play key role in Search Engine Optimisation. So it’s viatal that we include the xml sitemap. But to handle the xml file, you need to add another couple of lines to your nginx config file. Once again, if you are using my config file, then fear not. I got you covered.
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last; rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
In case you are running a WordPress multisite. Then checkout this minimal nginx config file.
If you are worried about performance, then you can enable gzip support in the nginx server via modifying the nginx.conf file.
This is pretty much it. You can see the Tamil blog I transferred to digital cloud here. So that’s all about installing WordPress on Ubuntu box. If you have encountered any problems, feel free to write down in the comments. Bye for now.
Subscribe to our mailing list
Subscribe to our mailing list and receive a free udpates
Kumara says
Wow now this is awesome 🙂
Jay Mayu says
You are welcome 🙂
Mark Kay says
I recently set up WordPress on Digital Ocean using a very similar set up to you. So far I’m happy with the service and the price! If your interested my blog article is here: http://www.learnwordpressblog.com/2014/12/24/install-wordpress-digitalocean/
Jay Mayu says
Thanks for sharing Mark