Jump to main content Jump to doc navigation

Here is an example config for a MODX installation on an nginx server (php-fpm is required for nginx servers) to enable friendly urls.

server {
        listen 80;
        server_name example.com www.example.com;
        root /home/sites/example.com;
        index index.php;
        client_max_body_size 30M;
        location / {
                root /home/sites/example.com;
                if (!-e $request_filename) {
                        rewrite ^/(.*)$ /index.php?q=$1 last;
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include fastcgi_params;
                fastcgi_ignore_client_abort on;
                fastcgi_param  SERVER_NAME $http_host;

        location ~ /\.ht {
                deny  all;

FastCGI connectivity between nginx and PHP as expressed on the line fastcgi_pass; may need to be set to something like fastcgi_pass unix:/var/run/php5-fpm.sock;

This is codependent on how the www.conf (usually located at /etc/php5/fpm/pool.d ) file is configured. How is the "listen" directive set up in that file: TCP or unix socket (i.e. /var/run/php5-fpm.sock ) ?

The nginx config file needs to specify the same connection in both files! [NB: theoretically unix sockets will be faster, but in such case both resources need to be on the same host. TCP is useful in a distributed environment. ]

An alternative server configuration was suggested in this forum topic.