Do the following steps as root user:
- Run puppet agent (maybe multiple times)
- Disable nginx default site:
rm /etc/nginx/sites-enabled/default
- Create folder for Python script and upload the files of deploy_script
mkdir /opt/prdeployer
- Install Python requirements:
cd /opt/prdeployer
andpip3 install -r requirements.txt
- Update Node/NPM:
npm install -g n && n stable && npm install npm@latest -g
- Install Sass (use new command in future):
npm install -g sass
- Secure MariaDB server:
mysql_secure_installation
Current root password (None, Enter)
Set new root password [Y] (Choose a random password)
Remove anonymous users [Y]
Disallow root login remotely [Y]
Remove test database [Y]
Reload privilege tables now [Y] - Allow TCP root login (disable socket):
mysql mysql -e "UPDATE user SET plugin = '' WHERE user = 'root' AND host = 'localhost';
mysql -e "FLUSH PRIVILEGES;"
- To allow mysql login as root without a password, create the file /root/.my.cnf with the following content
[client] user=root password=MYSQL_PASSWORD_DEFINED_ABOVE
- Also set the password in /opt/prdeployer/config.py file
- Create web directories:
mkdir /var/www/catroweb && mkdir -p /var/www/index/logs
- Create cache directories for composer and npm:
mkdir /var/www/.composer && chown www-data:www-data /var/www/.composer mkdir /var/www/.npm && chown www-data:www-data /var/www/.npm mkdir /var/www/.config && chown www-data:www-data /var/www/.config
- Upload files of index_page to /var/www/index/
- Create database for deployment:
mysql -e "CREATE DATABASE deployment;"
- Initialize the database with the create_deployment_table.sql file:
mysql deployment < create_deployment_table.sql
- Create MySQL user for index page:
mysql -Be "CREATE USER 'index'@'localhost' IDENTIFIED BY 'YOUR_RANDOM_INDEX_PASSWORD'; GRANT SELECT ON deployment.* TO 'index'@'localhost';"
- Set MySQL password for index in /var/www/index/config.php, and check url_template there, too.
- Add branches using the following Python3 script, executed in /opt/prdeployer/:
import prdeployer prdeployer.Deployer.add_github_branch('master') prdeployer.Deployer.add_github_branch('develop')
The server should run using HTTPS, otherwise, errors or warnings may occur in the browser.
- nginx site config for index
- nginx server block template used by deployer
- php sury apt list config
- installed apt packages
- cron command
- Add Sury PHP as package source: See https://deb.sury.org/
- Install needed packages (use PHP version needed, multiple versions possible)
apt-get install nginx mariadb-server ssl-cert npm curl python3 git apt-get install php8.1-common php8.1-cli php8.1-fpm php8.1-curl php8.1-intl php8.1-gd php8.1-zip php8.1-mysql php8.1-xml php8.1-mbstring apt-get install php-apcu php-imagick php-gettext composer
- Copy the file nginx_index_site to /etc/nginx/sites-available/index
- Create a symlink from /etc/nginx/sites-enabled/000-index to /etc/nginx/sites-available/index
- Do the steps from above, except the first one
- Restart nginx:
systemctl restart nginx
- Add the following line as cronjob for root using
crontab -e
:/15 * * * * /usr/bin/flock -w 300 /opt/prdeployer/prdeployer.lock /usr/bin/python3 /opt/prdeployer/prdeployer.py >/dev/null 2>&1