loading

Installing WordPress on Ubuntu

Updated at
16/12/2023
Views
2063

Introduction: This tutorial will guide you through the process of setting up a self-hosted WordPress website on a YottaSrc servers running Ubuntu. You don't need to be an expert, but basic Linux knowledge is assumed. 

Prerequisites:

  1. A new YottaSrc server with root access.
  2. A domain pointing to your YottaSrc server (DNS record with the IP address of your server).

Ensure the DNS record follows this format, replacing 10.0.0.1 with your server's IP:

Type Name Value A @ 10.0.0.1

  1. Ensure that SMTP ports (25 and 587) are not blocked by your hosting provider. Unblock them if necessary.

Example Terminology (Replace with Your Values):

  • Server's Public IP: 10.0.0.1
  • WordPress Domain: example.com
  • New User for the Server: holu

Step 1: Configuring the Server Step 1.1: Checking DNS To proceed, confirm that your domain points to the YottaSrc server. Use the ping command on your local computer (replace example.com with your domain):

ping example.com

Ensure the output displays your server's IP (10.0.0.1) as the result. If not, wait for DNS records to update and proceed with the tutorial up to Step 3.4.

Step 1.2: Updating the System Update your server:

apt update

Upgrade packages if needed:

apt upgrade

Step 1.3: Creating a User Create a regular system user (replace holu with your desired username):

adduser holu

Add the user to the sudo group:

usermod -aG sudo holu

From now on, use this new user for server operations:

su holu

Step 1.4: Configuring Time Zone Set the server's time zone to match your own:

sudo dpkg-reconfigure tzdata

Step 1.5: Creating a Directory for WordPress Create the directory for your WordPress website:

sudo mkdir /var/www/wordpress

Give permissions to the regular user:

sudo chown holu:holu /var/www/wordpress

Step 2: Installing Required Software Step 2.1: Using a Package Manager Install necessary software packages:

sudo apt update && sudo apt install nginx mariadb-server mariadb-client \ php-fpm php-cli php-zip php-xml php-mysql php-json php-curl php-imagick \ certbot python3-certbot-nginx

Step 2.2: Checking PHP Version Check the PHP version:

php -v

Note the major and minor version (e.g., 7.4).

Step 2.3: Installing WP-CLI Install WP-CLI, a useful tool for WordPress management:

cd curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp

Step 3: Configuring Required Software Step 3.1: Configuring PHP Edit the PHP configuration file (replace 7.4 with your PHP version):

sudo nano /etc/php/7.4/fpm/pool.d/www.conf

Replace user = www-data and group = www-data with:

user = holu group = holu

Reload the configuration (replace 7.4 with your PHP version):

sudo systemctl stop php7.4-fpm sudo systemctl start php7.4-fpm

Step 3.2: Configuring Nginx Create the Nginx configuration file:

sudo nano /etc/nginx/sites-available/wordpress

Insert the following content, making replacements as needed:

server {
    listen 80;
    server_name example.com;
    root /var/www/wordpress;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }
}
  • Replace example.com with your domain.
  • Replace /var/www/wordpress with the directory created in Step 1.5.
  • Replace 7.4 with your PHP version.

Save and close the file. Enable the configuration file:

sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress

Reload Nginx:

sudo systemctl reload nginx

Step 3.3: Configuring MariaDB Open the MariaDB shell:

sudo mysql

Create a database account for the system user (replace holu with your username from Step 1.3):

CREATE USER 'holu'@'localhost' IDENTIFIED VIA unix_socket;

Choose a database name for your WordPress website (e.g., wordpress_db). Grant permissions:

GRANT ALL ON wordpress_db.* TO 'holu'@'localhost';

Exit the shell:

\q

Step 3.4: Configuring HTTPS Support Configure HTTPS support (replace example.com with your domain):

sudo certbot -d example.com

Follow the prompts and select option 2 to redirect requests when asked.

Step 3.5: Configuring Email Notifications To receive email notifications from your WordPress website, set up the mail server and create a DNS record:

Type Name Value TXT @ v=spf1 a -all

Install and configure the mail server:

sudo apt update && sudo apt install postfix

Select "Internet Site" when prompted and use your WordPress website's domain as the mail name.

Edit the postfix configuration

YottaSrc footer

why choose us?

Better Pricing, Fast SSD Storage and Real 24/7
Technical Support.

control panel icon
cPanel

Managing Your Site Through CPanel With The Latest Version

security icon
FAST, RELIABLE & SECURE

99.8% Uptime Guarantee.
So Focus On Your Work!

support icon
24/7/365 Support

Day or night, rain or shine,
our team is here for you!

cloud backup icon
Daily Backup

Daily & Weekly Backup.
Your Files Are Safe!