There are different options of running OroCRM on your server. In this blog post we will described how to run the OroCRM application on a Linux server with nginx + php-fpm.
System environment: Ubuntu 13.10
Server components installation
Let’s start by installing Nginx, PHP and MySQL. In shell execute one of the sets of commands based on your chosen distro.
apt-get install nginx
apt-get install curl
apt-get install php5-cli php5-common php5-mysql php5-suhosin php5-gd php5-fpm php5-fpm php-pear php5-mcrypt php5-intl php5-json php5-curl
apt-get install mysql-server
apt-get install git
apt-get install openjdk-7-jre-headless
apt-get install nodejs
cd /etc/php5/fpm/conf.d
ln -s ../../conf.d/mcrypt.ini 20-mcrypt.ini
nginx configuration
Go to Nginx configuration folder /etc/nginx. Change HTTP timeouts.
cd /etc/nginx
vi ./conf.d/options.conf
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
real_ip_header X-Forwarded-For;
Create OroCRM project configuration. Go to /etc/nginx/sites-available and create orocrm file there
server {
server_name *.local;
root /var/www/project/dev/$host/web;
index app.php;
access_log /var/log/nginx/$host.access_log;
error_log /var/log/nginx/dev.error_log info;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /app.php/$1;
}
location ~ [^/].php(/|$) {
fastcgi_split_path_info ^(.+?.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_index app.php;
fastcgi_read_timeout 10m;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Let’s review configuration in details. Listen on all .local subdomains.
server_name *.local;
Set server root and set directory index to app.php
root /var/www/project/dev/$host/web;
index app.php;
$host variable used to support different projects. For example host http://oro-crm.local/ will be mapped to /var/www/project/dev/oro-crm.local/web
Configure server logs. It’s sad but we are unable to use $host for errors logging
access_log /var/log/nginx/$host.access_log;
error_log /var/log/nginx/dev.error_log info;
Support links without PHP file name in them
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /app.php/$1;
}
Redirect all request to PHP files to PHP-FPM, set script execution wait timeout to 10 minutes, connect to php-fpm with socket
location ~ [^/].php(/|$) {
fastcgi_split_path_info ^(.+?.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_index app.php;
fastcgi_read_timeout 10m;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
To enable OroCRM config symlink it to /etc/nginx/sites-enabled folder with the following command
cd /etc/nginx
ln -s ./sites-available/oro ./sites-enabled/oro
PHP-FPM configuration
Basic PHP-FPM configuration. The main thing here is to set user and group to the same ones used in nginx.conf and listen on socket that used for FastCGI requests from Nginx.
Go to /etc/php5/fpm/pool.d and edit www.conf. Below are the listed options that need to be enabled and set. All other options may be used as is in this file.
[www]
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
user = www-data
group = www-data
PHP configuration
To run OroCRM you need to change the following PHP option in php.ini. Go to /etc/php5/fpm and edit php.ini there
memory_limit = 512M
date.timezone = #For example America/Los_Angeles
If you have installed another web server on 80 port you need to stop it or change listening port. For example to stop Apache web server execute the following command.
/etc/init.d/apache2 stop
Finally run installed and configured services
/etc/init.d/mysql start
/etc/init.d/php5-fpm start
/etc/init.d/nginx start
Add host name to hosts file
127.0.0.1 oro-crm.local
Installing OroCRM
Download OroCRM application from github
mkdir /var/www/project/dev
cd /var/www/project/dev
git clone https://github.com/orocrm/crm-application.git oro-crm.local
Install composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin
Install OroCRM dependencies
cd oro-crm.local
composer.phar install --prefer-dist
Fix permissions
chown www-data:www-data -R /var/www/project/dev/oro-crm.local
Now navigate to http://oro-crm.local/install.php and follow installation instructions