Skip to content

Instantly share code, notes, and snippets.

@benallfree
Last active August 15, 2018 01:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benallfree/86236e4c20e0f453412f to your computer and use it in GitHub Desktop.
Save benallfree/86236e4c20e0f453412f to your computer and use it in GitHub Desktop.
Ubuntu LAMP++ (Ubuntu 18.04.1 LTS / Apache / PHP 7.2 / Beanstalk / Certbot / git / composer / git-lfs)
#!/bin/bash
SSHPK="..."
MYSQLP="..."
MYSQLDB="..."
USERP="..."
ufw allow http
ufw allow https
ufw allow mysql
ufw allow ssh
echo y | ufw enable
mkdir ~/.ssh
echo "$SSHPK" >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
apt-get -y update
apt-get -y upgrade
debconf-set-selections <<< "mysql-server mysql-server/root_password password $MYSQLP"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $MYSQLP"
apt-get -y install apache2 mysql-server curl libcurl4 libcurl4-openssl-dev git-core zip unzip
add-apt-repository ppa:ondrej/apache2
apt-get update
apt-cache pkgnames | grep php7
apt-get install -y php7.2 php7.2-curl libapache2-mod-php7.2 php7.2-cli php7.2-common php7.2-mbstring php7.2-gd php7.2-intl php7.2-xml php7.2-mysql php7.2-zip
# Install git-lfs
apt-get -y install software-properties-common
add-apt-repository ppa:git-core/ppa
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
apt-get -y install git-lfs
git lfs install
# Install NVM and yarn
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get -y update
sudo apt-get -y install yarn
# Install PNG support
sudo apt-get install gcc make libpng-dev
mysql -uroot -p$MYSQLP <<< "create database $MYSQLDB;"
a2enmod rewrite
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer global require hirak/prestissimo
cd /etc/skel
git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt
curl -sSL https://gist.github.com/benallfree/e2a687e994d570a66626.txt >> .bashrc
useradd -m -p "$USERP" -s /bin/bash user
mkdir -p /home/user/public_html
curl -sSL https://gist.github.com/benallfree/8ff71a873e6a610afccf.txt > /home/user/public_html/whoami.php
chmod -R 755 /home/user/public_html
chown -R user:user /home/user/public_html
mkdir /home/user/.ssh
echo "$SSHPK" >> /home/user/.ssh/authorized_keys
ssh-keygen -q -N "" -f /home/user/.ssh/id_rsa
chown -R user:user /home/user/.ssh
chmod 700 /home/user/.ssh
chmod 600 /home/user/.ssh/*
sed -i 's/www-data/user/g' /etc/apache2/envvars
curl -sSL https://gist.github.com/benallfree/724c3fd1843688aa9805.txt > /etc/apache2/sites-enabled/000-default.conf
# Now go edit and add the ServerName domain for SSL
add-apt-repository ppa:certbot/certbot
apt-get -y update
apt-get -y install python-certbot-apache
certbot --apache
# # Add Beanstalkd for Laravel
apt-get -y install beanstalkd
apt-get -y install supervisor
apache2ctl stop
sleep 10
apache2ctl start
visudo
%sudo ALL=(ALL) NOPASSWD:ALL
usermod -aG sudo user
### Test your installation
http://<ip>/whoami.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment