Scripts for automating deployment and removal of websites using the Nginx web server.
This repository contains shell scripts that simplify the deployment and removal of websites on an Nginx server.
They automate tasks such as:
- Moving website files to
/var/www - Creating and configuring Nginx server blocks
- Enabling/disabling sites via
sites-enabled - Reloading Nginx after changes
- Safely removing site configurations and files
This script automates the deployment of a static or PHP website on an Nginx server.
It performs the following actions:
- Moves the website directory to
/var/www - Creates an Nginx configuration file
- Creates a symbolic link in
sites-enabled - Checks Nginx configuration
- Restarts Nginx
- Make the script executable:
chmod +x deployNginxWebsite.sh- Run the script with the path to the website folder:
sudo ./deployNginxWebsite.sh /path/to/website [-ip]-ip (optional): serves the site using the server IP instead of a domain name Notes:
- Ensure your domain (e.g. mywebsite) is properly configured in DNS or /etc/hosts
- If using a different PHP version, update the PHP-FPM socket path (e.g. php8.0-fpm.sock)
- Requires Nginx and PHP-FPM to be installed and configured
This script automates the removal of a website from an Nginx server.
It performs the following actions:
- Removes Nginx config from sites-available and sites-enabled
- Deletes the website directory from /var/www
- Reloads Nginx to apply changes
Usage:
- Make the script executable:
chmod +x removeNginxWebsite.sh- Run the script with the site name:
sudo ./removeNginxWebsite.sh example.comNotes
- Be careful: this action is irreversible
- If config or directory is missing, the script will notify but continue execution Requires Nginx to be installed
В этом репозитории представлены shell-скрипты для автоматизации развёртывания и удаления сайтов на сервере Nginx.
Они выполняют:
- перенос сайта в /var/www
- создание конфигурации Nginx
- подключение сайта через sites-enabled
- перезагрузку Nginx
- безопасное удаление сайта и конфигурации
🚀 Скрипт деплоя
deployNginxWebsite.sh
Скрипт автоматизирует развёртывание статического или PHP сайта на Nginx.
Что делает:
- перемещает сайт в /var/www
- создаёт конфиг Nginx
- добавляет символическую ссылку в sites-enabled
- проверяет конфигурацию Nginx
- перезапускает сервер Использование:
chmod +x deployNginxWebsite.shsudo ./deployNginxWebsite.sh /путь/к/папке_с_сайтом [-ip]-ip - (опционально) доступ по IP вместо домена Примечания:
- убедитесь, что домен настроен в DNS или /etc/hosts
- при использовании PHP проверьте версию PHP-FPM
- требуется установленный Nginx и PHP-FPM
🗑️ Скрипт удаления ``removeNginxWebsite.sh`
Скрипт автоматизирует удаление сайта из Nginx.
Что делает:
- удаляет конфиги из sites-available и sites-enabled
- удаляет папку сайта из /var/www
- перезагружает Nginx Использование:
chmod +x removeNginxWebsite.shsudo ./removeNginxWebsite.sh example.comПримечания:
- удаление необратимо
- если файлы не найдены, скрипт продолжит работу
- требуется установленный Nginx