Image

Knowledge base → Installing Wordpress on Ubuntu 20.04 (LAMP)

[Virtual servers] [Applications on VPS/VDS]
Date of publication: 09.09.2022

Consider installing Wordpress CMS on Ubuntu 20.04 with LAMP preinstalled. Similarly, you can add multiple sites to one server. The guide will also be relevant for transferring sites, for example, from shared hosting to a VPS server.

We make all settings from the root user, if you are using a regular user, add before the command sudo.

1. Download the latest version of wordpress 

apt update && sudo apt upgrade
wget https://wordpress.org/latest.zip
apt install unzip
mkdir -p /var/www/
unzip latest.zip -d /var/www/
mv /var/www/wordpress /var/www/domain.tld


2. Create a database and write in the settings

mariadb -u root

create database wpdomain; grant all privileges on wpdomain.* to user@localhost identified by 'your-password'; flush privileges; exit;

Now we will specify all this data in the configuration file wp-config.php

cd /var/www/domain.tld/
cp wp-config-sample.php wp-config.php
nano wp-config.php

/** The name of the database for WordPress */ define('DB_NAME', 'wpdomain');

/** MySQL database username */ define('DB_USER', 'user');

/** MySQL database password */ define('DB_PASSWORD', 'your-password');

Save the changes CTRL + O, Enter and exit CTRL + X


3. Web service setup

Assign rights and create a configuration file for our domain:

chown www-data:www-data /var/www/domain.tld/ -R

Let's create a configuration file:

nano /etc/apache2/sites-available/domain.tld.conf

ServerName www.domain.tld ServerAlias domain.tld

DocumentRoot /var/www/domain.tld #This enables .htaccess file, which is needed for WordPress Permalink to work.

AllowOverride All

ErrorLog ${APACHE_LOG_DIR}/domain.tld.error.log CustomLog ${APACHE_LOG_DIR}/domain.tld.access.log combined


Let's restart the services:

apache2ctl configtest
a2ensite domain.tld.conf
systemctl reload apache2
/etc/init.d/php7.4-fpm restart

Change domain.tld to your already configured in the DNS editor to the ip address of the VPS server. Thus, you can add several sites by analogy. Go to the browser using the configured http://domain.tld/ domain and complete the installation in the browser. You will be prompted to select a language, specify an administrator username and password. This completes the installation. In case of site transfer, you can place existing files and import the database.





No Comments Yet