WordPress Installation on Ubuntu Server
Published in
2 min readAug 13, 2022
- Download WordPress & Install WordPress
- Install MySQL Database Server
- Create WordPress Database
- Installing Additional PHP Extensions
- Configuring the WordPress Directory
- Adjusting the Ownership and Permissions
- Install Nginx
- Adjusting the Firewall
- Configure Nginx
- Completing the Installation Through the Web Interface
1. Download WordPress & Install WordPress
- Download WordPress using the following command
$ wget -c http://wordpress.org/latest.tar.gz
- Extract the WordPress Zip file
$ tar xzvf latest.tar.gz
2. Install MySQL Database Server:
- We need to install the MySQL database server by running the command below
$ sudo apt install mysql-server mysql-client
- start & enable the mysql service
$ sudo systemctl start mysql$ sudo systemctl enable mysql
3. Create WordPress Database
- Creating a MySQL Database and User for WordPress
$ sudo mysql -u root
- create an exclusive database for WordPress to control
mysql> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- create a separate MySQL user account that we will use exclusively to operate our new database
mysql> CREATE USER ‘wordpressuser’@’localhost’ IDENTIFIED BY ‘password’;
- Next, let the database know that our wordpressuser should have complete access to the database we set up:
mysql> GRANT ALL ON wordpress.* TO ‘wordpressuser’@’localhost’;
- Exit out of MySQL
mysql>EXIT;
4. Installing Additional PHP Extensions
- Download and install some of the most popular PHP extensions for use with WordPress by typing:
$ sudo apt install php7.4 php7.4-gd php7.4-mysql php7.4-zip php7.4-fpm –y
5. Configuring the WordPress Directory
- Move all WordPress file into /var/www/html directory
$ sudo cp -r /home/ubuntu/wordpress /var/www/html
6. Adjusting the Ownership and Permissions
- Run the command below to change ownership of ‘wordpress’ directory
$ sudo chown -R www-data:www-data /var/www/html/wordpress
- Change File permissions of the WordPress folder
$ chmod -R 755 /var/www/html/wordpress/
7. Install Nginx
$ sudo apt update$ sudo apt install nginx
8. Adjusting the Firewall
- List all firewall apps in ubuntu server
$ sudo ufw app list
- Allow nginx traffic on port 80
$ sudo ufw allow nginx
- You can verify the change by typing:
$ sudo ufw status
- Checking your Web Server
$ sudo systemctl status nginx
- When you have your server’s IP address, enter it into your browser’s address bar:
http://your_server_ip/
- You should receive the default Nginx landing page.
9. Configure Nginx
- Navigate to /etc/nginx/site-available folder
$ cd /etc/nginx/site-available
- Rename default file into wordpress.com
$ mv default wordpress.com
- Restart the nginx server
$ sudo systemctl restart nginx
- Now run the following URL in your browser
http://your_server_ip/wordpress
10. Completing the Installation Through the Web Interface
- Completing the Installation Through the Web Interface
- In web browser, navigate to your server’s domain name or public IP address:
https://server_domain_or_ip/