This project provides a fully automated Bash script to set up a production-ready Linux server or Docker stack on Debian, Ubuntu, CentOS, or RHEL. The script installs and configures all essential components for web hosting and applications.
-
Operating Systems: Debian 12+, Ubuntu 20.04+, CentOS 7+, RHEL 7+
-
Installed Components:
- Nginx (web server)
- PHP-FPM (configurable version, e.g., 8.2)
- MariaDB / MySQL-compatible
- phpMyAdmin
- Node.js 20+
- Fail2Ban (brute-force protection)
- Firewall (UFW on Debian/Ubuntu, firewalld on CentOS/RHEL)
- SSL certificates via Certbot (Let's Encrypt)
-
Modes:
native: installation directly on the host serverdocker: Docker Compose stack with DB, Nginx, PHP-FPM, phpMyAdmin
-
Multi-Domain Support: single or multiple domains can be configured simultaneously
-
Automatic Nginx vhosts for each domain
-
Non-interactive MariaDB setup with root password
-
Docker support for instant containerized deployment
- Root access on the server (sudo)
- At least 1 GB RAM
- Internet connection
- Optional: domains pointing to the server
curl -fsSL https://example.com/automated-linux-server-setup.sh -o automated-linux-server-setup.sh
chmod +x automated-linux-server-setup.shsudo DOMAINS="example.com,www.example.com" \
EMAIL="[email protected]" \
MODE=native \
DB_ROOT_PASS="securepassword" \
bash automated-linux-server-setup.shsudo DOMAINS="example.com" \
MODE=docker \
DB_ROOT_PASS="securepassword" \
bash automated-linux-server-setup.shAfter execution, the Docker Compose stack is located under /opt/<domain>.
- Web root:
/var/www/<domain_group>/html(native) or/opt/<domain>/www(docker) - MariaDB: Root password is set automatically, default user
root - phpMyAdmin: Access via
/phpmyadminor port 8080 for Docker - Nginx vhosts: automatically generated for each domain group
- PHP-FPM Socket:
/var/run/php/php<version>-fpm.sock(native)
--domains- comma-separated domains--mode-nativeordocker(default: native)--email- administrator email for SSL--db-root-pass- MariaDB root password--php- PHP version (default: 8.2)--force- overwrite existing configurations
- Fail2Ban to protect against brute-force attacks
- Firewall configuration (UFW/firewalld) on standard ports
- SSL certificates via Let's Encrypt
- Non-interactive MariaDB setup removes insecure defaults
- Place your website files in the web root:
/var/www/<domain>/htmlor/opt/<domain>/www - Check Nginx configuration:
nginx -t - Check PHP-FPM:
systemctl status php<version>-fpm - Access MariaDB:
mysql -u root -p - Access phpMyAdmin:
http://<domain>/phpmyadmin(native) orhttp://<server_ip>:8080(Docker)
If you encounter problems, please open an issue on GitHub or contact the administrator.
Note: The script is intended for production environments. Test it first in a safe environment. Optional adjustments can include specific security policies, SELinux, load balancers, or CI/CD integration.