TYPO3 is a great solution for websites of any size, from small to enterprise. With this CMS, you can build and manage multilingual enterprise sites for large corporations. These websites can scale and adapt to any future needs. And with Jelastic, you can make your TYPO3 site not only very flexible and accessible, but also stable and high performing. This can be gained by setting up a high-available cluster with two Apache application servers, NGINX balancer, Memcached instance and two replicated MySQL databases.
The Memcached node is used for storing the sessions of the Apache servers. The sessions are backed up, and if any of the Apache servers fail, the second one will get the sessions from Memcached for further session serving. The NGINX balancer distributes the traffic inside the cluster. In addition, the MySQL database master-slave replication improves the performance, the security of the data and the fail-over capabilities of your environment.
And now, let’s go step-by-step and configure your highly-available clustered TYPO3 application.
A. Deploy TYPO3 Application
Firstly, let’s create the required Jelastic environment and deploy TYPO3 application.
1. Sign-up for a Jelastic account (if you haven’t done this before) or log into your Jelastic account.
2. Click Create environment.
3. Pick Apache application server, MySQL database and Memcached. Specify your cloudlet limits and name your environment (for example, typo-cluster). Click Create.
4. Wait just a moment for your environment to be created.
5. Visit the official TYPO3 web-site to download the latest TYPO3 version as a zip package.
6. Using the Deployment manager, upload the package you’ve just downloaded.
7. Once the package is in Jelastic, deploy it to the environment you have just created.
B. Configure PHP Sessions Clustering
The high availability of your PHP application can be achieved by implementing PHP sessions clustering in the cloud. We are going to use Memcached to successfully handle application server failover.
1. Click the Config button next to the Apache node. In the Config Manager, open the etc > php.ini file and enable Memcached module by adding the next string:
2. To activate the support of the sessions, edit the Session block in php.ini config file by adding the following lines:
session.save_handler = memcached
session.save_path = “< server >:11211”
Note: instead of < server > you should paste the Memcached IP. To find it, click the Info button next to the Memcached node in your environment.
3. Apply the changes by clicking the Save button and Restart Apache server.
С. Database Configuration
Let’s configure MySQL master-slave replication in order to protect your application from downtime or data loss.
MySQL in your environment with TYPO3 deployed will be used as a master database. For the slave database, you need to create a separate environment.
Navigate to the Jelastic dashboard and create your environment with MySQL node, which is going to be used as a slave database. Name your environment (e.g. slave-db) and click Create.
And now, let’s configure each database separately:
As we’ve mentioned above, we use MySQL in the environment with app deployed (i.e. typo-cluster) as our master database.
1. Click Config button for your master database.
2. Navigate to etc > my.cnf file and set the following properties as it is shown below (you just need to uncomment two lines):
server-id = 1
log-bin = mysql-bin
We use binlog-format=mixed to allow a replication of operations with foreign keys.
3. Save the changes and Restart MySQL in order to apply new configuration parameters.
4. Click the Open in browser button for master MySQL. Log in using credentials you have received via email when creating the environment.
5. Navigate to the Replication tab and click on Add slave replication user.
6. Specify the name and password for your slave replication user and click Go.
Your slave user is successfully created.
And now, let’s connect the master database with slave MySQL.
1. Click the Config button for your slave database.
2. Navigate to my.cnf file and add the following strings:
server-id = 2
slave-skip-errors = all
We allow our slave base to skip all errors from master (slave-skip-errors = all) in order not to stop normal slave operation, in case of errors on the master base.
Skipping this step is not recommended at the development stage, in order to locate bugs, etc. However here, we focus on production, when your code has already been tested. Any error on the master’s side can stop slave or lead to its unsynchronization. In this case, the error may be even innocuous. Some minor errors will probably occur on production, so the replication can be stopped because of small errors.
3. Save the changes and Restart your slave database server in order to apply the new configuration parameters.
4. Navigate to phpMyAdmin using the credentials which Jelastic sent you when you created the environment for your slave database.
5. Go to the Replication tab and click configure for Slave replication.
6. Configure your master server (enter the name, password and host of your slave replication user).
Now your master server is configured.
7. Check the slave status table to ensure that everything is ok.
The replication is configured and all the data is synchronized between the master and slave database.
D. TYPO3 Installation
Now we can complete TYPO3 installation.
1. Navigate to the Jelastic dashboard and click the Open in browser button next to your TYPO3 environment. The installation will be started. Click Continue.
2. In the Connect to your database host window:
- choose the MySQL/MySQLi driver
- fill in the Username and Password fields with the credentials to your master database (you’ve received them via email when creating the environment)
- put the database server address in the Host field
3. At the Select database step, create a new database by entering a name for your TYPO3 database (e.g. typo_db). Click Continue.
4. In the next window choose the Introduction package. Click Continue.
5. The installation will be started. Wait a few minutes for its completion.
6. Finally, enter the password for access to the TYPO3 Admin Panel and choose the color of your TYPO3 main page.
Congratulations! TYPO3 is installed.
E. Cluster Configuration
After TYPO3 installation has been successfully completed, we can proceed to configuration of a highly-available cluster.
1. Navigate to the Jelastic dashboard and click Change environment topology button next to the environment with your TYPO3 app.
2. Add one more Apache application server by clicking + button (circled in the image below). NGINX-balancer will be added automatically. Click Apply.
Now, you have your own highly reliable and scalable clustered environment, hosted with TYPO3. Click Open in browser and start using your TYPO3 application.
That’s all you have to do to get a highly reliable and scalable clustered TYPO3 application in the cloud! Do you have a different experience with TYPO3 clustering? Please share it with us in the comments below.