By now, you should have registered your domain name and configured the DNS settings so that it will point to your VPS. If you haven’t, and somehow stumbled on this post, go back to Step 1 to register your domain name via NameSilo. If you’ve missed Step 2, go back and configure the DNS settings for your domain.
Step 3: Installing WordPress
First, you need to SSH into your VPS. Next, perform the following commands while in your user directory (replace all yourdomain.com with your own domain name):
- Wget the latest copy of WordPress from wordpress.org:
sudo wget https://wordpress.org/latest.tar.gz
- Extract the wordpress folder from the
.tar.gz
file:
sudo tar -xzvf latest.tar.gz
- Create the directory using your domain name in
/var/www
, andpublic_html
folder in/var/www/yourdomain.com
:
sudo mkdir /var/www/yourdomain.com
sudo mkdir /var/www/yourdomain.com/public_html
- Copy the contents of the
wordpress
folder into/var/www/yourdomain.com/public_html/
:
sudo cp -r wordpress/* /var/www/yourdomain.com/public_html/
- Change the owner of your
public_html
folder and all its contents to www-data (the OS of my VPS is Ubuntu, so we use www-data):
sudo chown -R www-data:www-data /var/www/yourdomain.com/public_html/
- In
/etc/apache2/sites-available/
, create a new file namedyourdomain.com.conf
:
sudo vi /etc/apache2/sites-available/yourdomain.com.conf
Then type in the following:<Directory "/var/www/yourdomain.com/public_html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin support@yourdomain.com
DocumentRoot /var/www/yourdomain.com/public_html
ServerName www.yourdomain.com
ServerAlias yourdomain.com
ErrorLog /var/www/yourdomain.com/error.log
CustomLog /var/www/yourdomain.com/requests.log common
</VirtualHost>
- Create a MySQL database for this WordPress website and a user that will have all privileges to access and modify it. I used phpMyAdmin as it’s definitely way easier to just click around, but if you haven’t got it installed and need to use commands, here they are.
- Login to MySQL:
mysql -u root -p
- Create database (replace wordpress_db with your desired database name):
create database wordpress_db;
- Create user and grant him all privileges to access and modify the database (replace wordpress_user and wordpress_pass with your desired username and password respectively):
create user wordpress_user@localhost identified by 'wordpress_pass';
grant all privileges on wordpress_db.* to wordpress_user@localhost;
- You’re done with the database, so exit:
exit;
- Login to MySQL:
- Make a copy of wp-config-sample.php and name it wp-config.php in
/var/www/yourdomain.com/public_html
folder:
sudo cp /var/www/yourdomain.com/public_html/wp-config-sample.php /var/www/yourdomain.com/public_html/wp-config.php
- Open
wp-config.php
and modify the following lines:
define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');Go to https://api.wordpress.org/secret-key/1.1/salt/ to obtain the secret keys and replace the following lines with those from your browser:
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');Save your file.
- Now type in this command:
sudo a2ensite yourdomain.com.conf
- Reload your Apache2 service:
sudo service apache2 reload
- You may now access your WordPress site by entering your domain name into your browser! You will see a setup page and just go ahead to get your site ready!
Ta-da you’re done! You may now enjoy the process of selecting an appropriate theme for your WordPress site and designing your website to suit your needs. Have fun! 🙂