How to Install WordPress on Ubuntu 22.10
WordPress is one of the most popular website-building tools available out there. It is a simple way to get your online presence and perfect for those who do not know how to code and want a simple and effective way to share and build your story on the internet.
Prerequisites:
-
Root access to your Ubuntu 22.10 server.
- LAMP Stack installed and running. Learn how to setup LAMP Stack.
Creating Database
Log into MySQL with the following command.
mysql -u root -p
First, we'll create a new database.
CREATE DATABASE wordpress_db;
Next, create a new MySQL user account that we will use to operate on WordPress's new database, with the username "wordpress_user".
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'strongpassword';
Replace "strongpassword" with an actual Password for the user.
Link the user and DB together by granting our user access to the database.
GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
Flush the privileges so that MySQL knows about the user permissions we just added.
FLUSH PRIVILEGES;
Exit out of the MySQL command prompt by typing.
exit
Output:
root@vps:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 50
Server version: 10.6.11-MariaDB-0ubuntu0.22.10.1 Ubuntu 22.10
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.001 sec)
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'strongpassword';
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> exit
Bye
Download and install WordPress
Download the latest version of WordPress by using the below command,
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 Apache vHost
We'll now configure the Apache vHost for the WordPress installation. For this, edit the following file using your favorite editor.
nano /etc/apache2/sites-available/example.com.conf
In this example, we will use example.com as the domain, replace this with your own domain or application name.
Now, in the file, add the below configuration into it.
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
DocumentRoot /var/www/wordpress
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Replace example.com with an actual domain name. If you're hosting the WordPress on an IP Address, replace it with the server's IP Address.
Save and exit the configuration file.
Enable vHost Configuration
Run the below command to enable the newly created vHost configuration,
a2ensite example.com.conf
After this, Disable the default vHost configuration present in the system.
a2dissite 000-default.conf
Restart Apache for the changes to take affect
systemctl restart apache2
Configure WordPress
Navigate to your browser.
http://IP_ADDRESS/ or http:://example.com
Start a WordPress installation by selecting the language of your choice
Click on the "Let's go" button to proceed to the next step.
Enter the details of Database that was created earlier.
Next after installation, you will be prompted to enter the site details and also creating a new User for accessing the admin dashboard.
Once the details are confirmed, you will be acknowledged with Success message.
Login with the new User and Password and you will be presented to the WordPress dashboard. Where you can further configure the site as per your requirements.
This concludes our topic of installing WordPress on Ubuntu 22.10 using Apache as a web server.