How to Install WordPress with Caddy on  Linux Cloud

In this tutorial we are going to discuss how to install WordPress using Caddy on Linux Cloud server.

Requirements

  • Linux Cloud server with sudo non-root user and firewall.

  • MySQL installed on the server

  • Caddy installed on your server with a domain name pointed to your server.

 
cloud hosting providers India
 

1st Step: Installing PHP

With the objective to run WordPress, you need a web server along with a MySQL database and the PHP language. You as of now have the Caddy web server and a MySQL database installed from the prerequisites, so the last prerequisite is to install PHP to your Linux Cloud server.

In the first place, ensure your bundles are updated

$ sudo apt-get update

At that point, install PHP and the PHP extensions WordPress relies upon, similar to support for MySQL, curl, XML, as well as multi-byte strings.

$ sudo apt-get install php7.0-fpm php7.0-mysql php7.0-curl php7.0-gd php7.0-mbstring php7.0-mcrypt php7.0-xml php7.0-xmlrpc

Once the installation completes, you can confirm that PHP was installed effectively by checking the PHP's variant.

$ php -v

2nd Step: Creating a MySQL Database & User

First of all login to the MySQL root administrative account.

$ mysql -u root -p

You will be incited for the password you set for the MySQL root account amid installation.

Make another database called wordpress which will be utilized for the WordPress site. You can utilize an alternate name, however ensure you recall it for extra arrangement later.

mysql> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Next, make another user that will be permitted to get to this database. Here, we utilize the username wordpressname for straightforwardness, however you can pick your own particular name. Make sure to supplant password with a solid and secure password.

mysql> GRANT ALL ON wordpress.* TO 'wordpressname'@'localhost' IDENTIFIED BY 'password';

Flush privileges to inform the MySQL server of the modifications:

mysql> FLUSH PRIVILEGES;

You can now security exit MySQL.

mysql> EXIT;

 

3rd Step: Downloading WordPress

To begin with, modify the present directory to/var/www, the web root which stores your site documents.

$ cd /var/www


Download the most recent compressed WordPress version. It's essential to utilize the most recent version because the software is much of the time refreshed with security patches.

$ sudo curl -O https://wordpress.org/latest.tar.gz

Extract the compressed archive you just downloaded.

$ sudo tar zxf latest.tar.gz

The above command will automatically make another directory called wordpress. You would now be able to securely remove the downloaded file, as it's never again required.

$ sudo rm latest.tar.gz
The last move is to change the authorizations of WordPress documents and directories with the goal that all records are writable by Caddy. This will enable WordPress to be automatically refreshed to recent versions/

$ sudo chown -R www-data:www-data wordpress

 


4th Step: Configuring Caddy to Serve the WordPress Website

Open the configuration file utilizing nano or your using any text editor.

$ sudo nano /etc/caddy/Caddyfile

Copy and paste the code given below into the record. You can expel any illustration arrangement from past instructional exercises.

/etc/caddy/Caddyfile

yourdomain.com {
   tls This email address is being protected from spambots. You need JavaScript enabled to view it.
   root /var/www/wordpress
   gzip
   fastcgi / /run/php/php7.0-fpm.sock php
   rewrite {
       if {path} not_match ^\/wp-admin
       to {path} {path}/ /index.php?_url={uri}
   }
}

After altering the configuration file appropriately, save the file & exit.

Restart Caddy to put the new configuration file settings into impact.

$ sudo systemctl restart caddy

5th Step: Configuring WordPress

WordPress comes with a GUI installation wizard to complete its setup, including interfacing with the database and setting up your first site.

In the event you visit your new WordPress instance in your web browser for the very first time, you will find a list of languages. Select the language you wish to use. In the next window, it explain the detail it requires about database. Hit Let’s go! And next screen will check for database connection informations. Fill the details as given below:

  • Database Name has to be wordpress, unless you adjusted it in 2nd Step.

  • Username has to be wordpressname, unless you adjusted it in 2nd Step.

  • Password  has to be the password you set for wordpressname in 2nd Step.

  • Database Host & Table Prefix must be left to their default values.

 

When you hit Submit, WordPress will check if the given elements are right. On the off chance that you get a mistake message, double check that you entered your database details elements effectively.

Once WordPress correctly connects to your database, you will see a message which starts with All right, sparky! You have done it through this part of the installation. WordPress can hereafter communicate with your database.