Files
wordpress-skeleton/init

54 lines
2.1 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 19:08:53 -07:00
sudo ln -fs $SCRIPT_PATH/nginx/wordpress /etc/nginx/sites-available
sudo ln -fs /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
2025-10-09 19:20:53 -07:00
sudo ln -fs $SCRIPT_PATH/phpmyadmin/phpmyadmin /etc/nginx/sites-available
sudo ln -fs /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/phpmyadmin
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:00:22 -07:00
printf "$MYSQL_ROOT_PASS\nn\nY\n$MYSQL_NEW_PASS\n$MYSQL_NEW_PASS\nY\nY\nY\nY\n" | sudo mariadb-secure-installation
2025-10-09 18:42:33 -07:00
2025-10-09 20:06:01 -07:00
# WordPress
curl https://wordpress.org/latest.zip -o /tmp/wordpress.zip
sudo unzip -d /var/www/html /tmp/wordpress.zip
2025-10-09 20:19:31 -07:00
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
2025-10-09 20:21:34 -07:00
sudo sed -i "s|define( 'DB_NAME', 'database_name_here' );|define( 'DB_NAME', '$WORDPRESS_DATABASE_NAME' );|" /var/www/html/wordpress/wp-config.php
sudo sed -i "s|define( 'DB_USER', 'username_here' );|define( 'DB_USER', 'root' );|" /var/www/html/wordpress/wp-config.php
sudo sed -i "s|define( 'DB_PASSWORD', 'password_here' );|define( 'DB_PASSWORD', '$MYSQL_NEW_PASS' );|" /var/www/html/wordpress/wp-config.php