Skip to content

Latest commit

 

History

History
69 lines (66 loc) · 3.5 KB

INSTALL.md

File metadata and controls

69 lines (66 loc) · 3.5 KB

Catroweb Auto-Deploy Server Installation

Do the following steps as root user:

  1. Run puppet agent (maybe multiple times)
  2. Disable nginx default site: rm /etc/nginx/sites-enabled/default
  3. Create folder for Python script and upload the files of deploy_script mkdir /opt/prdeployer
  4. Install Python requirements: cd /opt/prdeployer and pip3 install -r requirements.txt
  5. Update Node/NPM: npm install -g n && n stable && npm install npm@latest -g
  6. Install Sass (use new command in future): npm install -g sass
  7. 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]
  8. Allow TCP root login (disable socket): mysql mysql -e "UPDATE user SET plugin = '' WHERE user = 'root' AND host = 'localhost';
    mysql -e "FLUSH PRIVILEGES;"
  9. 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
    
  10. Also set the password in /opt/prdeployer/config.py file
  11. Create web directories: mkdir /var/www/catroweb && mkdir -p /var/www/index/logs
  12. 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
  13. Upload files of index_page to /var/www/index/
  14. Create database for deployment: mysql -e "CREATE DATABASE deployment;"
  15. Initialize the database with the create_deployment_table.sql file: mysql deployment < create_deployment_table.sql
  16. 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';"
  17. Set MySQL password for index in /var/www/index/config.php, and check url_template there, too.
  18. 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.

The following things are under puppet control

  • nginx site config for index
  • nginx server block template used by deployer
  • php sury apt list config
  • installed apt packages
  • cron command

Installation without Puppet

  1. Add Sury PHP as package source: See https://deb.sury.org/
  2. 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
  3. Copy the file nginx_index_site to /etc/nginx/sites-available/index
  4. Create a symlink from /etc/nginx/sites-enabled/000-index to /etc/nginx/sites-available/index
  5. Do the steps from above, except the first one
  6. Restart nginx: systemctl restart nginx
  7. 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