autoinstallers/alma-x64/wp

156 lines
4.5 KiB
Plaintext
Raw Permalink Normal View History

2022-05-31 20:58:06 -04:00
#!/bin/bash
2022-05-31 19:28:17 -04:00
echo "Welcome to the Discord-Linux Wordpress Automated installer"
echo "This will install Apache, MySQL, PHP and Wordpress on your system"
echo "The install will be located at /var/www/html"
echo "downloading the Notification Bot"
wget -q -O /usr/bin/notif https://ssh.surf/debian/notif && chmod +x /usr/bin/notif
2022-05-31 19:28:17 -04:00
notif "Welcome to the Wordpress Automated installer for Discord-Linux, We are preparing your installation..."
yum install dnf-plugins-core sudo -y
yum config-manager --set-enabled powertools
2022-05-31 19:28:17 -04:00
yum groupinstall 'Development Tools' -y
2022-05-31 19:28:17 -04:00
echo "Installing dependencies for Apache and PHP"
2022-05-31 19:28:17 -04:00
notif "Installing dependencies for Apache and PHP"
#sudo add-apt-repository ppa:ondrej/php
#sudo apt update
sudo dnf install httpd httpd-tools -y
sudo dnf module reset php -y
sudo dnf module enable php:7.4 -y
sudo dnf install php php-common php-opcache php-cli php-gd php-curl php-mysqlnd zip unzip php-zip php-intl php-gd php-pear php-devel -y
sudo dnf install mariadb-server -y
2022-05-31 19:28:17 -04:00
sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf
notif "Installing MySQL 8"
echo "Installing MySQL 8"
echo "Starting MySQL 8"
2022-05-31 19:28:17 -04:00
service mariadb start
notif "Sleeping for 5 seconds to allow MySQL to start."
echo "Sleeping 5 seconds to allow MySQL to start"
sleep 5
2022-05-31 19:28:17 -04:00
echo "creating database with random strings for dbname, dbuser and dbpassword"
DBNAME=$(openssl rand -hex 12)
USERNAME=$(openssl rand -hex 12)
PASSWORD=$(openssl rand -hex 12)
mysql -uroot -e "CREATE DATABASE $DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci";
mysql -uroot -e "CREATE USER $USERNAME@'127.0.0.1' IDENTIFIED BY '$PASSWORD'";
mysql -uroot -e "GRANT ALL PRIVILEGES ON $DBNAME.* TO '$USERNAME'@'127.0.0.1'";
2022-05-31 19:28:17 -04:00
notif "We have created the following Database information for this installaton: Database:$DBNAME|Username:$USERNAME|Password:$PASSWORD"
2022-05-31 19:28:17 -04:00
echo "Database and user created."
#https://askubuntu.com/questions/916199/install-apt-show-versions-inside-an-ubuntu-docker-container
echo "Fixing SystemD"
sh /var/tools/getsystemctl.sh
echo "Installing Wordpress base"
wget -O /var/www/html/latest.tar.gz https://wordpress.org/latest.tar.gz
#unzip wordpress
cd /var/www/html && tar -zxvf latest.tar.gz
#change dir to wordpress
cd /var/www/html/wordpress
#copy file to parent dir
cp -rf . ..
#move back to parent dir
cd ..
#remove files from wordpress folder
rm -R wordpress
#create wp config
cp wp-config-sample.php wp-config.php
echo "Setting up WP DB Config"
#set database details with perl find and replace
perl -pi -e "s/database_name_here/$DBNAME/g" /var/www/html/wp-config.php
perl -pi -e "s/username_here/$USERNAME/g" /var/www/html/wp-config.php
perl -pi -e "s/password_here/$PASSWORD/g" /var/www/html/wp-config.php
perl -pi -e "s/localhost/127.0.0.1/g" /var/www/html/wp-config.php
2022-05-31 19:28:17 -04:00
#set WP salts
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/put your unique phrase here/salt()/ge
' /var/www/html/wp-config.php
#create uploads folder and set permissions
mkdir /var/www/html/wp-content/uploads
chmod 775 /var/www/html/wp-content/uploads
mkdir -p /var/www/temp
chmod 755 /var/www/temp
echo "Installing WP CLI"
# installing wp cli
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
echo "Setting Custom ENV"
cd /var/www/html/ && wp config set FS_METHOD \'direct\' --raw --type=constant --allow-root
cd /var/www/html/ && wp config set 'WP_TEMP_DIR' \'/var/www/temp\' --raw --type=constant --allow-root
echo "repairing ownership and permissions"
chown -R www-data:www-data /var/www/html/
chown -R www-data:www-data /var/www/temp
find /var/www/html/ -type d -exec chmod 755 {} \;
find /var/www/html/ -type f -exec chmod 644 {} \;
rm -f /var/www/html/index.html
sed -i "3 iif ( (\!empty( \$_SERVER['HTTP_X_FORWARDED_HOST'])) || (\!empty( \$_SERVER['HTTP_X_FORWARDED_FOR'])) ) { \$_SERVER['HTTPS'] = 'on'; }" /var/www/html/wp-config.php
echo "Cleaning..."
#remove zip file
rm latest.tar.gz
echo "Setting serverName ENV"
echo "serverName $(hostname)" >> /etc/httpd/conf/httpd.conf
2022-05-31 19:28:17 -04:00
echo "starting webserver"
sudo systemctl start php-fpm
2022-05-31 19:28:17 -04:00
service httpd restart
sed -i "s/#wp/service mysql start \&\& service httpd start/g" /start.sh
2022-05-31 19:28:17 -04:00
echo "========================="
echo "Installation is complete."
echo "========================="
notif "The Wordpress installation is complete, please complete your installation at your HTTP Port."
2022-05-31 19:28:17 -04:00