How to Install Magento 2.4 in CWP – Control Web Panel

In this tutorial we’ll learn how to install magento 2.4.x in CWP control panel. At the time of writing this tutorial CWP 7 (centos 7) have older version of MySQL server i.e. MariaDB 10.2 which is not supported by Magento 2.4.x. With recent CWP installation MariaDB 10.4 IS ALREADY THERE.

CWP on centos 8 is fully supported by magento since it have Mariadb 10.4. Without wasting time lets get started.

Centos 7 Only :-

if you’re using Centos 8 CWP proceed with steps from Elastic search installation below.

Remove Mariadb 10.1 or10.2 and update Mariadb 10.4:

systemctl stop mariadb mysql mysqld

Now edit/create the file run the commands one by one :

ensure to remove the content of /etc/yum.repos.d/mariadb.repo

> /etc/yum.repos.d/mariadb.repo
nano /etc/yum.repos.d/mariadb.repo

then paste this lines and save it (Remove any entries from mariadb.repo before pasting below if any):

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Now remove Mariadb 10.1, 10.2 and install 10.4 :

yum remove MariaDB-server MariaDB-client -y && yum install MariaDB-server MariaDB-client -y 

Now update the server :

yum update -y

Next we’ll install Elastic search which is required by Magento 2.4.xx

For version Elastic Search 7 Centos 7 and Centos 8 :

cd /usr/local/src
rm -rf elasticsearch*
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.8-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.8-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-7.17.8-x86_64.rpm.sha512
rpm --install elasticsearch-7.17.8-x86_64.rpm

For version Elastic Search 8.5 Centos 7 and Centos 8:

cd /usr/local/src
rm -rf elasticsearch*
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.5.3-x86_64.rpm wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.5.3-x86_64.rpm.sha512 shasum -a 512 -c elasticsearch-8.5.3-x86_64.rpm.sha512 rpm --install elasticsearch-8.5.3-x86_64.rpm

After it is installed you need to start the service and enable it to start the service on boot startup :

systemctl enable elasticsearch.service
systemctl start elasticsearch.service

You can test the service active and running via the status command :

systemctl status elasticsearch.service

Next we’ll Download Opensource Magento 2.4.x :

you can follow your own way of installing Magento 2.4.x or follow this :

Please note here “user” is the username of your user account in below commands.

Download Magento :

cd /home/user/public_html
wget -c https://github.com/magento/magento2/archive/refs/tags/2.4.5-p1.zip -O magento24.zip
unzip magento24.zip
rsync -av magento2-2*/ . && rm -rf magento2-2*

Now remove the “Options” config from .htaccess else you’ll get 500 Internal server Error

cd /home/user/public_html
sed -e '/Options/ s/^#*/#/' -i .htaccess pub/.htaccess

Fix the user file and folder permission :

cd /home/user/public_html
chown -R user:user *

Now install composer :

Use this tutorial to install composer : How to Install Composer in CWP

First you need to enabled full shell access for the user from cwp admin  >> Security >> Shell access and enable full shell access for the user now you need to login in ssh via user login details.

go to public_html dir or where magento root dir is :

cd /home/user/public_html

Now run composer install command to install required magento dependencies:

If you’re using php switcher version 7.3,7.4,8.0 or 8.1 run below command

composer install

when running php selector 7.3,7.4,8.0 or 8.1 run below command respectively :

/opt/alt/php73/usr/bin/php /usr/local/bin/composer install
/opt/alt/php74/usr/bin/php /usr/local/bin/composer install
/opt/alt/php80/usr/bin/php /usr/local/bin/composer install
/opt/alt/php81/usr/bin/php /usr/local/bin/composer install

when running php fpm 7.3,7.4,8.0 or 8.1 run below command respectively :

/opt/alt/php-fpm73/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm74/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm80/usr/bin/php /usr/local/bin/composer install
/opt/alt/php-fpm81/usr/bin/php /usr/local/bin/composer install

Now go to the domain url and check this page is showing up :

Thats means everything is up and running and we can proceed with next step :

Next Install Magento via Command line :

Ensure you’re still login as user via ssh and in the magento installation dir, now run below command to install magento ensure you created DB, user db and user DB password created from cwp and replaced in below command :

/opt/alt/php-fpm74/usr/bin/php bin/magento setup:install --base-url="https://www.domainname.tld/" --db-host="localhost" --db-name="magento_db" --db-user="magento_db" --db-password="db_password" --admin-firstname="admin" --admin-lastname="admin" --admin-email="youremail@domain.tld" --admin-user="admin" --admin-password="admin_pass" --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="admin"   

Change php path:

#for php-fpm selector 7.4 :
/opt/alt/php-fpm74/usr/bin/php
#for php selector 7.4 :
/opt/alt/php74/usr/bin/php
#for php switcher 7.4 :
/usr/local/bin/php

or for 8.1 : 

#for php-fpm selector 8.1 :
/opt/alt/php-fpm81/usr/bin/php
#for php selector 8.1 :
/opt/alt/php81/usr/bin/php
#for php switcher 8.1 :
/usr/local/bin/php

Change magento site domain url :

--base-url="https://www.domainname.tld/"

Replace the DB details :

--db-name="magento_db" --db-user="magento_db" --db-password="db_password"

Replace admin details for magento :

--admin-firstname="admin" --admin-lastname="admin" --admin-email="youremail@domain.tld" --admin-user="admin" --admin-password="admin_pass"

After that you can see installation is started and after the end you can login to admin and do settings and create magento powered site via gui.

Troubleshoot :

if you not able to login to admin and want to reset the password for magento admin, you need to login to phpmyadmin with magento user db and password and run this command to reset the Magento admin password :

go to SQL tab after selecting the correct db and run this command :

UPDATE admin_user SET password = CONCAT(SHA2('xxxxxxxYourNewPassword', 256), ':xxxxxxx:1') WHERE username = 'admin';

replace only “YourNewPassword” with your new password and run the sql command by clicking GO button.

If you’ve any question and want me to update the post comment below or for more advanced support use our support forum https://forum.mysterydata.com/

Back to top button