Auto Nginx Installation
Project description
Auto Nginx Installation Script
This script is designed to install Nginx on modern Ubuntu, other Debian-based systems might also work.
Supported Modules
- Many common first-party modules (Check auto-generated
config.yamlfor details) - Dynamic Record Resizing for TLS
- brotli
- headers-more
- geoip2
- fancyindex
- OpenSSL from source
- Zlib-Cloudflare from source
- Substitutions Filter
- Development Kit
Supported Flavors
- Vanilla
- OpenResty
Go to discussions to request more modules.
Installation
pip install -U nginx-install
or
git clone https://github.com/VermiIIi0n/nginx_install.git
cd nginx_install
pip install -U poetry
poetry install
Quick Start
Create a config.yaml, use any action as the first argument, it won't actually run if config.yaml is not found.
nginx-install uninstall --dry ## creates a config.yaml file and quits
Edit your config.yaml and run the following command to install Nginx:
nginx-install install
To uninstall Nginx, use the following command:
nginx-install uninstall
Usage
Installed by pip
nginx-install { prepare | build | install | uninstall | clean } [build_dir]
When you first run the script, you will be asked to create a config.yaml under the current directory. You may not want to run as root when creating the config.yaml file.
You can also specify the file using the -c/--config option.
The first positional argument is the action to be performed.
The second positional argument is optional and is used to specify the build directory. If not specified, the default build directory is used.
When running the script for real business, you will be prompted to run as root, because the script needs to install packages and create directories.
To just build the Nginx binary, use the following command:
nginx-install build ./build # Or any other build directory
To just install without building, use the following command:
nginx-install install --no-build ./build # Or any other build directory
To build and install Nginx, use the following command:
nginx-install install # Here the build directory is in a tmp dir
build and plain install both delete the previous build directory and create a new one.
Currently only partial support for cross-compiling. If your target system is the same as the build system, you can copy the build directory to the target system and run install --no-build there.
Change -march in config.yaml if your are installing on systems with different CPU
By default, core installer will use -march=native flag, this may cause problems on other systems.
Check your -march by running gcc -march=native -Q --help=target | grep march on your target system and change -march in config.yaml accordingly.
Installed by git clone
If you cloned the repository, use the following command to run the script:
poetry run `which python` nginx_install <...>
Dry Run
Use --dry to run the script in dry-run mode. In this mode, the script will not change anything outside of build_dir but will print the commands to be executed.
nginx-install --dry build
no root should be required if you have access to the build directory.
Configuration
The config.yaml file is used to specify the version of Nginx to be installed, the modules to be included, and the build options.
Use -c/--config to specify the path of the config.yaml file. By default, it is config.yaml under the current directory.
If not specified, the script will search for the ./config.yaml file, and if not found, it will ask you to create one.
If -q/--quiet is specified, the script will not ask you to create one and will exit with an error if not found.
Useful options in config.yaml:
version: The version of Nginx to be installed. Can bestable,mainline,latest, or a simple spec version (e.g.1.21.3,^1.24.0,<=1.26.0).core.flavor: Can be vanilla and openrestypymodule_paths: A list of paths to Python modules. Convenient for adding customInstallerclasses.
Customization
You can easily add your own modules to modify the installation of Nginx (e.g. add custom modules, change build options, etc.).
All Installer classes are descendants of the BaseInstaller class.
Every Installer class has 5 async methods corresponding to the 5 stages of the installation process:
preparebuildinstalluninstallclean
They all accept a special context parameter, which contains useful information about the installation process. You must override these methods in inherited classes.
During installation running, installers go through prepare, build, install and clean stages. During uninstallation running, installers go through uninstall and clean stages.
A special Installer called core represents the core binary installer of Nginx. In every stage, the core installer methods are called first, and then the methods of other installers are called. The order of the other installers is random. This is done to reduce build time.
You can access core through the context parameter. Parameters like Nginx configure options are stored in core and can be modified.
Context
The context parameter is a dictionary containing the following attributes:
build_dir: The build directory.cfg: TheConfigobject from theconfig.yamlfile.core: TheNginxInstallerobject.verbose: A boolean value indicating whether to print verbose information.quiet: A boolean value indicating whether to print nothing unless an error occurs.dry_run: A boolean value indicating whether to run the script in dry-run mode. You should respect this value in your custom installers. Don't actually change anything ifdry_runisTrue.user: The user who started the script.client: Ahttpx.AsyncClientobject. You can use it to download files from the internet.logger: You can use it to log information.progress: Arich.progress.Progressobject. You can use it to show a progress bar.run_cmd: Anasyncfunction to run shell commands. You should use it to run shell commands in your custom installers. Whendry_runisTrue, it will only print the command to be executed.download: Anasyncfunction to download files from the internet. You should use it to download files in your custom installers. It automatically shows a progress bar when downloading files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nginx_install-0.1.12.tar.gz.
File metadata
- Download URL: nginx_install-0.1.12.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bd41d9deb0af74b33138b49fc6529a39f15ec155e3cf6af6ef409a4245abb04
|
|
| MD5 |
6c72cf9ca688260c74172a24a65bff04
|
|
| BLAKE2b-256 |
66469e318fe2b66be067f2387bc9d8dc280184821b99151949fb22642790bca6
|
Provenance
The following attestation bundles were made for nginx_install-0.1.12.tar.gz:
Publisher:
publish-workflow.yml on VermiIIi0n/nginx_install
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nginx_install-0.1.12.tar.gz -
Subject digest:
8bd41d9deb0af74b33138b49fc6529a39f15ec155e3cf6af6ef409a4245abb04 - Sigstore transparency entry: 225332829
- Sigstore integration time:
-
Permalink:
VermiIIi0n/nginx_install@d2429818f0adcf328c7e6c263da55a77e2357b65 -
Branch / Tag:
refs/tags/v0.1.12 - Owner: https://github.com/VermiIIi0n
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-workflow.yml@d2429818f0adcf328c7e6c263da55a77e2357b65 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nginx_install-0.1.12-py3-none-any.whl.
File metadata
- Download URL: nginx_install-0.1.12-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0db5699659e3bec9c3a612a95464b06b502ec5acc1a6d276e14b1099986a9ab7
|
|
| MD5 |
40b1a22632c1d5d928c439bb5b41eeae
|
|
| BLAKE2b-256 |
b195ef538d7e570a9aaf7a9d7a990726aadbe8c9ebbe369e5680dd16fb66c039
|
Provenance
The following attestation bundles were made for nginx_install-0.1.12-py3-none-any.whl:
Publisher:
publish-workflow.yml on VermiIIi0n/nginx_install
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nginx_install-0.1.12-py3-none-any.whl -
Subject digest:
0db5699659e3bec9c3a612a95464b06b502ec5acc1a6d276e14b1099986a9ab7 - Sigstore transparency entry: 225332836
- Sigstore integration time:
-
Permalink:
VermiIIi0n/nginx_install@d2429818f0adcf328c7e6c263da55a77e2357b65 -
Branch / Tag:
refs/tags/v0.1.12 - Owner: https://github.com/VermiIIi0n
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-workflow.yml@d2429818f0adcf328c7e6c263da55a77e2357b65 -
Trigger Event:
push
-
Statement type: