Creating a Joomla website with a PostgreSQL database using the management console
To create an infrastructure for your Joomla website with a PostgreSQL database using the Yandex Cloud management console:
- Prepare your cloud.
- Create a VM for Joomla.
- Create a PostgreSQL DB cluster.
- Install Joomla and additional components.
- Configure the Apache2 web server.
- Configure Joomla.
- Upload the website files.
- Configure the DNS.
- Test the website.
If you no longer need the resources you created, delete them.
Prepare your cloud
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Make sure the selected folder contains a network with subnets in the ru-central1-a
, ru-central1-b
, and ru-central1-d
availability zones. To do this, select Virtual Private Cloud on the folder page. If the list contains a network, click its name to see the list of subnets. If the subnets or network you need are not listed, create them.
Required paid resources
The cost of hosting a Joomla-powered website includes:
- Fee for a continuously running VM (see Yandex Compute Cloud pricing).
- Fee for using a dynamic or static external IP address (see Yandex Virtual Private Cloud pricing).
- Fee for a PostgreSQL DB cluster (see Yandex Managed Service for PostgreSQL pricing).
- Fee for outgoing traffic from Yandex Cloud to the internet (see Compute Cloud pricing).
- Fee for public DNS queries and DNS zones if using Yandex Cloud DNS (see pricing Cloud DNS).
Create a VM for Joomla
-
On the folder page in the management console
, click Create resource and select Virtual machine instance. -
In the Name field, enter the VM name:
joomla-pg-tutorial-web
. -
Select an availability zone to place your VM in.
-
Under Boot disk image, go to the Marketplace tab and select a public CentOS Stream image.
-
Under Computing resources on the Custom tab:
- Choose a platform.
- Specify the required number of vCPUs and the amount of RAM.
This minimum configuration is enough for functional testing:
- Platform:
Intel Ice Lake
- vCPU:
2
- Guaranteed vCPU performance:
20%
- RAM:
1 GB
-
In Network settings, select the subnet to connect the VM to once it is created.
-
Under Access, specify the information required to access the instance:
-
Enter the username in the Login field.
-
In the SSH key field, paste the contents of the public key file.
You will need to create a key pair for the SSH connection yourself. To create keys, use third-party tools, such as
ssh-keygen
(on Linux or macOS) or PuTTYgen (on Windows).
-
-
Click Create VM.
It may take a few minutes to create a VM.
Once created, the VM is assigned an IP address and a host name (FQDN). This data can be used for SSH access.
Create a PostgreSQL DB cluster
- On the folder page, click Create resource and select PostgreSQL cluster.
- In the Cluster name field, enter the cluster name:
joomla-pg-tutorial-db-cluster
. - Under Host class, select the appropriate host class.
- Under Size of storage, enter
10 GB
. - Under Database, specify:
- DB name:
joomla-pg-tutorial-db
. - Username:
joomla
. - Password: Password you will use to access the DB.
- DB name:
- Under Network settings, select the network your VM is connected to.
- Under Hosts, add two more hosts in the other availability zones. When creating hosts, do not enable Public access for them.
- Click Create cluster.
Creating a DB cluster may take a few minutes.
Install Joomla and additional components
After the joomla-pg-tutorial-web
VM status changes to RUNNING
, do the following:
-
Under Network on the VM page in the management console
, find the VM public IP address. -
Connect to the VM via SSH. You can use the
ssh
utility in Linux or macOS, or PuTTY in Windows.The recommended authentication method when connecting over SSH is using a key pair. Make sure to configure the generated key pair so that the private key matches the public key sent to the VM.
-
Download and unpack the Joomla archive:
CentOS Streamsudo mkdir -p /var/www/html/ curl https://downloads.joomla.org/cms/joomla3/3-8-7/Joomla_3-8-7-Stable-Full_Package.tar.gz?format=gz -o Joomla_3-8-7-Stable-Full_Package.tar.gz -L sudo mv Joomla_3-8-7-Stable-Full_Package.tar.gz /var/www/html/ (cd /var/www/html/ && sudo tar -zxvf Joomla_3-8-7-Stable-Full_Package.tar.gz) sudo rm /var/www/html/Joomla_3-8-7-Stable-Full_Package.tar.gz sudo mv /var/www/html/htaccess.txt /var/www/html/.htaccess
-
Install additional components:
CentOS Streamsudo dnf install epel-release sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm sudo yum -y install --enablerepo remi-modular httpd php php-pgsql php php-common php-mbstring php-zip php-xml nano wget php-json sudo dnf module enable postgresql:13 sudo dnf install postgresql-server
-
Get and configure the SSL certificate:
CentOS Streamsudo mkdir ~apache/.postgresql sudo wget "https://crls.yandex.net/allCLCAs.pem" -O ~apache/.postgresql/root.crt sudo chmod 0600 ~apache/.postgresql/root.crt sudo chown -R apache:apache ~apache/.postgresql
Configure the Apache2 web server
-
Perform the basic configuration of Apache2:
CentOS Streamsudo chown -R apache /var/www/html/
-
Specify the virtual host settings in the Apache2 configuration file. You can edit files in the
nano
editor:CentOS Streamsudo nano /etc/httpd/conf.d/joomla.conf
Edit the file as follows:
<VirtualHost *:80 [::]:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/ <Directory /var/www/html/> DirectoryIndex index.php index.html DirectorySlash off RewriteEngine on RewriteBase / AllowOverride all </Directory> </VirtualHost>
-
Restart the web server:
CentOS Streamsudo service httpd restart
-
Change the settings:
CentOS Streamsudo restorecon -R /var/www/html sudo setsebool -P httpd_can_network_connect 1
Configure Joomla
Configure Joomla by following this guide
-
Get the addresses of the DB cluster hosts in the management console:
- Open the folder where the DB cluster was created and select Managed Service for PostgreSQL.
- Select the
joomla-pg-tutorial-db-cluster
cluster. - Go to the Hosts tab.
- In the Host FQDN field, copy the host addresses.
-
At the Database step, fill in the following fields in the Joomla web installer:
-
Database type:
PostgreSQL
. -
DB server name:
<address_of_host_1>,<address_of_host_2>,<address_of_host_3> port=6432 sslmode=verify-full target_session_attrs=read-write
-
Username:
joomla
. -
Password: Enter the DB user's password.
-
DB name:
joomla-pg-tutorial-db
.
-
-
For security reasons, Joomla may ask you to create or delete a special test file. On the VM, go to the
/var/www/html/installation
folder and create or delete the specified file there. -
Create an empty file named
configuration.php
to safe configuration and configure write permissions for the folder:sudo touch /var/www/html/configuration.php sudo chmod 655 /var/www/html/configuration.php sudo chown -R apache:apache /var/www/html/ sudo restorecon -R /var/www/html
-
After the installation is completed, delete the
installation
directory. This is a Joomla security requirement:sudo rm -rf /var/www/html/installation
Upload the website files
-
Under Network on the VM page in the management console
, find the VM public IP address. -
Connect to the VM via SSH.
-
Grant your user write access to the
/var/www/html
directory:sudo chown -R "$USER":apache /var/www/html
-
Upload the website files to the VM via SCP
.Linux/macOSWindowsUse the
scp
command-line utility:scp -r <path_to_file_directory> <VM_username>@<VM_IP_address>:/var/www/html
Use WinSCP
to copy the local file directory to/var/www/html
on the VM.
Configure the DNS
You need to link the domain name you want to use for your website to the created joomla-pg-tutorial-web
VM. You can use Yandex Cloud DNS to manage your domain.
The tutorial below describes configuring DNS for the example.com
domain name.
Add a DNS zone
To add a public DNS zone:
Add resource records
Create DNS records in the public zone:
- Under Network on the VM page in the management console
, find the VM's public IP address. - Create an A record:
- Open the Cloud DNS section of the folder containing the
example.com
DNS zone. - Select the
example.com
DNS zone from the list. - Click Create record.
- Set the record parameters:
- Name: Leave empty.
- Type: Keep
А
as the value. - Data: Enter your VM's public address.
- TTL (in seconds) (record time to live): Keep the default value.
- Click Create.
- Open the Cloud DNS section of the folder containing the
- Create a CNAME record:
- Select the
example.com
DNS zone from the list. - Click Create record.
- Set the record parameters:
- Name:
www
. - Type: Keep
CNAME
as the value. - Data: Enter
example.com
. - TTL (in seconds) (record time to live): Keep the default value.
- Name:
- Click Create.
- Select the
Delegate the domain name
Delegation is the transfer of authority from the registrar's servers to yours. For a domain, NS resource records are created (ns1.yandexcloud.net
and ns2.yandexcloud.net
).
To delegate a domain, specify its DNS servers in the registrar's account.
Delegation does not take effect immediately. It usually takes up to 24 hours (86,400 seconds) for internet service providers to update records. This depends on the TTL value which specifies how long domain records are cached.
You can check domain delegation using Whoisdig
utility:
dig +short NS example.com
Result:
ns2.yandexcloud.net.
ns1.yandexcloud.net.
Test the website
To check that the site is up, enter its IP address or domain name in your browser:
http://<public_IP_of_VM>
http://www.example.com
How to delete the resources you created
To stop paying for the resources you created:
- Delete the VM.
- Delete the static public IP if you reserved one.
- Delete the Managed Service for PostgreSQL cluster.
- If you used Cloud DNS, delete the DNS records and delete the DNS zone.