Skip to content

Instantly share code, notes, and snippets.

@irisjae
Last active July 9, 2018 09:41
Show Gist options
  • Save irisjae/6a86bcfedd71a38ab31321e9e99eeac3 to your computer and use it in GitHub Desktop.
Save irisjae/6a86bcfedd71a38ab31321e9e99eeac3 to your computer and use it in GitHub Desktop.
Wordpress LAMP
function bare_install_lamp {
sudo apt-get install apache2
sudo apt-get install mysql-server
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
}
function install_lamp {
sudo apt-get update
bare_install_lamp
setup_apache
setup_mysql
setup_php
sudo service apache2 restart
}
function install_ssl {
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache
sudo certbot --apache
}
function renew_ssl {
sudo certbot renew
}
function setup_apache {
sudo a2enmod rewrite
enable_permalink="$(cat << 'EOF'
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
EOF
)"
sudo sed -i '/DocumentRoot \/var\/www\/html/a\'"$(echo "$enable_permalink" | sed -z "s/\n/\\\\n/g" | sed "s/\//\\\\\//g")" /etc/apache2/sites-available/000-default.conf
}
function setup_mysql {
password="password"
user="wordpress"
db="wordpress"
echo "Please enter root user MySQL password!"
read rootpasswd
mysql -uroot -p${rootpasswd} -e "CREATE DATABASE ${db} /*\!40100 DEFAULT CHARACTER SET utf8 */;"
mysql -uroot -p${rootpasswd} -e "CREATE USER ${user}@localhost IDENTIFIED BY '${password}';"
mysql -uroot -p${rootpasswd} -e "GRANT ALL PRIVILEGES ON ${db}.* TO '${user}'@'localhost';"
mysql -uroot -p${rootpasswd} -e "FLUSH PRIVILEGES;"
}
function setup_php {
sudo apt-get install php-cli php-zip php-gd php-xml
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R g+rw /var/www/html
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment