First, we connect (via SSH) to our server and update the system.

ssh root@ip-address -p your-port-number

Once logged, we type:

apt-get update
apt-get upgrade

Then, we install Apache Web Server:

apt-get install apache2

After the installation complete we start the server:

systemctl start apache2
systemctl enable apache2

And of course, we can learn about the status of our server:

systemctl status apache2

Next, we install the MySQL Database Server:

apt-get install mysql-server

Enter the strong password and follow other recommended actions during the installment process (mysql_secure_installation).

After the installation complete we start our db server:

systemctl start mysql
systemctl enable mysql

Now let’s install the PHP. I write the line for 7.0 version, you can replace the version due to your requirements (it’s highly recommended to use the latest version of pl for security and best experience):

apt-get install php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-mbstring php7.0-gd php7.0-xml php7.0-xmlrpc php7.0-intl php7.0-soap php7.0-zip

To test the ok working status of our pl:

nano /var/www/html/info.php

And type the following:

<?phpphpinfo();?>

Then save and restart the server and open the URL (http://your_server_ip_address/info.php).

Finally, we install the WordPress CMS. Let’s move to suitable directory:

cd /var/www/html

and download the package itself and then extract it:

wget -c http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

Now the all needed files placed in directory: /var/www/html/wordpres.

Let’s create a database:

mysql -u root -p

and run the following commands:

CREATE DATABASE wordpress_db; GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'PASSWORD'; FLUSH PRIVILEGES; exit;

Then we should config the wp-config.php file in the WordPress root directory:

mv wp-config-sample.php wp-config.php
nano wp-config.php

And accordingly change the info:

// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress_db'); /** MySQL database username */ define('DB_USER', 'wordpress_user'); /** MySQL database password */ define('DB_PASSWORD', 'PASSWORD'); /** MySQL hostname */ define('DB_HOST', 'localhost'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');

Then save and restart apache.

systemctl restart apache2
systemctl restart mysql

Now we should configure our VirtualHost:

nano /etc/apache2/sites-available/mydomain.com.conf

Add the following code with accordingly changes:

<VirtualHost *:80>ServerAdmin admin@mydomain.com ServerName mydomain.com ServerAlias www.mydomain.com DocumentRoot /var/www/html/wordpress ErrorLog ${APACHE_LOG_DIR}/mydomain.com_error.log CustomLog ${APACHE_LOG_DIR}/mydomain.com_access.log combined </VirtualHost>

To enable our rules:

a2ensite mydomain.com.conf

And then one more time restart the apache:

systemctl restart apache2

After that visit your website and follow the famous 5 minutes installation of WordPress 🙂

Previous

Что-то на татарском

Next

Securing Apache server with Free Let's Encrypt SSL Certificate on Ubuntu