How to Install a WordPress locally on ubuntu

-

This tutorial covers the whole process on installing a WordPress locally on a computer with ubuntu operating system.

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.

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

These are the whole process on installing a WordPress:

Install Dependencies

To install PHP and Apache, use following command:

sudo apt update 
sudo apt install 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 

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 chown www-data: /var/www/yourdomain/public_html 
sudo curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C 
/var/www/ yourdomain.somaliren.org/public_html 

Note that this sets the ownership to the user www-data, which is potentially insecure, such as when your server hosts multiple sites with different maintainers. You should investigate using a user per website in such scenarios and make the files readable and writable to only those users. This will require configuring PHP-FPM to launch a separate instance per site each running as the site’s user account. In such setup the wp-config.php should (read: if you do it differently you need a good reason) be readonly to the site owner and group and other permissions set to no-access (chmod 400). This is beyond the scope of this guide, however.

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 '<your-password>'; 
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

Configure WordPress with Wizard GUI

Open http://localhost/ in your browser. You will be asked for title of your new site, username, password, and address e-mail. Note that the username and password you choose here are for WordPress, and do not provide access to any other part of your server – choose a username and password that are different to your MySQL (database) credentials, that we configured for WordPress’ use, and different to your credentials for logging into your computer or server’s desktop or shell. You can choose if you want to make your site indexed by search engines.

Leave a Comment