If you have a Magento installation on shared hosting, or simply want an easier way to manage your server, a good option is HestiaCP.
Before you begin
First, create a HestiaCP server (if you already have a server and a user account, you can skip these steps) and follow the article Getting started with HestiaCP.
Next, create a user in HestiaCP: go to the HestiaCP administration panel, sign in as admin, open Users, select Add User, and fill in the required information.
Now add the domain so you can import all the data. Click Add Web Domain and enter the domain you will use for Magento.
Migrating Magento content
Depending on the source server and your permissions, you have two options. The best option is to access the Magento server over SSH. If your hosting provider does not offer SSH access, you can use the alternative method below.
Using SSH
First, migrate the database using the following command. Replace the username and database name with your own:
# mysqldump -u usuario -p base_de_datos > archivo.sqlIf you do not know the database name, run show databases in mysql or check /rutamagento/app/etc/env.php. The value of dbname is the database name.
Once you have copied the database, transfer it between the servers with the following command (remember to check the paths in every command):
# scp archivo.sql root@ip:/home/usuario/archivo.sqlNext, go to the Magento directory and use rsync to transfer Magento. For HestiaCP, the command would look like this:
# rsync -avh /var/www/html/magento2/ root@ip:/home/usuario/web/dominio/public_html/Alternative method using FTP and phpMyAdmin
You can download the database through phpMyAdmin (some panels, such as plesk, or other hosting services may let you download it directly; what matters is downloading the database in the appropriate format).
In phpMyAdmin, select the database you want to download. Open the Exporta (export in English) tab, enter a name, select SQL as the format, and click Exporta. The database will then be downloaded to your PC:
To download Magento, you can use FTP software such as FileZilla. Create a folder on your local PC and save the files there.
You do not need to install FTP to upload the content to HestiaCP. You can use SFTP, which FileZilla supports.
Open the Site Manager in the upper-right corner of FileZilla:
Change the protocol, enter the IP address and the root user, and then connect:
Once connected, upload the Magento content to /home/usuario/web/dominio/public_html:
You can use FileZilla to place the SQL file directly in /home/migracion.
Importing the database
To make the database appear in the HestiaCP panel, create it from the panel. If you create it in mysql with create database, it will work but will not appear in the panel. You can create it under DB for the user.
Once you have created the database, access HestiaCP over SSH and go to the directory containing the database file. In our case, that is:
# cd /home/Migracion/Now you can import the database:
# mysql -u root -p nombre_BD < archivo.sqlSetting permissions
Go to the domain directory in HestiaCP:
# cd /home/admin/web/tudominio/public_htmlThen assign ownership to the user and set the file permissions:
# chown usuario:usuario -R *
# find . -type f -exec chmod 664 {} \;
# find . -type d -exec chmod 775 {} \;
# chmod u+x bin/magento
Local Magento configuration
To let Magento connect to the database, edit app/etc/env.php and update the database credentials:
# nano app/etc/env.phpEnter the values inside the quotation marks after the arrows:
'dbname' => 'Nombre_BBDD',
'username' => 'Usuario_BBDD',
'password' => 'Contraseña',Next, check the Magento version and the PHP version it requires. To change the PHP version in HestiaCP, go to the user account that owns the domain, edit the domain, and open Advanced Options. Select the version you need there. You can enable older PHP versions in the server settings in the same panel:
Magento 2 should now be working correctly on HestiaCP.
If you want to change the Magento URL, follow this article: Changing the Magento 2 URL
Troubleshooting:
If Magento reports a cache error or does not locate some items correctly, you can use the following commands (use the PHP version required by your Magento installation):
# php7.4 bin/magento setup:upgrade
# php7.4 bin/magento setup:static-content:deploy -f
# php7.4 bin/magento cache:flush
# php7.4 bin/magento cache:cleanDepending on your installation, you may need to install elasticsearch. You can use the commands below. The required version depends on your Magento version; check the requirements at this link, and replace 7.6.1 at the end of the wget command with the version you need to download it:
# cd /opt
# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-amd64.deb
# dpkg -i elasticsearch-7.6.1-amd64.deb
# systemctl start elasticsearchIf you have any questions about this or anything else related to your Clouding servers, feel free to email soporte@clouding.io We’re here to help with whatever you need. Get in touch!