For the framework to successfully run under Nginx + FastCGI without the use of Apache, it is necessary to add some special settings to the Nginx configuration file.
Below is shown a sample configuration for the following operating conditions:
- The framework is installed in server directory
/var/www/fw/. - PHP FastCGI serves TCP port 9000 (default setting).
server {
listen 80;
server_name fw;
root /var/www/fw;
index index.php;
try_files $uri $uri/ /index.php?$query_string;
location /index.php {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
# for install only
location /install.php {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
location ^~ /api.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
location ~ /(oauth.php|link.php|payments.php|captcha.php|push.php) {
try_files $uri $uri/ /index.php?$query_string;
}
location ^~ /wa-data/protected/ {
internal;
}
location ~ /wa-content {
allow all;
}
location ~ /wa-apps/[^/]+/(plugins/[^/]+/)?(lib|locale|templates)/ {
deny all;
}
location ~ /(wa-plugins/([^/]+)|wa-widgets)/.+/(lib|locale|templates)/ {
deny all;
}
location ~* ^/wa-(cache|config|installer|log|system)/ {
return 403;
}
location ~* ^/wa-data/public/contacts/photos/[0-9]+/ {
access_log off;
expires 30d;
error_page 404 = @contacts_thumb;
}
location @contacts_thumb {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_NAME /wa-data/public/contacts/photos/thumb.php;
fastcgi_param SCRIPT_FILENAME $document_root/wa-data/public/contacts/photos/thumb.php;
}
# photos app
location ~* ^/wa-data/public/photos/[0-9]+/ {
access_log off;
expires 30d;
error_page 404 = @photos_thumb;
}
location @photos_thumb {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_NAME /wa-data/public/photos/thumb.php;
fastcgi_param SCRIPT_FILENAME $document_root/wa-data/public/photos/thumb.php;
}
# end photos app
# shop app
location ~* ^/wa-data/public/shop/products/[0-9]+/ {
access_log off;
expires 30d;
error_page 404 = @shop_thumb;
}
location @shop_thumb {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_NAME /wa-data/public/shop/products/thumb.php;
fastcgi_param SCRIPT_FILENAME $document_root/wa-data/public/shop/products/thumb.php;
}
location ~* ^/wa-data/public/shop/promos/[0-9]+ {
access_log off;
expires 30d;
error_page 404 = @shop_promo;
}
location @shop_promo {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_NAME /wa-data/public/shop/promos/thumb.php;
fastcgi_param SCRIPT_FILENAME $document_root/wa-data/public/shop/promos/thumb.php;
}
# end shop app
# mailer app
location ~* ^/wa-data/public/mailer/files/[0-9]+/ {
access_log off;
error_page 404 = @mailer_file;
}
location @mailer_file {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_NAME /wa-data/public/mailer/files/file.php;
fastcgi_param SCRIPT_FILENAME $document_root/wa-data/public/mailer/files/file.php;
}
# end mailer app
# tasks app
location ~* ^/wa-data/public/tasks/tasks/[0-9]+/ {
access_log off;
expires 30d;
error_page 404 = @tasks_thumb;
}
location @tasks_thumb {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_NAME /wa-data/public/tasks/tasks/thumb.php;
fastcgi_param SCRIPT_FILENAME $document_root/wa-data/public/tasks/tasks/thumb.php;
}
# end tasks app
location ~* ^.+\.(jpg|jpeg|gif|png|webp|js|css)$ {
access_log off;
expires 30d;
}
location /cli.php {
deny all;
}
}
Also check that you have these values in configuration file /etc/nginx/fastcgi_params:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info;









