Install Joomla on Ubuntu with Vultr Managed Database
Joomla is a popular content management system. It runs on PHP programming language and uses the MySQL database to manage data. Joomla needs services like Apache/Nginx, MySQL and PHP on the server to function correctly.
In this tutorial, You will learn how to install Joomla on a cloud instance with Vultr managed database. In this configuration, you have a Vultr VM instance as an application server, and Vultr managed database as a database server.
What is Managed Database?
Managed Database is a virtual machine with a pre-installed database management system. You can start hosting databases as soon as the instance is ready. In Vultr, You can create MySQL, Postgres and Redis Database servers.
Prerequisites
For this setup, You need two instances.
You will use a VM instance to host the Joomla code and managed MySQL database to manage the data.
Configure the Application Server
On the VM instance, You have to install Apache and PHP. You can also install other services according to your requirements on this VM instance.
If you have a fresh VM instance, Execute the following commands to update the repositories and install the updates on the server.
$ sudo apt-get update
$ sudo apt-get upgrade -y
It may take a few minutes to install the updates.
Install Apache
Execute the following command to install Apache on the Ubuntu server.
$ sudo apt-get install apache2 -y
Verify the installation by visiting the public IPv4 address of your VM instance in the browser.
Note: If you cannot access the default Apache page, check if the firewall allows incoming requests on ports 80 and 443.
If you see the default Apache page, the installation was successful.
Install PHP
To install PHP on the VM instance, Execute the following commands.
$ sudo apt-get install php -y
It will take a few minutes to install PHP on your VM instance. Once installed, execute the following command to install the required PHP libraries.
$ sudo apt-get install php-mysql php-json php-xml php-json php-mbstring php-intl php-zip
After installing the libraries, execute the following command to restart the Apache server to apply all the changes.
$ sudo service apache2 restart
To test PHP installation, execute the following command.
$ echo "<?php phpinfo(); >" > /var/www/html/test.php
This command will create a test PHP file containing information about the PHP installation. Access this file at the following address in your browser.
http://PUBLIC_IPv4_ADDRESS/test.php
Apache and PHP are successfully installed if you can see the PHP information on the page.
Download and Host Joomla
Next, you must download and move the Joomla code to the server's document root. The default document root for the Apache web server is /var/www/html
.
Execute the following commands to navigate to the server's document root and remove all files.
$ cd /var/www/html
$ rm -rf * .*
Execute the following commands to download and extract Joomla in the document root.
$ wget https://downloads.joomla.org/cms/joomla4/4-2-5/Joomla_4-2-5-Stable-Full_Package.zip
$ unzip Joomla_4-2-5-Stable-Full_Package.zip
If you want to install any other version of Joomla, You can replace the version number in the download URL.
Execute the following command to delete the unwanted zip file.
$ rm Joomla_4-2-5-Stable-Full_Package.zip
Execute the following command to set the file permissions correctly.
$ sudo chown -R www-data:www-data /var/www/html
The configuration of the application server is complete. Now you have to set up the Managed database and connect it with Joomla.
To verify the installation, visit the Public IPv4 address of your server in a browser. If everything is working correctly, You should see the Joomla installation page.
Keep the tab open, as you must create the Vultr Managed database first to continue the installation. So, set up Vultr's Managed database and then complete the installation.
Create Vultr Managed Database (MySQL)
Go to the Vultr dashboard and click the Databases -> Add Managed Database. You can also select the same option from the "+" button on the Vultr dashboard.
Select the options just like the following.
- Choose Database Engine: MySQL
- Server Configuration: Based on your requirements. Set the number of replica nodes to 0 if you do not want replica servers.
- Server Location: Select the closest location to your application server. The best practice is selecting the same location for both servers.
- Label: The label is for identification. Select any name you like.
After filling up the information, click on the Deploy Now button to create a managed Vultr database.
Once the Managed database is up and running, You can create a database and a user for the Joomla installation.
To do that, Execute the following command to connect with Managed Vultr database from the terminal or Putty.
$ mysql -uvultradmin --host='vultr-prod-1c5f5b68-2319-489e-9178-e32235ac0edf-vultr-prod-7747.vultrdb.com' --port=16751 -p
It will prompt you for the password; enter the password for the vultradmin user. You can find the host, port, username and password of the Managed Database instance from the Vultr dashboard.
After connecting with the MySQL server, execute the following commands to create a new user and a database.
> CREATE DATABASE DATABASE_NAME;
> CREATE USER 'USERNAME'@'IP_ADDRESS_OF_APP_SERVER' IDENTIFIED BY 'STRONG_PASSWORD';
> GRANT ALL PRIVILEGES ON DATABASE_NAME.* TO 'USERNAME'@'IP_ADDRESS_OF_APP_SERVER';
> FLUSH PRIVILEGES;
> EXIT;
Note: Replace IP_ADDRESS_OF_APP_SERVER with the IP address of your VM instance you are using as an application server. Note all this information as you will use it to connect Joomla with the database.
You also have to disable the required primary key SQL mode. To do that, go to Vultr, Click Databases, Go to the Settings tab, and then click the SQL Modes option.
In this section, you will see a switch with a Require Primary Key
label. Turn off the switch and click Apply Changes.
The database server configuration is complete.
Install Joomla from the Web
To install Joomla from the web, Access the Public IPv4 address of your application server in the browser.
You will see the Joomla installation wizard. It is a 3-step process.
In the first two steps, You have to select the site name, language and admin login information. The third step is database connectivity.
Configure Database Connectivity
In the last step, we will connect the Joomla installation with Managed Vultr Database. Fill up the form with the following information.
Select the Database type: MySQL (PDO)
Enter the hostname: Copy the host and port of your Managed Vultr Database and paste it here. Separate the host and port with ":". Just like the following example.
Example: vultr-prod-1c5f5b68-2319-489e-9178-e32235ac0edf-vultr-prod-7747.vultrdb.com:16751
Username: Enter the username you have set while creating a database.
Password: Enter the password you have set while creating a database.
Enter the Database name: Enter the name of the database we have created in the managed Vultr database instance.
Enter a table prefix: Set the table prefix according to your requirements. You can also use the default table prefix as is.
After filling up the form, click the Install Joomla button given at the end of the form to start the verification process.
Verify the Ownership
As soon as you click the Install Joomla button, You will see the following notice.
To confirm that you are the owner of this website please delete the file named "_JoomlaD5nPoDJ8hfaiTq7Iblfc2.txt" that has been created in the "installation" folder of your Joomla site. Then select "Install Joomla" to continue.
As a result, It will create a file in the Application server to verify that you are the website owner. Go to the installation folder in the Document root and delete the newly created file. Or execute the following command on the application server.
$ sudo rm /var/www/html/installation/FILE_NAME.txt
After deleting the file, click the Install Joomla button at the bottom of the page to start the installation. The installation may take several minutes as Joomla will create many tables in the database and the tables with default data.
Once the installation is complete, You can access your Joomla website on the public IPv4 address of the server.
Connecting a Domain name
Joomla is ready to host content. But you can only access it on the IP address right now. If you want to connect a domain name, You have to add the domain name to the Apache virtual host file.
Execute the following command to open the default apache virtual host file in the Nano editor.
$ sudo nano /etc/apache2/sites-available/000-default.conf
Find a line with the ServerName
directive.
...
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
...
Uncomment the line containing ServerName
directive and replace www.example.com
with your actual domain name. The updated line should look like this.
...
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.mydomain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
...
Go to the DNS section in Vultr and add a new domain. You can select a VM instance while adding a domain name. Select the correct VM instance.
Now you can access the Joomla website with your domain name. Also, remember to update the domain name in your Joomla installation from the admin area.
Conclusion
You have a normal functioning Joomla website with one difference. Its database server is a standalone virtual machine that is a fully managed database management system. You can scale both instances separately according to the computing requirements. And, It is also effective to monitor the application server and database server individually.