Snippets

Benjamin J. DeLong Install Wordpress script

Created by Benjamin J. DeLong
#!/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

if [[ $1 ]]; then
    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

echo "All done!"

sudo chown -R bozdoz:www-data ./

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.