-
Notifications
You must be signed in to change notification settings - Fork 6
Installation Instructions (Nginx)
This document assumes you are using an Nginx/PHP-FPM installation on Ubuntu 14.04.
Install the contents of the magento
folder to /var/www/html
. For example:
cd /var/www
git clone https://github.com/steverobbins/Magento-Multi_Client.git multiclient
rm -rf html
ln -s multiclient/magento html
Each client needs a unique identifier, or code. For this example, we are going to use the CLIENT_CODE
of foostore
.
We need to tell Nginx to respond to requests to foostore
's domain name. For this example, the domain name is foostore.local
.
Open /etc/nginx/sites-available/foostore.local.conf
and add the following contents.
server {
listen 80;
server_name foostore.local;
root /var/www/html/public;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location ^~ /media/downloadable/ {
deny all;
}
location /. {
return 404;
}
location @handler {
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ {
if (!-e $request_filename) {
rewrite / /index.php last;
}
expires off;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param CLIENT_CODE foostore;
include fastcgi_params;
}
}
Most of this is typical Magento Nginx config. The important lines are:
...
server_name foostore.local;
...
fastcgi_param CLIENT_CODE foostore;
...
Here were are telling the application that for the url foostore.local
, set the CLIENT_CODE
to foostore
.
Nginx will automatically load *.conf
files in the sites-enabled
folder, so we need to symlink our file there
ln -s /etc/nginx/sites-available/foostore.local.conf /etc/nginx/sites-enabled/foostore.local.conf
Now restart Nginx
service nginx restart
If you are using the Vagrant box included in the repository, now is good time to add the following to your /etc/hosts
file
192.168.100.101 foostore.local
The current installation process involves breaking the application for other clients. The installation should take place on an offline server (dev), exported, and then imported to the production environment.
Before we can start the installation, we need to create directories for this client. The directory name foostore
should match our CLIENT_CODE
that we determined earlier.
mkdir -p /var/www/html/var/foostore
mkdir -p /var/www/html/app/etc/multiclient/foostore
cp -R /var/www/html/public/media/_template /var/www/html/public/media/foostore
chmod -R 700 /var/www/html/var/foostore /var/www/html/public/media/foostore
At this point when visiting http://foostore.local/
you should see Magento's 404 page.
Now we need to create the Magento database for this client. Because there is already an app/etc/local.xml
, Magento thinks it's been installed. We need to trick it into running the installation process and save the new local.xml
to a client specific place.
To start, rename the local.xml
mv /var/www/html/app/etc/local.xml /var/www/html/app/etc/local.xml.save
Reload http://foostore.local/
and you should see the Magento Installation Wizard. Complete the installation process as you normally would.
If you are using the Vagrant box provided in this repo, the default MySQL username and password are root
and root
. Make sure you have created the foostore
database.
mysql -e 'CREATE DATABASE foostore'
You will also need to check "Skip Base URL Validation Before the Next Step"
Once you've reached the final step of the wizard, the credentials have been stored in app/etc/local.xml
. Since we want this file to be client specific, we need to move it to it's client specific area. Then we will restore the original local.xml
mv /var/www/html/app/etc/local.xml /var/www/html/app/etc/multiclient/foostore/local.xml
mv /var/www/html/app/etc/local.xml.save /var/www/html/app/etc/local.xml
Now navigate to http://foostore.local/
once again and you should see the Magento frontend. This indicates a successful installation. You should be able to repeat this process for barstore
, etc.