Overview
WordPress is the most popular open-source blogging system and CMS on the Web. It is based on PHP and MySQL. Its features can be extended with thousands of free plugins and themes.
In this tutorial we will install WordPress on Apache2 server and create our first post.
What you’ll learn
How to set up WordPress
How to configure WordPress
How to create first post
What you’ll need
A computer running Ubuntu Server 20.04 LTS
This guide will also show you how to configure a database for WordPress
rdPress, explore the interface a bit to get acquainted with your new CMS.
2. Install Dependencies
To install PHP and Apache, use following command:
sudo apt update
sudo apt install apache2 \
ghostscript \
libapache2-mod-php \
mysql-server \
php \
php-bcmath \
php-curl \
php-imagick \
php-intl \
php-json \
php-mbstring \
php-mysql \
php-xml \
php-zip
3. Install WordPress
We will use the release from WordPress.org rather than the APT package in the Ubuntu Archive, because this is the preferred method from upstream WordPress. This will also have fewer “gotcha” problems that the WordPress support volunteers will not be able to anticipate and therefore be unable to help with.
Create the installation directory and download the file from WordPress.org:
sudo mkdir -p /srv/www
sudo chown www-data: /srv/www
curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www
4. Configure Apache for WordPress
Create Apache site for WordPress. Create /etc/apache2/sites-available/wordpress.conf with following lines:
DocumentRoot /srv/www/wordpress
Options FollowSymLinks
AllowOverride Limit Options FileInfo
DirectoryIndex index.php
Require all granted
Options FollowSymLinks
Require all granted
Enable the site with:
sudo a2ensite wordpress
Enable URL rewriting with:
sudo a2enmod rewrite
Disable the default “It Works” site with:
sudo a2dissite 000-default
Or, instead of disabling the “it works” page, you may edit our configuration file to add a hostname that the WordPress installation will respond to requests for. This hostname must be mapped to your box somehow, e.g. via DNS, or edits to the client systems’ /etc/hosts file (on Windows the equivalent is C:\Windows\System32\drivers\etc\hosts). Add ServerName as below:
ServerName hostname.example.com
… # the rest of the VHost configuration
Finally, reload apache2 to apply all these changes:
sudo service apache2 reload
5. Configure database
To configure WordPress, we need to create MySQL database. Let’s do it!
$ sudo mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0,00 sec)
mysql> CREATE USER wordpress@localhost IDENTIFIED BY ‘
Query OK, 1 row affected (0,00 sec)
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
-> ON wordpress.*
-> TO wordpress@localhost;
Query OK, 1 row affected (0,00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 1 row affected (0,00 sec)
mysql> quit
Bye
Enable MySQL with sudo service mysql start.
6. Configure WordPress to connect to the database
Now, let’s configure WordPress to use this database. First, copy the sample configuration file to wp-config.php:
sudo -u www-data cp /srv/www/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php
Next, set the database credentials in the configuration file (do not replace database_name_here or username_here in the commands below. Do replace
sudo -u www-data sed -i ‘s/database_name_here/wordpress/’ /srv/www/wordpress/wp-config.php
sudo -u www-data sed -i ‘s/username_here/wordpress/’ /srv/www/wordpress/wp-config.php
sudo -u www-data sed -i ‘s/password_here/
Finally, in a terminal session open the configuration file in nano:
sudo -u www-data nano /srv/www/wordpress/wp-config.php
Find the following:
define( ‘AUTH_KEY’, ‘put your unique phrase here’ );
define( ‘SECURE_AUTH_KEY’, ‘put your unique phrase here’ );
define( ‘LOGGED_IN_KEY’, ‘put your unique phrase here’ );
define( ‘NONCE_KEY’, ‘put your unique phrase here’ );
define( ‘AUTH_SALT’, ‘put your unique phrase here’ );
define( ‘SECURE_AUTH_SALT’, ‘put your unique phrase here’ );
define( ‘LOGGED_IN_SALT’, ‘put your unique phrase here’ );
define( ‘NONCE_SALT’, ‘put your unique phrase here’ );
Delete those lines (ctrl+k will delete a line each time you press the sequence). Then replace with the content of https://api.wordpress.org/secret-key/1.1/salt/. (This address is a randomiser that returns completely random keys each time it is opened.) This step is important to ensure that your site is not vulnerable to “known secrets” attacks.
Save and close the configuration file by typing ctrl+x followed by y then enter
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital
pulchradigital