How to Install WordPress on Ubuntu 20.04
Prerequisites:
-
Root access to your Ubuntu 20.04 server.
- Install LEMP Stack on the server. Learn how to Install LEMP Stack
Creating the new database.
Log into MySQL with the following command.
mysql
First, we'll create a new database.
MariaDB [(none)]> CREATE DATABASE wordpress_db;
Next, create a new MySQL user account that we will use to operate on WordPress's new database, with username "wordpress_user".
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
Link the user and DB together by granting our user access to the database.
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
Flush the privileges so that MySQL knows about the user permissions we just added.
MariaDB [(none)]> FLUSH PRIVILEGES;
Exit out of the MySQL command prompt by typing.
MariaDB [(none)]> exit
Output:
root@vps:~# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE wordpress_db;
Query OK, 1 row affected (0.002 sec)
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.004 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> exit
Bye
Download and install WordPress
Download Wordpress.
wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
Unzip the downloaded WordPress file.
tar -xzvf /tmp/wordpress.tar.gz -C /var/www/
Change the permission of the site directory.
chown -R www-data.www-data /var/www/wordpress
Configure Nginx
Configure Nginx VirtualHost file /etc/nginx/conf.d/default.conf
.
nano /etc/nginx/conf.d/default.conf
Copy the below content and save into the file.
server {
listen 80;
listen [::]:80;
root /var/www/wordpress;
index index.php index.html index.htm;
client_max_body_size 100M;
autoindex off;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Next, test to make sure that there are no syntax errors in any of your Nginx files.
nginx -t
If there aren’t any problems, restart Nginx to enable your changes.
systemctl reload nginx
Navigate to your browser.
Start a WordPress installation by clicking on the Run the installation button.
Provide the requested information.
Once the Wordpress is installed login with your new user credentials.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS