Skip to content

Instantly share code, notes, and snippets.

@rsgalloway
Last active February 19, 2018 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsgalloway/8c6135b7e9ffa240082e23337dd3b2d4 to your computer and use it in GitHub Desktop.
Save rsgalloway/8c6135b7e9ffa240082e23337dd3b2d4 to your computer and use it in GitHub Desktop.
#!/bin/bash
##
#<UDF name="ssuser" Label="New user" example="username" />
#<UDF name="sspassword" Label="New user password" example="Password" />
#<UDF name="hostname" Label="Hostname" example="examplehost" />
#<UDF name="website" Label="Website" example="example.com" />
# <UDF name="db_password" Label="MySQL root Password" />
# <UDF name="db_name" Label="Create Database" default="" example="Create database" />
# add sudo user
adduser $SSUSER --disabled-password --gecos "" && \
echo "$SSUSER:$SSPASSWORD" | chpasswd
adduser $SSUSER sudo
# updates
apt-get -o Acquire::ForceIPv4=true update -y
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" install grub-pc
apt-get -o Acquire::ForceIPv4=true update -y
# SET HOSTNAME
hostnamectl set-hostname $HOSTNAME
echo "127.0.0.1 $HOSTNAME" >> /etc/hosts
# INSTALL APACHE
apt-get install apache2 -y
# edit apache config
sed -ie "s/KeepAlive Off/KeepAlive On/g" /etc/apache2/apache2.conf
# create a copy of the default Apache configuration file for your site:
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/$WEBSITE.conf
# configuration of vhost file
cat <<END >/etc/apache2/sites-available/$WEBSITE.conf
<Directory /var/www/html/$WEBSITE/public_html>
Require all granted
</Directory>
<VirtualHost *:80>
ServerName $WEBSITE
ServerAlias www.$WEBSITE
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/$WEBSITE/public_html
ErrorLog /var/www/html/$WEBSITE/logs/error.log
CustomLog /var/www/html/$WEBSITE/logs/access.log combined
</VirtualHost>
END
# create website html directory
mkdir -p /var/www/html/$WEBSITE/{public_html,logs}
cd /var/www/html/$WEBSITE/public_html/
echo "<h1>Stackscript: Ubuntu 16.04 LAMP successfully installed :D<h1/></html>" > index.html
# remove default html page
cd
rm /var/www/html/index.html
# link your virtual host file from the sites-available directory to the sites-enabled directory:
sudo a2ensite $WEBSITE.conf
# disable the default virtual host to minimize security risks:
a2dissite 000-default.conf
# restart apache
systemctl reload apache2
systemctl restart apache2
# install MySQL Server in a Non-Interactive mode. Default root password will be "root"
echo "mysql-server mysql-server/root_password password $DB_PASSWORD" | sudo debconf-set-selections
echo "mysql-server mysql-server/root_password_again password $DB_PASSWORD" | sudo debconf-set-selections
apt-get install mysql-server -y
mysql -uroot -p$DB_PASSWORD -e "create database $DB_NAME"
service mysql restart
# installing php
#apt-get install php7.0 php-pear libapache2-mod-php7.0 php7.0-mysql -y
# installing wsgi
apt-get install libapache2-mod-wsgi -y
a2enmod wsgi
# making directory for php? giving apache permissions to that log? restarting php
mkdir /var/log/php
chown www-data /var/log/php
systemctl restart apache2
# install git
apt-get install git -y
# install libjpeg-dev with apt
apt-get install libjpeg-dev
# if you're on Ubuntu 14.04, also install this
apt-get install libjpeg8-dev
# python modules
apt-get install python-pip -y
apt-get install python-mysqldb -y
apt-get install python-virtualenv -y
pip install --upgrade pip
pip install -U pyseq
pip install -U sqlalchemy
pip install -U Flask
pip install -U boto
pip install -U pyyaml
pip install -U requests
pip install -U restclient
pip install -U blinker
# for current_user.is_authenticated() bool error
#pip install -Flask-Login==0.2.6
pip install -U Flask-Login
pip install -U flask-wtf
pip install -U flask-mail
pip install --no-cache-dir -I pillow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment