Files
wordpress-skeleton/init

64 lines
2.2 KiB
Plaintext
Raw Normal View History

2025-10-09 19:17:45 -07:00
#!/bin/bash -x
2025-10-09 18:42:33 -07:00
2025-10-09 18:44:07 -07:00
# Load env variables
source .env
2025-10-09 19:08:53 -07:00
# Get the script's directory
SCRIPT_PATH=$(dirname "$(realpath "${BASH_SOURCE[0]}")")
2025-10-09 18:42:33 -07:00
# Enable nginx to start with system
sudo systemctl enable --now nginx
# Setup nginx
sudo rm /etc/nginx/sites-enabled/default
2025-10-09 21:00:10 -07:00
sudo cp $SCRIPT_PATH/nginx/wordpress /etc/nginx/sites-available
2025-10-09 21:52:46 -07:00
sudo sed -i "s|example\.com|$WP_DOMAIN_NAME|g" /etc/nginx/sites-available/wordpress
2025-10-09 19:08:53 -07:00
sudo ln -fs /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
2025-10-09 18:42:33 -07:00
# Check for error
sudo nginx -t
# Restart nginx after loading wordpress config
sudo systemctl restart nginx
2025-10-09 19:10:25 -07:00
sudo systemctl status nginx
2025-10-09 18:42:33 -07:00
# PHP
sudo systemctl enable --now php8.4-fpm
2025-10-09 18:52:19 -07:00
# Set limit to post size and upload file size
2025-10-09 18:46:49 -07:00
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
2025-10-09 18:42:33 -07:00
2025-10-09 18:52:19 -07:00
# Set max processing children for php
2025-10-09 18:42:33 -07:00
sudo sed -i "s/^pm = dynamic/pm = ondemand/g" /etc/php/8.4/fpm/pool.d/www.conf
2025-10-09 18:51:08 -07:00
sudo sed -i "s/^pm.max_children = 5/pm.max_children = $PM_MAX_CHILDREN/g" /etc/php/8.4/fpm/pool.d/www.conf
2025-10-09 18:42:33 -07:00
# Start php-fpm
sudo systemctl restart php8.4-fpm
# MariaDB
sudo systemctl enable --now mariadb
# Secure MariaDB
2025-10-09 20:44:04 -07:00
printf "$DB_PASSWORD\nn\nY\n$DB_PASSWORD\n$DB_PASSWORD\nY\nY\nY\nY\n" | sudo mariadb-secure-installation
2025-10-09 18:42:33 -07:00
2025-10-09 20:27:02 -07:00
sudo mysql <<EOF
2025-10-09 20:44:46 -07:00
CREATE DATABASE $DB_NAME;
CREATE USER '$DB_NAME'@'localhost' IDENTIFIED BY '$DB_PASSWORD';
GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';
2025-10-09 20:27:02 -07:00
EOF
2025-10-09 20:06:01 -07:00
# WordPress
2025-10-09 20:19:31 -07:00
2025-10-09 20:49:22 -07:00
# 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
2025-10-09 22:47:20 -07:00
cd /home/debian
2025-10-09 21:45:38 -07:00
composer create-project roots/bedrock $WP_DOMAIN_NAME
2025-10-09 22:47:20 -07:00
cd /home/debian/$WP_DOMAIN_NAME
2025-10-09 22:09:17 -07:00
ln -sf $SCRIPT_PATH/.env .
composer install
2025-10-09 22:47:20 -07:00
chown -R www-data:www-data /home/debian/$WP_DOMAIN_NAME