How to install WordPress on Ubuntu 18.04 and derivatives?

Ubuntu18.04WordPress

WordPress has become one of content management systems (CMS) most popular and used in the network, This is due to the fact that it can be adapted to different types of use, it also has a large number of plug-ins that allow you to further enhance its use and without leaving the themes or skins of this lake.

This time we are going to share a simple guide on how to install WordPress in Ubuntu, this in order to have a test site or for people who still do not know its functionality.

Installation Process

Before doing anything, you must update the system with:

sudo apt-get upgrade && sudo apt-get upgrade -y

Nginx installation

In order to install WordPress on our system, we are going to rely on a few tools for its operation, the first one is Nginx:

sudo apt-get install nginx -y

MariaDB installation

For, the database service we are going to choose MariaDB, for its installation we execute:

sudo apt-get install mariadb-server -y

Done this now we are going to execute the following command to configure the database server:

mysql_secure_installation

Here only we will follow the instructions and it will ask us to set a password, which we must not forget.

creation of the database

We must log in with the credentials we put in, if we leave the ones that it has by default, it should be as follows:

mysql -u root -p

If they should not put your username after -u and your password after -p

Done this it's time to create a database, with which WordPress will be served by executing these commands:

CREATE DATABASE wordpress;

CREATE USER `tu-usuario`@`localhost` IDENTIFIED BY 'tucontraseña';

GRANT ALL ON wordpress.* TO `wpuser`@`localhost`;

FLUSH PRIVILEGES;

exit;

Here in these you are going to replace the username with your password for the database.

PHP installation

To install PHP with all its necessary dependencies and modules, run the following command:

sudo apt-get install php-fpm php-curl php-mysql php-gd php-mbstring php-xml php-xmlrpc -y

Done this totime we are going to edit the php.ini file.

sudo nano /etc/php/7.2/fpm/php.ini

Y look for this line:

;cgi.fix_pathinfo=1

We must uncomment the line removing the; change the = 1 to = 0, remained as follows:

cgi.fix_pathinfo=0

After we will look for the following lines in the php.ini file and place the following values, they should look like this:

upload_max_filesize = 100M
post_max_size = 1000M
memory_limit = 1000M
max_execution_time = 120

Download WordPress

WordPress-ubuntu

Now let's download the latest version of WordPress and we will put it in the default Nginx directory:

cd /var/www/html

wget https://wordpress.org/latest.tar.gz

Unzip the file just downloaded with:

tar -zxvf latest.tar.gz --strip-components=1

Now let's change the permissions of the Nginx folder:

chown -R www-data:www-data /var/www/html/
chmod -R 755

Done this let's create a configuration file with:

nano /etc/nginx/sites-available/example.com

Y we put the following:

server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.php index.html index.htm;
server_name example.com www.example.com;
client_max_body_size 500M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Now we must enable it with:

ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

Now restart Nginx and PHP for changes to take effect

sudo systemctl restart nginx.service
sudo systemctl restart php7.2-fpm.service

Setting up WordPress

Now let's edit the WordPress configuration file where we will place the credentials of the database:

mv /var/www/html/wp-config-sample.php /var/www/html/wp-config.php

sudo nano /var/www/html/wp-config.php

Y we will change the information within he:

define('DB_NAME', 'wordpress');
define('DB_USER', 'usuario-de-la-base-de-datos');
define('DB_PASSWORD', 'contraseña-de-la-base-de-datos');

Done this for security reasons, they must update the security keys in your wp-config.

So that we must generate them, we do this by visiting this link and we change the values ​​that this site gives us in our configuration file.

And done with it We already have WordPress installed on our system.

To start using it simply We must open a browser and place in the address bar the path where we have wordpress / var / www / html / or our ip address.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

2 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Pierre said

    Now we are going to change the permissions of the Nginx folder:

    chown -R www-data: www-data / var / www / html /
    chmod -R 755

    Error after chmod -R 755 (missing parameter)

  2.   Romualdo said

    Please correct sudo apt-get upgrade && sudo apt-get upgrade -y

    by

    sudo apt-get update && sudo apt-get upgrade -y