This article will serve as a walkthrough for how to install WordPress on a Digital Ocean VPS. To do this, please follow the guide below.
Adding a User
- Login to your droplet via ssh.
~$ ssh root@123.123.123.123 The authenticity of host '123.123.123.123 (123.123.123.123)' can't be established. ECDSA key fingerprint is 79:95:46:1a:ab:37:11:8e:86:54:36:38:bb:3c:fa:c0. Are you sure you want to continue connecting (yes/no)?
- Add a new user and fill out the following details to complete user creation: password, full name, phone number, etc.
~# adduser developer
- Confirm root privileges for your new user:
- Open sudoers file.
~# nano /etc/sudoers
- Find the following row:
root ALL=(ALL:ALL) ALL
-
Add the following below root:
ALL=(ALL:ALL) ALL
developer ALL=(ALL:ALL) ALL
- Open sudoers file.
- Change user.
~# su - developer
- Update system:
- DEBIAN
-
~$ sudo apt-get update
-
- RHEL
-
~$ sudo yum update
-
- DEBIAN
Installing the Web Server
- DEBIAN
-
~$ sudo apt-get install apache2
-
- RHEL
-
~$ sudo yum install apache2
-
Installing mysql
- DEBIAN
-
~$ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql ~$ sudo /usr/bin/mysql_secure_installation
- Enter current password for root (hit enter if there isn't a password).
-
- RHEL
-
~$ sudo yum install mysql-server libapache2-mod-auth-mysql php5-mysql ~$ sudo /usr/bin/mysql_secure_installation
- Enter current password for root (hit enter if there isn't a password).
-
OK, successfully used password, moving on...
Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.
It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
Installing php
- DEBIAN
-
~$ sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
-
- RHEL
-
~$ sudo yum install php5 libapache2-mod-php5 php5-mcrypt
-
Preparing the Database
- Login to the mysql server.
~$ mysql -uroot -ppassword
- Create a mysql user.
mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'desired_password';
- Grant privileges for the new user
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;
- Create database.
mysql> CREATE DATABASE wp_db;
Installing WordPress
~$ cd /var/www/html/
~$ wget https://wordpress.org/latest.zip
~$ unzip latest.zip
~$ mv -f /var/www/html/wordpress/* /var/www/html/
- If you don’t have unzip install it with:
DEBIAN
~$ apt-get install unzip
OR
RHEL
~$ yum install unzip
Installation via Browser
Access your WordPress installation via browser by typing your domain associated with your Droplet or IP address you received after the droplet was created:
http://domain.com/
http://123.123.123.123/
The installation will automatically start and you should complete the installation of WordPress by filling out the requested fields. Below are a few examples (be sure to use your own unique names):
- Database user: user
- Database user password: desired_password
- Database name: wp_db
- Host server: localhost
If you have any questions about the content of this article, please feel free to reach out to the Support Team for assistance, we're available 24/7 for your convenience.