how to format Elgg 2.3.2 in nginx.conf

I am trying to install Elgg 2.3.2 on Centos 7 running nginx but cannot get any of the nginx.conf code I have found to work. Any help would be greatly appreciated. If you have a nginx.conf that works ( I can input my own ip and domain name obviously) please let me know or if there is anything else needs to be done, instructions on  how would be wonderful. 

  • Will your Elgg site be in the document root (like elgg.org) or in a subdirectory (example.com/elgg/)?

  • in root..yes I have tried this out and I used the 1.71 nginx.conf  file I found and the file elgg tells you to use when it describes install on nginx to no avail

  • Do you know PHP/PHP-FPM is working in general, and bound to port 9000? I just recently managed to get ngnix + PHP7 setup myself.

  • This is my working nginx config:

    server {
            listen 80;
            server_name yoursite.com;
    
            # Server root, replace it with your elgg installation location
            root /path/to/yoursite.com;
            index index.php;
    
            # Max post size
            client_max_body_size      20M;
            client_body_buffer_size 256K;
    
            ssi  on;
    
            gzip on;
            gzip_types
                    # text/html is always compressed by HttpGzipModule
                    text/css
                    text/javascript
                    text/xml
                    text/plain
                    text/x-component
                    application/javascript
                    application/x-javascript
                    application/json
                    application/xml
                    application/rss+xml
                    font/truetype
                    font/opentype
                    application/vnd.ms-fontobject
                    image/svg+xml;
    
            # Server logs, replace it with your project names
            error_log /var/log/nginx/error.log error;
            # access_log /var/log/nginx/$server_name.access.log;
    
            location ~ (^\.|/\.) {
                    return 403;
            }
    
            location = /rewrite.php {
                    rewrite ^(.*)$ /install.php;
            }
    
            location / {
                    try_files $uri $uri/ @elgg;
            }
               # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~ \.php$ {
                    try_files $uri @elgg;
                    fastcgi_index index.php;
                    fastcgi_pass   unix:/var/run/php/php5.6-fpm.sock;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
                    #Tweaks
                    fastcgi_connect_timeout 60;
                    fastcgi_send_timeout 300;
                    fastcgi_read_timeout 300;
                    fastcgi_buffer_size 512k;
                    fastcgi_buffers 512 16k;
                    fastcgi_busy_buffers_size 512k;
                    fastcgi_temp_file_write_size 512k;
                    fastcgi_intercept_errors on;
            }
    
            location @elgg {
                    fastcgi_pass   unix:/var/run/php/php5.6-fpm.sock;
    
                    include /etc/nginx/fastcgi_params;
                    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
                    fastcgi_param SCRIPT_NAME     /index.php;
                    fastcgi_param QUERY_STRING    __elgg_uri=$uri&$args;
            }
    }

    Pay attention to update your pastcgi_pass parameter to your socket path, or to your listenng port.

  • I am still uploading elgg but I uploaded Javier's nginx.conf and my phpmyadmin in the control panel is now coming up with an error 404 not found...any ideas?

  • I just proposed a change to the nginx config you might want to consider.

  • I got phpmyadmin working but now when I try to access install.php i get a 502 Bad Gateway error in nginx

  • here is the nginx.conf I am using I have changed the domain name to yoursite.com

    server {
            listen my ip:80;
            server_name yoursite.com www.yoursite.com;

            # Server root, replace it with your elgg installation location
            root /home/admin/web/yoursite.com/public_html;
            index index.php;

            # Max post size
            client_max_body_size      20M;
            client_body_buffer_size 256K;

            ssi  on;

            gzip on;
            gzip_types
                    # text/html is always compressed by HttpGzipModule
                    text/css
                    text/javascript
                    text/xml
                    text/plain
                    text/x-component
                    application/javascript
                    application/x-javascript
                    application/json
                    application/xml
                    application/rss+xml
                    font/truetype
                    font/opentype
                    application/vnd.ms-fontobject
                    image/svg+xml;

            # Server logs, replace it with your project names
            access_log  /var/log/nginx/domains/yoursite.com.log combined;
            access_log  /var/log/nginx/domains/yoursite.com.bytes bytes;
            error_log   /var/log/nginx/domains/yoursite.com.error.log error;

            location ~ (^\.|/\.) {
                    return 403;
            }

            location = /rewrite.php {
                    rewrite ^(.*)$ /install.php;
            }

            location / {
                    include     /etc/nginx/conf.d/phpmyadmin.inc*;
                    include     /etc/nginx/conf.d/phppgadmin.inc*;
                    include     /etc/nginx/conf.d/webmail.inc*;
                    try_files $uri $uri/ @elgg;
                    
            }
               # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
               # Pay attention to update your pastcgi_pass parameter to your socket path, or to your listenng port.
            location ~ \.php$ {
                    try_files $uri @elgg;
                    fastcgi_index index.php;
                    fastcgi_pass   unix:/etc/php.ini;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    #Tweaks
                    fastcgi_connect_timeout 60;
                    fastcgi_send_timeout 300;
                    fastcgi_read_timeout 300;
                    fastcgi_buffer_size 512k;
                    fastcgi_buffers 512 16k;
                    fastcgi_busy_buffers_size 512k;
                    fastcgi_temp_file_write_size 512k;
                    fastcgi_intercept_errors on;
            }

            location @elgg {
                    fastcgi_pass   unix:/etc/php.ini;

                    include /etc/nginx/fastcgi_params;
                    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
                    fastcgi_param SCRIPT_NAME     /index.php;
                    fastcgi_param QUERY_STRING    __elgg_uri=$uri&$args;
                    
            }
           

    }

  • when i try to run install with that nginx.conf I get this message:

    Fatal error: Uncaught exception 'LogicException' with message 'The root path /home/admin/web/herbertwalsh.com/public_html is not readable.' in /home/admin/web/herbertwalsh.com/public_html/vendor/league/flysystem/src/Adapter/Local.php:81 Stack trace: #0 /home/admin/web/herbertwalsh.com/public_html/vendor/elgg/elgg/engine/classes/Elgg/Filesystem/Directory/Fly.php(157): League\Flysystem\Adapter\Local->__construct('/home/admin/web...') #1 /home/admin/web/herbertwalsh.com/public_html/vendor/elgg/elgg/engine/classes/Elgg/Filesystem/Directory/Local.php(23): Elgg\Filesystem\Directory\Fly::createLocal('/home/admin/web...') #2 /home/admin/web/herbertwalsh.com/public_html/vendor/elgg/elgg/engine/classes/Elgg/Filesystem/Directory/Local.php(43): Elgg\Filesystem\Directory\Local::fromPath('/home/admin/web...') #3 /home/admin/web/herbertwalsh.com/public_html/vendor/elgg/elgg/engine/classes/Elgg/Config.php(42): Elgg\Filesystem\Directory\Local::root() #4 /home/admin/web/herbertwalsh.com/public_html/vendor/elgg/elgg/engine/classes/ElggInsta in /home/admin/web/herbertwalsh.com/public_html/vendor/league/flysystem/src/Adapter/Local.php on line 81