Magento is great eCommerce software now owned by eBay, Inc. With its opensource support base, it has become a very popular open-source application to run any types of eCommerce website.
If you’re looking for a great eCommerce application to sell your product and engage with your customers online, then you may want to install and use Magento.
Not only is it free to install and use, but it will help drive your cost down. No need to spend thousands on custom and proprietary software. This brief tutorial is going to show you how to easily install Magento application in CentOS 7 if you haven’t already done so.
Since Magento is like many other opensource scripts, it requires the LAMP stack. The LAMP stack is a collection of opensource applications that makes it possible run scripts written in PHP.
The LAMP stack includes, Apache, MySQL and PHP. L stands for Linux.
To get started with installing Magento in CentOS, first install the LAMP stack. To do that, continue with the steps below.
- Installing Apache2 Web server
The A in LAMP stands for Apache2. Apache2 is an opensource web server that allows anyone to use and serve web pages. To install Apache2 in CentOS, run the commands below.
sudo yum install httpd
After installing Apache2, run the commands below to start it up.
sudo systemctl start httpd.service
If you want Apache2 to automatically start up everytime you reboot the server, run the commands below
sudo systemctl enable httpd.service
After running the above commands, open Apache2 default configuration file and fine the lines between </Directory “/var/www/”> </Directory> and change the value to look like the block below.
sudo vi /etc/httpd/conf/httpd.conf
Options Indexes FollowSymLinks MultiViews
allow from all
After that, save the file and go to the step.
- Installing MySQL Database server
The next step is installing MySQL server. To do that, run the commands below
sudo yum install mariadb-server mariadb
After installing it, run the commands below to start up MySQL database server.
sudo systemctl start mariadb.service
To make sure MySQL always starts up everytime you reboot your server, run the commands below.
sudo systemctl enable mariadb.service
To secure and configure MySQL server, run the commands below.
When you run the above command, it will prompt you to create a new password for the database root user, and also to enable some secure options.
Always choose Y for yes when prompted.
Next, go and create a database for Magento. You’ll also need to create a database user for Magento. To do that, run the commands below to logon to the database as the root user.
mysql -u root -p
Next, run the SQL statement below to create a database called magento.
CREATE DATABASE magento;
Then run the commands below to create a new database user called magentouser..
CREATE USER magentouser@localhost;
Then grant all access and privileges to the new database to the database user by running the commands below.
GRANT ALL ON magento.* TO magentouser@localhost IDENTIFIED BY 'password_here';
Exit and you’re done. Next, continue below.
- Installing PHP5 and other PHP modules
The next step is installing PHP5 and other PHP modules. To do that run the commands below.
sudo yum install php php-gd php-mysql php-tidy php-xmlrpc php-common php-cli php-xml
Magento requires php-mcrypt, but that packages isn’t readily available in CentOS 7. You must add other repositories that contain the package in order to use.
To do that, run the commands below.
cd /tmp/ && wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-1.noarch.rpm
sudo yum install epel-release-7-1.noarch.rpm
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Then install php-mcrypt using the commands below
sudo yum install php-mcrypt
After install PHP, open its configuration file and increase the memory limit for PHP scripts to about 512MB. Run the commands below to open the file.
sudo vi /etc/php.ini
Then change the memory limit to 512MB, then save the file and exit.
memory_limit = 512M
- Downloading Magento Files
The next step is downloading Magento files. To do that, run the commands below.
cd /tmp/ && wget http://www.magentocommerce.com/downloads/assets/184.108.40.206/magento-220.127.116.11.zip
Next, run the commands below to unzip the downloaded file.
sudo unzip magento*.zip
Next, run the commands below to copy the extracted content to Apache default root directory.
sudo cp -rf magento/* /var/www/html/
Next, change the ownership of the files to the web server (Apacha2)
sudo chown -R apache:apache /var/www/html/
Next, change the permission of the files so that Magento can function correctly.
sudo chmod -R 755 /var/www/html/
Restart Apache2 web server
sudo systemctl restart httpd.service
Next, open the firewall to allow HTTP traffic.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Now open your browser and browse to your server. You should see Magento setup page.
If everything is done correctly, Magento should be installed.
If you run into Magento cannot write to /media/doenloadable and /app/etc folder, run the commands below to fix SELinux issues.
chcon -R -t httpd_sys_rw_content_t /var/www/html/
Continue with the database connection setup