Nginx
Nginx is light-weight web-server which run on more than 6% over internet web-servers[1].
Here are some instructions on how-to install it on Gentoo Linux machine and install joomla within this server. For other distros, see sources section
Contents |
PHP installation
PHP will run as fastcgi service (fpm), so Nginx server will run php separately (as different process):
# echo "dev-lang/php gd gd2 curl simplexml tokenizer dom tidy sqlite xml fpm cgi" >> /etc/portage/package.use # emerge php
The default of php-fpm is good for most servers. For special configuration visit php site.
Install nginx
In Linux you'll need to use emerge command. In other distros it would be apt-get, rpm, etc (depend on the distro).
# emerge nginx
Configure Nginx
The configuration of the virtual host on Gentoo lives in /etc/nginx/nginx.conf. Here is example from the author server:
server {
listen 80;
server_name YOUR_DOMAIN;
server_name_in_redirect off;
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log info;
root PATH_ON_SERVER;
# this is the sef of Joomla
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
index index.php index.html index.htm default.html default.htm;
# unauthorize running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
location ~ .*.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# caching of files
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}
}
Pay attention for few things:
- The sef of Joomla is inside.
- The argument fastcgi_pass set to 127.0.0.1:9000 as the fpm configured to listen on this port. That's mean you can run the php on separate servers. You can find this configuration in /etc/php/fpm-php5.3/php-fpm.conf/
- Don't forget to replace YOUR_DOMAIN & PATH_ON_SERVER depend on your domain and the path of Joomla on your server.
GZip support
If you need GZip compression support add the next code into the http section (inside /etc/nginx/nginx.conf:
gzip on;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain application/xhtml+xml text/css application/xml application/xml+rss text/javascript application/javascript application/x-javascr$
gzip_proxied any;
gzip_disable "MSIE [1-6]\.";