Websites are incredibly easy to set up and manage. During this tutorial I’ll show you how to set up your own server with WordPress.
With two months free hosting
Step one: Domain Name
A domain name identifies your website on the internet.
For example: example.com
The best and cheapest domain name provider currently is Namecheap.com
To regiester a domain name with them first sign-up
Once signed in simply click Domains » Registration
Enter the domain name you want for your website in the search bar.
Most users will want to a .com domain name so select the first one and check out.
Step two: Hosting
The best and cheapest option is a VPS from DigitalOcean.com
They charge $5.00 per month but using this link you will get $10.00 credit.
In other words two months free hosting.
After creating your digitalocean account follow these steps to get set up with wordpress.
1. Create a New Droplet (VPS)
Droplets » Create Droplet
2. Select One-click Apps
By default you should be in the Distributions tab. Click One-click Apps
And select LAMP on 14.04
Scroll down and choose a size. I’d go with the $5.00/mo
The rest should be left as default but these are the configurations I’d recommend
“Choose a datacenter region”: Pick where you want your VPS to be located. I’d go with New York
“Select additional options”: Leave them all unchecked
“Add your SSH keys”: SSH keys are the safest way to login to your VPS but for now we’ll use a password. Leave it as default.
“How many Droplets?”: 1
“Choose a hostname”: mydroplet
Step three: Installing Wordpress
You’ll be given the IP of your server. For example:
And if you copy/paste it into your web browser:
Now let’s access our server and point apache to WordPress instead of the default page.
Step 1. Get Your Server’s password
Login to the email you signed up with digital ocean.
You’ll find a new email with your password information.
Step 2. SSH into your VPS
SSH allows you to to connect to your VPS safely. No data to or from can be tampered with or read.
Linux/Mac users already have an SSH client
Windows users can use putty
$ ssh root@yourvpsip
You’ll be prompted for your password. Use the one sent to you in the email.
Once you successfully SSH you’ll be outputed a message like this:
You are required to change your password immediately (root enforced) ------------------------------------------------------------------------------------- Thank you for using DigitalOcean's LAMP Application. Your web root is located at /var/www/html and can be seen from http://yourvpsip/ The details of your PHP installation can be seen at http://yourvpsip/info.php Your MySQL root user's password is password You are encouraged to run mysql_secure_installation to ready your server for production. ------------------------------------------------------------------------------------- You can find more information on using this image here: http://do.co/lampapp --------
Take note of where your web root is located as this is where we’ll install Wordpress. For me it’s /var/www/html
And also take note of MySQL root user’s password.
Lastly you’ll be asked to change your password. So do that and DONT loose it.
Step 3. Run mysql_secure_installation
This program secures your MySQL installation.
But first update your machine
$ sudo apt-get update && sudo apt-get upgrade -y
Then run mysql_secure_installation
Enter MySQL’s root password (in the output when you ssh)
Then type Y or n for each question as below.
- Change the root password? [Y/n] n
- Remove anonymous users? [Y/n] Y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] Y
- Reload privilege tables now? [Y/n] Y
Step 4. Install Wordpress
Download and Decompress WordPress
$ cd ~ $ wget http://wordpress.org/latest.tar.gz $ tar xzvf latest.tar.gz
Step 5. Create the Database
Log into MySQL with the root password provided in the ouput when you SSH’d inot your VPS
$ mysql -u root -p
Create the database
> CREATE DATABASE wordpress;
Create a new user that gets access to the wordpress database
Replace password with your own strong password
> CREATE USER wordpressuser@localhost IDENTIFIED BY 'password'
Give wordpressuser access to the database
> GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost;
Commit the changes and exit
> FLUSH PRIVILEGES; > exit
Step 6. Configure Wordpress
Copy the file wp-config-sample.php into wp-config.php and open it for editing.
$ cd ~/wordpress $ cp wp-config-sample.php wp-config.php $ nano wp-config.php
Fill in the values of these parameters with the information for the database you created. It should look like this:
// ** 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 close the file
Step 7. Copy Files to the Root
$ sudo rsync -avP ~/wordpress/ /var/www/html/ $ cd /var/www/html
Change the ownership of the files for security.
$ sudo chown -R www-data:www-data *
Create a directory for your uploads such as images
$ mkdir /var/www/html/wp-content/uploads
Step 8. Delete index.html
Delete the file index.html inside /var/www/html
$ rm index.html
And restart apache
$ sudo service apache2 restart
Type in your IP into the url and set up wordpress
Your website now has wordpres installed and running!
Last Step: Point your domain name to the ip
Follow this simple tutorial from namecheap’s website
Select Domain List from the left sidebar and click on the Manage button next to your domain:
Navigate to the Advanced DNS tab at the top of the page:
Find the Host records section and click on the Add New Record button
But first click the trash can icon next to the records there by default
Select A Record for Type and enter the Host you would like to point to an IP address:
Host: @ will point to example.com (no www)
Host: www wil point to www.example.com
Host: blog will point to blog.example.com
It typically takes 30 minutes for dns servers to refresh their cache. So in thirty minutes your website will be available at example.com!