Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "A Wordpress website creation script"
- read -p "Website Name: " WEBNAME
- read -p "Website Url (excluding www prefix): " WEBURL
- read -p "PHP-FPM Port: " PORT
- read -p "Database Name: " DBNAME
- read -p "Database User: " DBUSER
- read -p "Database Password: " DBPWD
- echo "Creating database..."
- mysql -uroot -pYourRootPasswordHere <<EOF
- CREATE DATABASE $DBNAME;
- CREATE USER $DBUSER@localhost IDENTIFIED BY "$DBPWD";
- GRANT ALL PRIVILEGES ON $DBNAME.* TO $DBUSER@localhost IDENTIFIED BY "$DBPWD";
- FLUSH PRIVILEGES;
- exit
- EOF
- echo "Creating nginx config..."
- cat /home/user/wp >> /etc/nginx/sites-enabled/$WEBNAME
- echo "Replacing values..."
- sed -i 's/domain.ext/'$WEBURL'/g' /etc/nginx/sites-enabled/$WEBNAME
- sed -i 's/900x/'$PORT'/g' /etc/nginx/sites-enabled/$WEBNAME
- sed -i 's/site_files_here/'$WEBNAME'/g' /etc/nginx/sites-enabled/$WEBNAME
- echo "Creating wordpress files..."
- cp -a /home/user/downloads/wordpress /usr/share/nginx/$WEBNAME
- chown www-data:www-data /usr/share/nginx/$WEBNAME -R
- echo "Replacing wp-config.php values..."
- sed -i 's/database_name_here/'$DBNAME'/g' /usr/share/nginx/$WEBNAME/wp-config.php
- sed -i 's/username_here/'$DBUSER'/g' /usr/share/nginx/$WEBNAME/wp-config.php
- sed -i 's/password_here/'$DBPWD'/g' /usr/share/nginx/$WEBNAME/wp-config.php
- echo "Creating php-fpm pool config..."
- cat /home/user/default.conf >> /etc/php/7.0/fpm/pool.d/$WEBNAME.conf
- echo "Replacing values..."
- sed -i 's/pool_name_here/'$WEBNAME'/g' /etc/php/7.0/fpm/pool.d/$WEBNAME.conf
- sed -i 's/900x/'$PORT'/g' /etc/php/7.0/fpm/pool.d/$WEBNAME.conf
- echo "Restarting services..."
- service php7.0-fpm restart
- service nginx restart
- certbot --nginx -d www.$WEBURL
- echo "All done! =D"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement