Update your system,
sudo apt update
output:
[email protected]:~# sudo apt update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Install apache2 server,
sudo apt install apache2
output:
[email protected]:~# sudo apt install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 ssl-cert
Suggested packages:
Commands to stop, start and enable Apache2 service to always start up with the server boots.
sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service
sudo apt-get install mariadb-server mariadb-client
output:
[email protected]:~# sudo apt-get install mariadb-server mariadb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
Commands to stop, start and enable MariaDB service to always start up when the server boots.
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Secure MariaDB server by creating a root password and disallowing remote root access.
sudo mysql_secure_installation
output:
sudo mysql_secure_installation
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Restart MariaDB server
sudo systemctl restart mariadb.service
sudo apt-get install software-properties-common
output:
[email protected]:~# sudo apt-get install software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
python3-software-properties
We need to add php repository
sudo add-apt-repository ppa:ondrej/php
output:
[email protected]:~# sudo add-apt-repository ppa:ondrej/php
Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.
Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa
Then update PHP 7.1
sudo apt update
output:
[email protected]:~# sudo apt update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Install PHP 7.1 and related modules..
sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-mbstring php7.1-xmlrpc php7.1-gd php7.1-xml php7.1-mysql php7.1-cli php7.1-mcrypt php7.1-zip php7.1-curl
output:
[email protected]:~# sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-mbstring php7.1-xmlrpc php7.1-gd php7.1-xml php7.1-mysql php7.1-cli php7.1-mcrypt php7.1-zip php7.1-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
Login to MariaDB database server,
sudo mysql -u root -p
Then create a database called wpdb,
CREATE DATABASE wpdb;
output:
MariaDB [(none)]> CREATE DATABASE wpdb;
Query OK, 1 row affected (0.00 sec)
Create a database user called wpuser
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY '[email protected]@[email protected]#';
output:
MariaDB [(none)]> CREATE USER 'wpuser'@'localhost' IDENTIFIED BY '[email protected]@[email protected]#';
Query OK, 0 rows affected (0.00 sec)
Then grant the user full access to the database.
GRANT ALL ON wpdb.* TO 'wpuser'@'localhost' IDENTIFIED BY '[email protected]@[email protected]#' WITH GRANT OPTION;
output:
MariaDB [(none)]> GRANT ALL ON wpdb.* TO 'wpuser'@'localhost' IDENTIFIED BY '[email protected]@[email protected]#';
Query OK, 0 rows affected (0.00 sec)
Save your changes and exit.
FLUSH PRIVILEGES;
EXIT;
cd /tmp
wget https://wordpress.org/latest.tar.gz
output:
[email protected]:/tmp# wget https://wordpress.org/latest.tar.gz
--2019-01-17 16:29:04-- https://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 198.143.164.252
Extract the tar file
tar -zxvf latest.tar.gz
output:
[email protected]:/tmp# tar -zxvf latest.tar.gz
wordpress/
wordpress/xmlrpc.php
wordpress/wp-blog-header.php
wordpress/readme.html
Move the wordpress file into /var/www/html
sudo mv wordpress /var/www/html/wordpress
output:
[email protected]:/tmp# sudo mv wordpress /var/www/html/wordpress
sudo chown -R www-data:www-data /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/
output:
[email protected]:/tmp# sudo chown -R www-data:www-data /var/www/html/wordpress/
[email protected]:/tmp# sudo chmod -R 755 /var/www/html/wordpress/
sudo vi /etc/apache2/sites-available/wordpress.conf
Then copy and paste the content below into the file and save it.
output:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress/
ServerName server.com
ServerAlias vps.server.com
<Directory /var/www/html/wordpress/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Note: Incase you dont have any domain name, set the ServerName value to the VPSes IP Address.
Enable the WordPress and Rewrite Module
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2.service
sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
output:
[email protected]:/tmp# sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
Open the config file.
sudo vi /var/www/html/wordpress/wp-config.php
output:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wpdb');
/** MySQL database username */
define('DB_USER', 'wpdbuser');
/** MySQL database password */
define('DB_PASSWORD', '[email protected]@[email protected]#');
Open your browser and browse to your domain name to launch WordPress configuration wizard.
http://<your_ip>
This concludes the installation of Wordpress on a Ubuntu server.