How to Install ProcessWire CMS on Debian 9, Part 2: Installing ProcessWire
We continue our look at setting up a CMS on Debian 9 by showing how to configure the domain and secure it using Let's Encrypt SSL certificates.
Join the DZone community and get the full member experience.Join For Free
This is the second part of my tutorial about how to install ProcessWire CMS on Debian 9.
In the previous tutorial, we set up a LAMP stack and other required packages for ProcessWire. In the second part of the tutorial, we will install ProcessWire on our Alibaba Cloud Elastic Compute Service (ECS) instance.
But before doing that, we will need to configure our domain. We will also secure the domain with Let's Encrypt (SSL). After that, we will create a database and then finally install ProcessWire CMS on our ECS instance.
If you bought your domain from Alibaba Cloud, it will automatically setup DNS records. You will only need to add a domain to the Alibaba Cloud DNS. In case, if you have already registered a domain from any other registrar, you will need to add that domain in Alibaba Cloud DNS and update its nameserver records on your registrar account. Once your DNS records are propagated, check them at intodns.com.
To setup a domain name bought from a third-party, follow the steps below:
- Login to your Alibaba Cloud account and click on Alibaba Cloud DNS (available in left sidebar of your dashboard). Click Add Domain Name.
- You will see a popup form. Now, type your complete domain name with TLD (in my case imarslan.com) and click Confirm.
- Now your domain has been added to Alibaba Cloud DNS. You need to configure our domain. Click on Configure, right below the Add Domain Name button
- If you bought a domain from Alibaba Cloud, your all nameservers would be configured already. If you bought it from some other registrar, Alibaba Cloud DNS configuration page will detect it and provide your information for changing nameservers.
- Now add A record and its value will be the IP address of your ECS instance as shown below.
- You can skip this step if you have bought a domain from Alibaba Cloud. If you have bought a domain from a third-party, you will need to visit the domain registrar's website. The steps differ according to the registrar.
- Now go back to Alibaba Cloud DNS page and click Add Record button to add records, after adding save them. To get records details, you can use intodns.com.
Create a Virtual Host
- Once your nameservers are updated, you can set up a virtual host to point to your domain on your Alibaba Cloud ECS IP Address. To set up a virtual host on your ECS, execute the following command. Replace imarslan.com with your domain name.
# sudo nano /etc/apache2/sites-available/imarslan.com.conf
- Write or copy-and-paste the following text in the opened file. Replace imarslan.com andwww.imarslan.com with your own domain name and firstname.lastname@example.org with your email address.
After adding the text, use Ctrl + X, then press 'Y', then hit Enter key to save the file
<VirtualHost *:80> # Admin email, Server Name (domain name), and any aliases ServerAdmin email@example.com ServerName imarslan.com ServerAlias www.imarslan.com # Index file and Document Root (where the public files are located) DirectoryIndex index.html index.php DocumentRoot /var/www/html/ # Log file locations LogLevel warn ErrorLog /var/www/html/error.log CustomLog /var/www/html/access.log combined </VirtualHost>
- Now restart your Apache Server to load the changes by using the following command
# sudo systemctl restart apache2
- After setting up a virtual host, you can access your website by accessing your domain. In my case, I used www.imarslan.com to access my website. Note: The above configurations of a virtual host are for HTTP protocol. To set up HTTPS protocol, you will have to install SSL. To install SSL and allow HTTPS to provide a secured experience to your users, you will need to install Let's Encrypt. Let's Encrypt will provide you free SSL for your domain.
Configure Let's Encrypt SSL
- For installation of Let's Encrypt SSL, you will have to stop your Apache Server. Use the command below to stop the Apache server. Remember, Certbot uses port 80 to get an SSL certificate. The Apache server uses same port 80. So, to avoid conflict, the Apache server must be stopped until you get an SSL certificate issued.
# sudo systemctl stop apache2
- To install the backports repository command, execute the following command:
# echo 'deb http://ftp.debian.org/debian jessie-backp orts main' | sudo tee /etc/apt/sources.list.d/backports.list
- Now you will need to update your package list by executing the command below to get the new repository's information.
# sudo apt-get update
- Now execute the following command to install Certbot.
# sudo apt-get install python-certbot-apache -t jessie-backportsYou will be prompted whether you want to continue or not. Type 'Y' and hit Enter.
- Now create your SSL certificate. Let's Encrypt performs challenges for Domain Validation on the basis of which Certificate Authority (CA) will authenticate your domain. On validation, you will be issued a SSL certificate by CA. To create SSL certificate for your domain using Let's Encrypt, use the following command:
Note: Remember to replace imarslan.com with your own domain name.
# sudo certbot --authenticator standalone --installer apache -d imarslan.com -d www.imarslan.com \ --pre-hook "systemctl stop apache2" \ --post-hook "systemctl start apache2"
- Now you will have to select whether you would like to redirect all of your traffic to HTTPS or HTTP by default. I will choose option 2 because I want to redirect all of the traffic to my domain to HTTPS. For this, I will type 2 and hit Enter.
- Now when you have to set up a virtual host again, to make it compatible with HTTPS, you will also want to stop people accessing your website without SSL. For this purpose, you may enforce SSL and every user will be redirected to a secured website via HTTPS. For this purpose, execute the command below:
# sudo nano /etc/apache2/sites-available/imarslan.com.conf
- After executing the above command, a file will be opened. Copy the text below to this opened file.
Replace imarslan.com with your domain name. This above code will force SSL and all of the traffic will be redirected to HTTPS version of the website.
<IfModule mod_ssl.c> <VirtualHost *:443> ServerName imarslan.com ServerAdmin firstname.lastname@example.org ServerAlias www.imarslan.com SSLEngine on SSLCertificateFile /etc/letsencrypt/live/imarslan.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/imarslan.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/imarslan.com/chain.pem DirectoryIndex index.html index.php DocumentRoot /var/www/html/ # Log file locations LogLevel warn ErrorLog /var/www/html/error.log CustomLog /var/www/html/access.log combined </VirtualHost> </IfModule> <VirtualHost *:80> # Admin email, Server Name (domain name), and any aliases ServerAdmin email@example.com ServerName imarslan.com ServerAlias www.imarslan.com Redirect permanent / https://www.imarslan.com/ # Log file locations LogLevel warn ErrorLog /var/www/html/error.log CustomLog /var/www/html/access.log combined </VirtualHost>
- Use a MySQL shell to log in as a root user and execute the following command:
# sudo mysql -u root -p
- Now the command prompt will ask you to enter a password for the user 'root'. Enter the password and hit the enter key; you will be prompted to input a MariaDB command prompt.
- To create the database and user for this database for your ProcessWire CMS, use the following query:
where pw_db can be changed to your desired name.
CREATE DATABASE pw_db CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 'pw_db'@'localhost' IDENTIFIED BY 'Password'; GRANT ALL PRIVILEGES ON pw_db.* TO 'pw_db'@'localhost'; FLUSH PRIVILEGES; EXIT;
Install ProcessWire CMS Files
- First of all, disable default Apache virtual host by executing the following command:
# sudo a2dissite *default
- Now enable your website by executing the following command.
# sudo a2ensite imarslan.com.conf
- Execute the following command to reload your Apache server, otherwise, your domain will keep showing default page of apache host.
# sudo systemctl reload apache2
- To begin installation of ProcessWire CMS, navigate to directory cd /var/www/html/ because, in the Apache Server, we use this as web-directory. Note: In this case, if you get any errors like 'No such directory or file,' then create an HTML directory. To do so, navigate to cd /var/www and execute the following command to create an HTML directory, type in
cd htmland hit enter.
# sudo mkdir html
- Execute the following command to see list of files in /var/www/html
# ls -liYou will see the files shown in the above screenshot. You will need to remove default index.html page ofApache.
- To remove the index.html file from this folder, execute the following command:
# sudo rm -r index.html
- Now use the following command to get ProcessWire CMS package for installation. The following command will fetch the latest version of ProcessWire CMS from its official website.
# sudo wget https://github.com/processwire/processwire/archive/master.zip -O ProcessWire.zip
- Now you will have to list the files in the directory to see files and folders. To list the files in the current directory, use the command:
# ls -li
- The downloaded instance of ProcessWire CMS is saved in a compressed form as ProcessWire.zip. Now you will have to unzip the compressed zip folder as listed when the
ls -lacommand is executed. To do so, use the command:
# sudo unzip ProcessWire.zip
- Now use the following command to move files from extracted folder to your root directory.
# sudo mv ./processwire-master/* /var/www/html
- Change the owner of files to avoid permissions issues. This will allow apache to access files of CMS without any issue. Execute the following command:
# sudo chown -R www-data:www-data *
- After performing the above steps, restart Apache to reload the latest configurations using the command:
# sudo systemctl restart apache2
Accessing ProcessWire CMS
Congratulations! Now it's time to access your ProcessWire CMS. Just open the website in your browser. In my case, I will open www.imarslan.com. Now we will proceed towards completion of installation of ProcessWire CMS which will involve different settings.
Complete the Installation of ProcessWire CMS
- Click on the Get Started button to proceed towards the installation process.
- Select one option from Installation Profile and click Continue button.
1.Default (Beginner Edition) 2.Default (Intermediate Edition) 3.Multi-Language 4. Blank 5. Classic
- From the list below, confirm whether your Alibaba Cloud ECS configurations are compatible with your ProcessWire CMS. Click Continue to Next Step to proceed to the next step.
- Now you will need to setup configure your database connection to connect your ProcessWire CMS. Add your DB Name, DB User, DB Pass, leave DB Host, and DB Port as it is if you have Alibaba Cloud ECS default settings for host and port. Select DB Engine of your choice, in my case I used InnoDB and chose characterset.
- Now select your preferred time zone from the drop-down list.
- Setup file permissions. The file permission for directories should be 755 and for files in directories should be 644.
- Next comes the whitelist host. You can also leave it blank. Then click Continue.
- Now setup your admin panel URL.
- Now, set up login credentials for Admin Panel and click Continue button to proceed next.
That's it! You have successfully installed ProcessWire CMS on Alibaba Cloud ECS.
You can access your admin panel by using the admin panel URL you have configured. If you have followed my values, you can access using https://www.yourdomain.com/admin . To view your website, you can simply access it through https://www.yourdomain.com.
Opinions expressed by DZone contributors are their own.