67 lines
2.2 KiB
Bash
67 lines
2.2 KiB
Bash
#!/bin/bash -x
|
|
|
|
# Load env variables
|
|
source .env
|
|
|
|
# Get the script's directory
|
|
SCRIPT_PATH=$(dirname "$(realpath "${BASH_SOURCE[0]}")")
|
|
|
|
# Enable nginx to start with system
|
|
sudo systemctl enable --now nginx
|
|
|
|
# Setup nginx
|
|
sudo rm /etc/nginx/sites-enabled/default
|
|
sudo cp $SCRIPT_PATH/nginx/wordpress /etc/nginx/sites-available
|
|
sudo sed -i "s|example\.com|$WP_DOMAIN_NAME|g" /etc/nginx/sites-available/wordpress
|
|
sudo ln -fs /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
|
|
|
|
# Check for error
|
|
sudo nginx -t
|
|
|
|
# Restart nginx after loading wordpress config
|
|
sudo systemctl restart nginx
|
|
|
|
# PHP
|
|
sudo systemctl enable --now php8.4-fpm
|
|
|
|
# Set limit to post size and upload file size
|
|
sudo sed -i "s/^post_max_size = 8M/post_max_size = $POST_MAX_SIZE/g" /etc/php/8.4/fpm/php.ini
|
|
sudo sed -i "s/^upload_max_filesize = 2M/upload_max_filesize = $UPLOAD_MAX_FILESIZE/g" /etc/php/8.4/fpm/php.ini
|
|
|
|
# Set max processing children for php
|
|
sudo sed -i "s/^pm = dynamic/pm = ondemand/g" /etc/php/8.4/fpm/pool.d/www.conf
|
|
sudo sed -i "s/^pm.max_children = 5/pm.max_children = $PM_MAX_CHILDREN/g" /etc/php/8.4/fpm/pool.d/www.conf
|
|
|
|
# Start php-fpm
|
|
sudo systemctl restart php8.4-fpm
|
|
|
|
# MariaDB
|
|
sudo systemctl enable --now mariadb
|
|
# Secure MariaDB
|
|
printf "$DB_PASSWORD\nn\nY\n$DB_PASSWORD\n$DB_PASSWORD\nY\nY\nY\nY\n" | sudo mariadb-secure-installation
|
|
|
|
sudo mysql <<EOF
|
|
CREATE DATABASE $DB_NAME;
|
|
CREATE USER '$DB_NAME'@'localhost' IDENTIFIED BY '$DB_PASSWORD';
|
|
GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';
|
|
EOF
|
|
|
|
# WordPress
|
|
|
|
# Composer installation
|
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
|
php -r "if (hash_file('sha384', 'composer-setup.php') === 'ed0feb545ba87161262f2d45a633e34f591ebb3381f2e0063c345ebea4d228dd0043083717770234ec00c5a9f9593792') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
|
|
php composer-setup.php
|
|
php -r "unlink('composer-setup.php');"
|
|
sudo mv composer.phar /usr/local/bin/composer
|
|
|
|
sudo su <<EOF
|
|
sudo usermod -a -G www-data debian
|
|
cd /var/www
|
|
chown -R www-data:www-data /var/www
|
|
EOF
|
|
|
|
composer create-project roots/bedrock $WP_DOMAIN_NAME
|
|
cd /var/www/$WP_DOMAIN_NAME
|
|
ln -sf $SCRIPT_PATH/.env .
|
|
composer install |