novafacile / novagallery

novaGallery - a beautiful and and ease to use php image gallery for your photos - flat file - no database required - modern responsive design
https://novagallery.org
GNU Affero General Public License v3.0
73 stars 11 forks source link

configuration for nginx #12

Open howardlshippin opened 2 years ago

howardlshippin commented 2 years ago

It would be useful to include in the documentation the configuration for nginx (i.e. the equivalent entry to include in the sites-enabled default file, which I understood should include the rewrite information instead of the .htaccess file used by apache).

Being new to this, I used an online converter, which gave me the following:

nginx configuration by winginx.com

location ~ ^/photos/nova-config/.*$ { }

location ~ ^/photos/nova-base/.*$ { }

location ~ ^/photos/nova-languages/.*$ { }

location /photos/ { if (!-e $request_filename){ rewrite ^/photos/(.*) /photos/index.php break; } }

I included the above in the NGINX default file of the sites-enabled diectory, however it doesn't work. (I get a 403 Forbidden error when trying to access the photos directory). PHP itself is set up correctly, according to tests, and the php.info file loads OK under NGINX.

david-novafacile commented 2 years ago

Good point! The difficulty is that nginx server configuration must always be customized to your own server environment and own requirements.

Here an example of nginx configuration on Ubuntu 20.04:

server {
        listen 80;
        listen [::]:80;
        server_name mydomain.com;
        root /www/novagallery;
        index index.php;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }
        location ^~ /nova-config/ { deny all; }
        location ^~ /nova-base/ { deny all; }
        location ^~ /nova-languages/ { deny all; }
}

If you have novaGallery installed in a subfolder, then you need to adjust the paths.