Setting up a Magento Host Server
This article is based on Magento’s own system requirements, which can be found here:
Magento requires Linux x86-64. I have found that CentOS is the most popular OS to run Magento on and has been the easiest for me to install, configure, and troubleshoot issues.
You can begin by downloading the ISO here and installing it on your server.
There are several different install types as you run through the install wizard. I prefer the Desktop Install. There are some cases where logging into the GUI is more beneficial than the command line such as searching through logfiles or config files. It is also time consuming to install the desktop components after the OS is installed.
Apache and NGINX are the two web servers that Magento recommends. The easier of the two as far as setting up and modifying is Apache. Once your OS is installed and setup you can install Apache by opening the terminal and using the yum command.
# yum install httpd
After Apache is installed you will need to make sure that the server will start automatically at startup. In terminal type:
# chkconfig httpd on
Now start the service
# service httpd start
You will also need to make sure that the iptables, (aka. Linux firewall) will allow traffic on port 80. If you have a perimeter firewall installed, it is not necessary to use iptables. In this case you should disable it:
#chkconfig iptables off
#service iptables stop
You can now setup the Virtual Host section in the Apache config file to point to your Magento installation directory. Locate the Apache config file in the default location of /etc/httpd/conf/http.conf and open it with your favorite editor.
Find the Virtual Host section at the bottom of the file. You can use the example in the file and fill in your own info for your server:
DocumentRoot /www/docs/dummy-host.example.com (Your Magento Install Folder)
ServerName dummy-host.example.com (Your Magento Website Domain Name)
CustomLog logs/dummy-host.example.com-access_log common
After editing this file you will need to restart Apache:
# service httpd restart
You should be able to test your config in a browser by adding a test.html page in the website root directory. If the test page displays without error, then download the magento install package and place it in this directory.
Magento requires either PHP 5.4 or PHP 5.5 for CE 1.9. Installing PHP could be a challenge if you do not have any prior experience. If you are comfortable with installing PHP by compiling it from the source, then you should have no troubles and can skip this section. However, if you are new to PHP it will be much easier to install it using the yum utility.
The tricky part is that your install of CentOS might not have the proper repos by default in order to install the PHP version you will need. To test this you can run this command in a shell
# yum list php
This will show you which version will be available through the yum repos. If it is less than PHP version 5.4 then you will need to complete the following two steps.
1) Install the following rpms
# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
If you are running CentOS 7 then use these instead
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# rpm -Uvh remi-release-7*.rpm epel-release-7*.rpm
2) Enable the Repo
Now you will need to browse to /etc/yum.repos.d and open the remi.repo in a text editor.
The first section is called [remi], make sure this is enabled. It should include this line:
The following sections are version specific for PHP. Find the version you want and again make sure you set:
Save and exit the editor.
Now when you run the following command you should see the PHP version available that you need:
# yum list php
You can now install php and the php modules required for Magento:
- SOAP (if Webservices API is to be used)
Magento recommends installing MySQL version 5.6. You might run into the same dilemma as with PHP because your CentOS release will not download the latest version through the default repos. In that case you will need to install the following rpm
# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
# rpm -ivh mysql-community-release-el6-5.noarch.
You will now be able to setup MySQL version 5.6
# yum install mysql-server
After it has been installed start the service and set it to start at boot:
# /etc/init.d/mysqld start
# chkconfig mysqld on
Now you can start the mysql setup wizard
This will run through the process of setting up a root user and access to your mysql server.
Now that the MySQL server is setup and running you can login and create a database and user for the Magento store:
# mysql –u root –p
mysql> create database magento_store;
mysql> create user magento_user;
mysql> grant all on magento_store.* to ‘magento_user’@’localhost’ identified by ‘your_password’;
Please make note of your database name, user, and password. You will need this during the Magento setup wizard.
You should also consider tuning the MySQL config to better server your Magento store. The following directives can be added to the my.cnf config file. These setting are based on a dedicated database server with a dual core processor and 2GB of RAM.
- query_cache_size = 512M
- query_cache_limit = 256M
- tmp_table_size = 256M
- key_buffer_size = 64M
- read_buffer_size = 128M
- read_rnd_buffer_size = 128M
- bulk_insert_buffer_size = 64M
- myisam_sort_buffer_size =
- myisam_max_sort_file_size = 128M
- myisam_max_extra_sort_file_size = 128M
- myisam_repair_threads = 2
- innodb_lock_wait_timeout = 120
- innodb_additional_mem_pool_size = 256M
- innodb_log_buffer_size = 128M
- innodb_log_file_size = 128M
- innodb_log_files_in_group = 2
- innodb_flush_log_at_trx_commit = 0
- innodb_buffer_pool_size = 512M
- innodb_data_home_dir = /var/lib/mysql/
- innodb_data_file_path = ibdata1:256M:autoextend
You will need to restart the MySQL service whenever changes are made to this file.
Congratulations, you have now setup a host server to run Magento. Please read the follow up article “Installing Magento” and start setting up your Magento store.