From 31192a2ac4a119ca913a1ada1d89b29d69819126 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 6 Jan 2024 07:38:28 +0100 Subject: [PATCH] provide snippets/fastcgi-php.conf and move default site from nginx.conf to sites-available/default [release 1.21.1-3mamba;Mon Aug 30 2021] --- nginx-1.21.1-conf-sites-enabled.patch | 58 ++++++++++++++++++++++++++- nginx-fastcgi-php.conf | 13 ++++++ nginx-sites-available-default | 14 +++++++ nginx.spec | 20 ++++++++- 4 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 nginx-fastcgi-php.conf create mode 100644 nginx-sites-available-default diff --git a/nginx-1.21.1-conf-sites-enabled.patch b/nginx-1.21.1-conf-sites-enabled.patch index 4754206..8e608c5 100644 --- a/nginx-1.21.1-conf-sites-enabled.patch +++ b/nginx-1.21.1-conf-sites-enabled.patch @@ -1,5 +1,59 @@ ---- nginx-1.21.1/conf/nginx.conf.orig 2021-08-29 11:08:19.726594969 +0200 -+++ nginx-1.21.1/conf/nginx.conf 2021-08-29 11:10:19.197781120 +0200 +--- nginx-1.21.1/conf/nginx.conf.orig 2021-08-30 13:43:13.100432769 +0200 ++++ nginx-1.21.1/conf/nginx.conf 2021-08-30 13:50:28.498600068 +0200 +@@ -32,28 +32,28 @@ + + #gzip on; + +- server { +- listen 80; +- server_name localhost; +- ++ #server { ++ # listen 80; ++ # server_name localhost; ++ # + #charset koi8-r; + + #access_log logs/host.access.log main; +- +- location / { +- root html; +- index index.html index.htm; +- } +- ++ # ++ # location / { ++ # root html; ++ # index index.html index.htm; ++ # } ++ # + #error_page 404 /404.html; +- ++ # + # redirect server error pages to the static page /50x.html + # +- error_page 500 502 503 504 /50x.html; +- location = /50x.html { +- root html; +- } +- ++ # error_page 500 502 503 504 /50x.html; ++ # location = /50x.html { ++ # root html; ++ # } ++ # + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { +@@ -76,7 +76,7 @@ + #location ~ /\.ht { + # deny all; + #} +- } ++ #} + + + # another virtual host using mix of IP-, name-, and port-based configuration @@ -114,4 +114,5 @@ # } #} diff --git a/nginx-fastcgi-php.conf b/nginx-fastcgi-php.conf new file mode 100644 index 0000000..467a9e7 --- /dev/null +++ b/nginx-fastcgi-php.conf @@ -0,0 +1,13 @@ +# regex to split $uri to $fastcgi_script_name and $fastcgi_path +fastcgi_split_path_info ^(.+?\.php)(/.*)$; + +# Check that the PHP script exists before passing it +try_files $fastcgi_script_name =404; + +# Bypass the fact that try_files resets $fastcgi_path_info +# see: http://trac.nginx.org/nginx/ticket/321 +set $path_info $fastcgi_path_info; +fastcgi_param PATH_INFO $path_info; + +fastcgi_index index.php; +include fastcgi.conf; diff --git a/nginx-sites-available-default b/nginx-sites-available-default new file mode 100644 index 0000000..0bc92da --- /dev/null +++ b/nginx-sites-available-default @@ -0,0 +1,14 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + root /var/www/html; + index index.html index.htm index.nginx-openmamba.html; + server_name _; + location / { + try_files $uri $uri/ =404; + } + #location ~ .php$ { + # include snippets/fastcgi-php.conf; + # fastcgi_pass unix:/run/php-fpm/php-fpm.sock; + #} +} diff --git a/nginx.spec b/nginx.spec index 9c96b5c..a2d9619 100644 --- a/nginx.spec +++ b/nginx.spec @@ -1,6 +1,6 @@ Name: nginx Version: 1.21.1 -Release: 2mamba +Release: 3mamba Summary: High Performance Load Balancer, Web Server and Reverse Proxy Group: System/Servers Vendor: openmamba @@ -9,6 +9,8 @@ Packager: Silvan Calarco URL: https://nginx.org/ Source: https://github.com/nginx/nginx.git/release-%{version}/nginx-%{version}.tar.bz2 Source1: nginx.service +Source2: nginx-fastcgi-php.conf +Source3: nginx-sites-available-default Patch0: nginx-1.21.1-conf-sites-enabled.patch License: BSD ## AUTOBUILDREQ-BEGIN @@ -34,7 +36,7 @@ High Performance Load Balancer, Web Server and Reverse Proxy. %prep %setup -q -%patch0 -p1 +#%patch0 -p1 %build auto/configure \ @@ -82,8 +84,14 @@ auto/configure \ %makeinstall install -D -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/nginx.service +install -D -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/nginx/snippets/fastcgi-php.conf +install -D -m0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/nginx/sites-available/default install -d -m0755 %{buildroot}%{_sysconfdir}/nginx/sites-{available,enabled} +install -d -m0755 %{buildroot}%{_localstatedir}/www/html +cp %{buildroot}%{_localstatedir}/www/nginx/html/index.html \ + %{buildroot}%{_localstatedir}/www/html/index.nginx-openmamba.html + rm -f %{buildroot}%{_sysconfdir}/nginx/*.default find %{buildroot} -type f -name perllocal.pod -exec rm -f {} ';' @@ -92,6 +100,7 @@ find %{buildroot} -type f -name perllocal.pod -exec rm -f {} ';' [ "%{buildroot}" != / ] && rm -rf "%{buildroot}" %post +[ $1 -eq 1 ] && ln -s ../sites-available/default %{_sysconfdir}/nginx/sites-enabled/default %systemd_post nginx : @@ -115,7 +124,10 @@ find %{buildroot} -type f -name perllocal.pod -exec rm -f {} ';' %{_sysconfdir}/nginx/koi-utf %{_sysconfdir}/nginx/koi-win %{_sysconfdir}/nginx/win-utf +%dir %{_sysconfdir}/nginx/snippets +%{_sysconfdir}/nginx/snippets/fastcgi-php.conf %dir %{_sysconfdir}/nginx/sites-available +%config(noreplace) %{_sysconfdir}/nginx/sites-available/default %dir %{_sysconfdir}/nginx/sites-enabled %{_sbindir}/nginx %{_unitdir}/nginx.service @@ -131,10 +143,14 @@ find %{buildroot} -type f -name perllocal.pod -exec rm -f {} ';' %dir %{_localstatedir}/www/nginx %dir %{_localstatedir}/www/nginx/html %{_localstatedir}/www/nginx/html/*.html +%{_localstatedir}/www/html/index.nginx-openmamba.html %dir %{_localstatedir}/log/nginx %{_mandir}/man3/nginx.3pm* %changelog +* Mon Aug 30 2021 Silvan Calarco 1.21.1-3mamba +- provide snippets/fastcgi-php.conf and move default site from nginx.conf to sites-available/default + * Sun Aug 29 2021 Silvan Calarco 1.21.1-2mamba - configure with sites-enabled and site-available layout; remove .default configuration files