You've already forked nginx-ubuntu
initial commit
This commit is contained in:
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Allan Christensen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
64
README.md
Normal file
64
README.md
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
# Nginx PHP-FPM for Ubuntu 24.04 Server
|
||||||
|
[](#)
|
||||||
|
[](#)
|
||||||
|
[](#)
|
||||||
|
[](#)
|
||||||
|
[](./LICENSE)
|
||||||
|
|
||||||
|
Automated Bash installer script for deploying Nginx with PHP-FPM on Ubuntu 24.04 Server.
|
||||||
|
|
||||||
|
This is a **production-focused installer**, not a demo.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Preparing
|
||||||
|
Update your package index before running the installer:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt update -y
|
||||||
|
```
|
||||||
|
|
||||||
|
### Download the Script
|
||||||
|
Clone the repository from your Git server:
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://git.x-files.dk/webserver/nginx-ubuntu.git
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
cd nginx-ubuntu
|
||||||
|
```
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
Run the script using:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo ./nginxinstall
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Nginx Configuration Includes
|
||||||
|
- A directory called **nginx-snippets** in `/etc/nginx`, containing reusable snippets for clean and readable setups.
|
||||||
|
- Cloudflare Real IP configuration to ensure proxied IPs are correctly displayed.
|
||||||
|
- The default website answering on the server IP address is disabled and returns **444** (drops TCP connection).
|
||||||
|
- Bad bots blocking file, CSP, and SSL configurations (can be customized).
|
||||||
|
- Custom error pages located in `/etc/nginx-snippets/errorpages` (editable as needed).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
This setup includes enhanced caching, which is left commented out in the nginx.conf file after installation. You can enable and adjust it according to your needs.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### More Information
|
||||||
|
|
||||||
|
More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-files.dk)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### License
|
||||||
|
Licensed under the [MIT License](./LICENSE).
|
||||||
|
|
||||||
|
---
|
||||||
4
last-tested
Normal file
4
last-tested
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
------------------------------------
|
||||||
|
Last tested: 15-10-2025 (DD-MM-YYYY)
|
||||||
|
Environment: Ubuntu Server 24.04 LTS
|
||||||
|
------------------------------------
|
||||||
99
nginxinstall
Executable file
99
nginxinstall
Executable file
@@ -0,0 +1,99 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Author : Allan Christensen
|
||||||
|
# First Created : 05012022 (DD-MM-YYYY)
|
||||||
|
# Description : Installs Nginx on Ubuntu 24.04
|
||||||
|
# License : MIT License (see LICENSE file for details)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Are we root
|
||||||
|
#
|
||||||
|
if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo "" ; exit 1; fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Function to check if a service is already running or not
|
||||||
|
#
|
||||||
|
serviceyes () { printf "\n%s" $service ; printf " is already running cannot continue...\n\n"; }
|
||||||
|
servicealive () { status=$(systemctl is-active $service); if [[ "$status" == "active" ]]; then serviceyes ; exit; fi; }
|
||||||
|
|
||||||
|
#
|
||||||
|
# If Nginx is allready running then die
|
||||||
|
#
|
||||||
|
service="nginx" ; servicealive
|
||||||
|
|
||||||
|
#
|
||||||
|
# Let's go
|
||||||
|
#
|
||||||
|
clear
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install and configure Nginx
|
||||||
|
#
|
||||||
|
apt install -y nginx
|
||||||
|
rm /var/www/html/index.nginx-debian.html > /dev/null 2>&1
|
||||||
|
rm /etc/nginx/snippets/snakeoil.conf > /dev/null 2>&1
|
||||||
|
mkdir -p /var/cache/nginx/fcgi
|
||||||
|
mkdir -p /etc/nginx/static-sites
|
||||||
|
|
||||||
|
#
|
||||||
|
# Clone nginx-snippets; if nginx-snippets exists then just pull latest changes
|
||||||
|
#
|
||||||
|
nginxsnippets="/etc/nginx/nginx-snippets"
|
||||||
|
repo="https://git.x-files.dk/webserver/nginx-snippets.git"
|
||||||
|
if [[ -d "$nginxsnippets/.git" ]]; then git -C "$nginxsnippets" pull --quiet; else git clone --quiet "$repo" "$nginxsnippets"; fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install Php-Fpm
|
||||||
|
#
|
||||||
|
apt install -y php-fpm php-curl php-dom php-gd php-imagick php-ldap php-mbstring php-mysql php-pear php-soap php-xml php-zip
|
||||||
|
|
||||||
|
#
|
||||||
|
# Determine Php version
|
||||||
|
#
|
||||||
|
phpver=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')
|
||||||
|
phpfpm="php$phpver-fpm"; phpclidir="/etc/php/$phpver/cli"; phpfpmdir="/etc/php/$phpver/fpm"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure Nginx
|
||||||
|
#
|
||||||
|
cp "$phpclidir"/php.ini "$phpclidir"/php.ini.orig
|
||||||
|
cp "$phpfpmdir"/php.ini "$phpfpmdir"/php.ini.orig
|
||||||
|
cp "$nginxsnippets"/nginxconf/nginx.conf /etc/nginx
|
||||||
|
cp "$nginxsnippets"/nginxconf/nginx.conf.high.perf /etc/nginx
|
||||||
|
cp "$nginxsnippets"/nginxconf/default /etc/nginx/sites-available/default
|
||||||
|
sed -i "s/VERSION/$phpver/" /etc/nginx/nginx.conf
|
||||||
|
sed -i "s/VERSION/$phpver/" /etc/nginx/nginx.conf.high.perf
|
||||||
|
|
||||||
|
#
|
||||||
|
# Creating a high performance www.conf file for optional or later use
|
||||||
|
#
|
||||||
|
cp /etc/php/"$phpver"/fpm/pool.d/www.conf /etc/nginx/www.conf.high.perf
|
||||||
|
sed -i "s/pm.max_children = 5/pm.max_children = 50/" /etc/nginx/www.conf.high.perf
|
||||||
|
sed -i "s/pm.start_servers = 2/pm.start_servers = 15/" /etc/nginx/www.conf.high.perf
|
||||||
|
sed -i "s/pm.max_spare_servers = 3/pm.max_spare_servers = 10/" /etc/nginx/www.conf.high.perf
|
||||||
|
sed -i "s/;pm.process_idle_timeout = 10s/pm.process_idle_timeout = 10s/" /etc/nginx/www.conf.high.perf
|
||||||
|
sed -i "s/;pm.max_requests = 500/pm.max_requests = 500/" /etc/nginx/www.conf.high.perf
|
||||||
|
|
||||||
|
#
|
||||||
|
# Adjusting php.ini with stuff I usually forget
|
||||||
|
#
|
||||||
|
sed -i 's/;max_input_vars = 1000/max_input_vars = 3000/' "$phpclidir"/php.ini
|
||||||
|
sed -i 's/;max_input_vars = 1000/max_input_vars = 3000/' "$phpfpmdir"/php.ini
|
||||||
|
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/' "$phpfpmdir"/php.ini
|
||||||
|
sed -i 's/max_file_uploads = 20/max_file_uploads = 100/' "$phpfpmdir"/php.ini
|
||||||
|
sed -i 's/;date.timezone =/date.timezone = Europe\/Copenhagen/' "$phpclidir"/php.ini
|
||||||
|
sed -i 's/;date.timezone =/date.timezone = Europe\/Copenhagen/' "$phpfpmdir"/php.ini
|
||||||
|
|
||||||
|
#
|
||||||
|
# Restart Nginx and Php-Fpm
|
||||||
|
#
|
||||||
|
systemctl restart "$phpfpm" && systemctl restart nginx
|
||||||
|
|
||||||
|
#
|
||||||
|
# All done
|
||||||
|
#
|
||||||
|
printf "\n\nAll Done...\n\n"
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of script
|
||||||
|
#
|
||||||
Reference in New Issue
Block a user