Created
June 16, 2017 00:30
-
-
Save bozdoz/4353103dd80bcb314503f9048cdb305c to your computer and use it in GitHub Desktop.
Wordpress Full Install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rm latest.tar.gz | |
wget https://wordpress.org/latest.tar.gz | |
tar -xzvf latest.tar.gz | |
if [[ $1 ]]; then | |
mv wordpress $1 | |
cd $1 | |
else | |
cd wordpress | |
fi | |
cp wp-config-sample.php wp-config.php | |
# output salt stuff | |
curl https://api.wordpress.org/secret-key/1.1/salt/ > wp-keys.txt | |
sudo sed -i '/#@-/r wp-keys.txt' wp-config.php | |
sudo sed -i "/#@+/,/#@-/d" wp-config.php | |
rm wp-keys.txt | |
if [[ $1 ]]; then | |
echo "mysql root password:" | |
read rootpass | |
if [[ $rootpass ]]; then | |
# create db | |
# create user | |
mysql -uroot -p$rootpass <<EOF | |
CREATE DATABASE \`${1}\`; | |
CREATE USER $1@localhost IDENTIFIED BY '$1'; | |
GRANT ALL PRIVILEGES ON \`${1}\`.* TO \`${1}\`@'localhost'; | |
EOF | |
fi | |
sudo sed -i "s/database_name_here/$1/" wp-config.php | |
sudo sed -i "s/username_here/$1/" wp-config.php | |
sudo sed -i "s/password_here/$1/" wp-config.php | |
echo "apache port (4 numbers):" | |
read port | |
cat > /etc/apache2/sites-available/$1.conf <<EOF | |
Listen $port | |
<VirtualHost *:$port> | |
DirectoryIndex index.html index.php | |
DocumentRoot /var/www/$1/ | |
<Directory "/var/www/$1/"> | |
Options FollowSymLinks | |
AllowOverride All | |
Order allow,deny | |
Allow from all | |
</Directory> | |
LogLevel warn | |
ErrorLog /var/log/error.log | |
CustomLog /var/log/access.log combined | |
</VirtualHost> | |
EOF | |
sudo a2ensite $1 | |
sudo service apache2 reload | |
fi | |
# harden | |
find ./ -type d -exec chmod 755 {} \; | |
find ./ -type f -exec chmod 644 {} \; | |
# use your username to allow to edit with an editor; group for wordpress editor | |
# sudo chown -R bozdoz:www-data ./ | |
# fix for updating plugins | |
sudo chown -R www-data:www-data wp-content | |
echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment