This guide is based on Linux mint, Ubuntu based linux distribution. You can download it from here. It will help you setup apache environment in your home folder.
You will need to install several things. First of them is Apache itself. From terminal run:
sudo apt-get install apache2
After that, you will need PHP:
sudo apt-get install libapache2-mod-suphp libapache2-mod-php5 suphp-common php5-cli php5
And finally MySQL. Default is 5.5., but we will install newer version here. During installation process, you will be required to set root password for MySQL.
sudo apt-get install mysql-server-5.6 mysql-client-5.6
For Magento, we will also need some extra PHP modules:
sudo apt-get install php5-mysql php5-gd php5-mcrypt php5-curl
sudo php5enmod mcrypt
And to make our lives easier, we will finally install PHPMyAdmin. When prompted, select reconfigure with apache2. You will also be prompted to setup password for it.
sudo apt-get isntall phpmyadmin
Now that all the packages are installed, we will need to configure them to work correctly. This will show you only how to configure things. If you want to know why are they configured that way, refer to this article.
NOTE: In examples bellow, my system user is inchoo, and I will be creating local domain called magento.loc, with files being installed in public_html/magento.loc in my home folder. Please adjust according to your needs.
- Edit /etc/hosts file, and add following to the list
127.0.0.1 magento.loc
- Create folder that will contain you files:
mkdir -p ~/public_html/magento.loc
- Adjust suPHP configuration: Open the file /etc/suphp/suphp.conf in editor of your choice(as root user; eg. sudo gedit), and adjust following values to match:
allow_file_group_writeable=true
allow_directory_group_writeable=true
check_vhost_docroot=false
umask=0002
min_uid=33
min_gid=33
- Add user www-data to your user group.. In my case, this is inchoo, so:
sudo usermod -a -G www-data inchoo
- Create virtual host for your domain. In my case this is magento.loc in public_html/magento.loc in my home folder. Add file magento.loc.conf to folder /etc/apache2/sites-available with following content:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName magento.loc
DocumentRoot /home/inchoo/public_html/magento.loc
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/inchoo/public_html/magento.loc>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- Since local files are managed by SuPHP, we need to configure mod_php to handle everything in usr/share path(eg. PHPMyAdmin). Open /etc/apache2/mods-available/php5.conf as root in your favorite editor (eg. sudo gedit), and replace content with following:
<IfModule mod_php5.c>
<Directory /usr/share>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</Directory>
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
Require all denied
</FilesMatch>
</IfModule>
- Once the configuration is created, enable site and restart Apache server:
sudo ln -s /etc/apache2/sites-available/magento.loc.conf /etc/apache2/sites-enabled/magento.loc.conf
sudo service apache2 reload
- Download Magento, and place files in your document root folder. In my case this is /home/inchoo/public_html/magento.loc.
At this point, you should be able to open http://magento.loc/ in your browser, which should trigger the installation. In case you are receivng an error, it is most likely due to too open permissions, which can be fixed by running following lines in your document root folder:
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
You may also want to add new database user for your magento isnstallation, which can easily be done through PHPMyAdmin. Also, I would recommend installing git, for managing your project:
sudo apt-get install git
In case you are importing an existing GitHub project, you would have to do following:
- Either create new VirtualHost in Apache (create new file, simmilar to 5. in previous chapter), or reuse magento.loc. In case you are re-using, delete folder /home/inchoo/public_html/magento.loc, and run following:
cd /home/inchoo/public_html/
git clone <your_repository_link> magento.loc
-
Copy/create local.xml in app/etc/ folder of Magento installation, and adjust credentials. You can also use local.xml.sample as template.
-
Import database to your MySQL server. In case of Magento, it is required to do it from terminal, due to file size. So you will most likely do something like follwoing:
zcat mysql_magento_dump.sql.gz | sed -E 's/DEFINER=`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g' | mysql -u <username> -p <database_name>