-
-
Save jstnbr/24ae37d21ec2b900461c0bfe9f6718a7 to your computer and use it in GitHub Desktop.
Configuration script to prep and install Laravel 5.6 on Ubuntu 16.04
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 | |
# /*================================= | |
# = VARIABLES = | |
# =================================*/ | |
WELCOME_MESSAGE=' | |
____ ____ ____ ____ ____ | |
||N ||||G ||||I ||||N ||||X || | |
||__||||__||||__||||__||||__|| | |
|/__\||/__\||/__\||/__\||/__\| | |
' | |
reboot_webserver_helper() { | |
sudo systemctl restart php7.2-fpm | |
sudo systemctl restart nginx | |
echo 'Rebooting your webserver' | |
} | |
# /*========================================= | |
# = CORE / BASE STUFF = | |
# =========================================*/ | |
sudo apt-get update | |
# The following is "sudo apt-get -y upgrade" without any prompts | |
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade | |
sudo apt-get install -y build-essential | |
sudo apt-get install -y tcl | |
sudo apt-get install -y software-properties-common | |
sudo apt-get install -y python-software-properties | |
sudo apt-get -y install vim | |
sudo apt-get -y install git | |
# Weird Vagrant issue fix | |
#sudo apt-get install -y ifupdown | |
# /*===================================== | |
# = INSTALL NGINX = | |
# =====================================*/ | |
sudo add-apt-repository -y ppa:ondrej/nginx-mainline # Super Latest Version | |
sudo apt-get update | |
sudo apt-get -y install nginx | |
sudo systemctl enable nginx | |
# Remove "html" and add public | |
mv /var/www/html /var/www/public | |
# Make sure your web server knows you did this... | |
MY_WEB_CONFIG='server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/public; | |
index index.html index.htm index.nginx-debian.html; | |
server_name _; | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
}' | |
echo "$MY_WEB_CONFIG" | sudo tee /etc/nginx/sites-available/default | |
sudo systemctl restart nginx | |
# /*=================================== | |
# = INSTALL PHP = | |
# ===================================*/ | |
# Install PHP | |
sudo add-apt-repository -y ppa:ondrej/php # Super Latest Version (currently 7.2) | |
sudo apt-get update | |
sudo apt-get install -y php7.2 | |
# Make PHP and NGINX friends | |
# FPM STUFF | |
sudo apt-get -y install php7.2-fpm | |
sudo systemctl enable php7.2-fpm | |
sudo systemctl start php7.2-fpm | |
# Fix path FPM setting | |
echo 'cgi.fix_pathinfo = 0' | sudo tee -a /etc/php/7.2/fpm/conf.d/user.ini | |
sudo systemctl restart php7.2-fpm | |
# Add index.php to readable file types and enable PHP FPM since PHP alone won't work | |
MY_WEB_CONFIG='server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/public; | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name _; | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/run/php/php7.2-fpm.sock; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
}' | |
echo "$MY_WEB_CONFIG" | sudo tee /etc/nginx/sites-available/default | |
sudo systemctl restart nginx | |
# /*=================================== | |
# = PHP MODULES = | |
# ===================================*/ | |
# Base Stuff | |
sudo apt-get -y install php7.2-common | |
sudo apt-get -y install php7.2-dev | |
# Common Useful Stuff (some of these are probably already installed) | |
sudo apt-get -y install php7.2-bcmath | |
sudo apt-get -y install php7.2-bz2 | |
sudo apt-get -y install php7.2-cgi | |
sudo apt-get -y install php7.2-cli | |
sudo apt-get -y install php7.2-fpm | |
sudo apt-get -y install php7.2-gd | |
sudo apt-get -y install php7.2-imap | |
sudo apt-get -y install php7.2-intl | |
sudo apt-get -y install php7.2-json | |
sudo apt-get -y install php7.2-mbstring | |
sudo apt-get -y install php7.2-odbc | |
sudo apt-get -y install php-pear | |
sudo apt-get -y install php7.2-pspell | |
sudo apt-get -y install php7.2-tidy | |
sudo apt-get -y install php7.2-xmlrpc | |
sudo apt-get -y install php7.2-zip | |
# Enchant | |
sudo apt-get -y install libenchant-dev | |
sudo apt-get -y install php7.2-enchant | |
# LDAP | |
sudo apt-get -y install ldap-utils | |
sudo apt-get -y install php7.2-ldap | |
# CURL | |
sudo apt-get -y install curl | |
sudo apt-get -y install php7.2-curl | |
# IMAGE MAGIC | |
sudo apt-get -y install imagemagick | |
sudo apt-get -y install php7.2-imagick | |
# /*=========================================== | |
# = CUSTOM PHP SETTINGS = | |
# ===========================================*/ | |
PHP_USER_INI_PATH=/etc/php/7.2/fpm/conf.d/user.ini | |
echo 'display_startup_errors = On' | sudo tee -a $PHP_USER_INI_PATH | |
echo 'display_errors = On' | sudo tee -a $PHP_USER_INI_PATH | |
echo 'error_reporting = E_ALL' | sudo tee -a $PHP_USER_INI_PATH | |
echo 'short_open_tag = On' | sudo tee -a $PHP_USER_INI_PATH | |
reboot_webserver_helper | |
# Disable PHP Zend OPcache | |
echo 'opache.enable = 0' | sudo tee -a $PHP_USER_INI_PATH | |
# Absolutely Force Zend OPcache off... | |
sudo sed -i s,\;opcache.enable=0,opcache.enable=0,g /etc/php/7.2/fpm/php.ini | |
reboot_webserver_helper | |
# /*================================ | |
# = PHP UNIT = | |
# ================================*/ | |
sudo wget https://phar.phpunit.de/phpunit-6.1.phar | |
sudo chmod +x phpunit-6.1.phar | |
sudo mv phpunit-6.1.phar /usr/local/bin/phpunit | |
reboot_webserver_helper | |
# /*============================= | |
# = MYSQL = | |
# =============================*/ | |
#sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root' | |
#sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root' | |
#sudo apt-get -y install mysql-server | |
#sudo mysqladmin -uroot -proot create scotchbox | |
#sudo apt-get -y install php7.2-mysql | |
#reboot_webserver_helper | |
# /*================================= | |
# = PostreSQL = | |
# =================================*/ | |
#sudo apt-get -y install postgresql postgresql-contrib | |
#echo "CREATE ROLE root WITH LOGIN ENCRYPTED PASSWORD 'root';" | sudo -i -u postgres psql | |
#sudo -i -u postgres createdb --owner=root scotchbox | |
#sudo apt-get -y install php7.2-pgsql | |
#reboot_webserver_helper | |
# /*============================== | |
# = SQLITE = | |
# ===============================*/ | |
#sudo apt-get -y install sqlite | |
#sudo apt-get -y install php7.2-sqlite3 | |
#reboot_webserver_helper | |
# /*=============================== | |
# = MONGODB = | |
# ===============================*/ | |
#sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 | |
#echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list | |
#sudo apt-get update | |
#sudo apt-get install -y mongodb-org | |
#sudo tee /lib/systemd/system/mongod.service <<EOL | |
#[Unit] | |
#Description=High-performance, schema-free document-oriented database | |
#After=network.target | |
#Documentation=https://docs.mongodb.org/manual | |
#[Service] | |
#User=mongodb | |
#Group=mongodb | |
#ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf | |
#[Install] | |
#WantedBy=multi-user.target | |
#EOL | |
#sudo systemctl enable mongod | |
#sudo service mongod start | |
# Enable it for PHP | |
#sudo pecl install mongodb | |
#sudo apt-get install -y php7.2-mongodb | |
#reboot_webserver_helper | |
# /*================================ | |
# = COMPOSER = | |
# ================================*/ | |
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") | |
php composer-setup.php --quiet | |
rm composer-setup.php | |
sudo mv composer.phar /usr/local/bin/composer | |
sudo chmod 755 /usr/local/bin/composer | |
# /*================================== | |
# = BEANSTALKD = | |
# ==================================*/ | |
#sudo apt-get -y install beanstalkd | |
# /*============================== | |
# = WP-CLI = | |
# ==============================*/ | |
#curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
#sudo chmod +x wp-cli.phar | |
#sudo mv wp-cli.phar /usr/local/bin/wp | |
# /*============================= | |
# = DRUSH = | |
# =============================*/ | |
#wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/download/0.5.1/drush.phar | |
#sudo chmod +x drush.phar | |
#sudo mv drush.phar /usr/local/bin/drush | |
# /*============================= | |
# = NGROK = | |
# =============================*/ | |
#sudo apt-get install ngrok-client | |
# /*============================== | |
# = NODEJS = | |
# ==============================*/ | |
sudo apt-get -y install nodejs | |
sudo apt-get -y install npm | |
# Use NVM though to make life easy | |
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | bash | |
source ~/.nvm/nvm.sh | |
nvm install 8.9.4 | |
# Node Packages | |
sudo npm install -g gulp | |
sudo npm install -g grunt | |
sudo npm install -g bower | |
sudo npm install -g yo | |
sudo npm install -g browser-sync | |
sudo npm install -g browserify | |
sudo npm install -g pm2 | |
sudo npm install -g webpack | |
# /*============================ | |
# = YARN = | |
# ============================*/ | |
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 update | |
sudo apt-get -y install yarn | |
# /*============================ | |
# = RUBY = | |
# ============================*/ | |
sudo apt-get -y install ruby | |
sudo apt-get -y install ruby-dev | |
# Use RVM though to make life easy | |
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | |
\curl -sSL https://get.rvm.io | bash -s stable | |
source ~/.rvm/scripts/rvm | |
rvm install 2.5.0 | |
rvm use 2.5.0 | |
# /*============================= | |
# = REDIS = | |
# =============================*/ | |
sudo apt-get -y install redis-server | |
sudo apt-get -y install php7.2-redis | |
reboot_webserver_helper | |
# /*================================= | |
# = MEMCACHED = | |
# =================================*/ | |
sudo apt-get -y install memcached | |
sudo apt-get -y install php7.2-memcached | |
reboot_webserver_helper | |
# /*============================== | |
# = GOLANG = | |
# ==============================*/ | |
sudo add-apt-repository -y ppa:longsleep/golang-backports | |
sudo apt-get update | |
sudo apt-get -y install golang-go | |
# /*=============================== | |
# = MAILHOG = | |
# ===============================*/ | |
sudo wget --quiet -O ~/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64 | |
sudo chmod +x ~/mailhog | |
# Enable and Turn on | |
sudo tee /etc/systemd/system/mailhog.service <<EOL | |
[Unit] | |
Description=MailHog Service | |
After=network.service vagrant.mount | |
[Service] | |
Type=simple | |
ExecStart=/usr/bin/env /home/vagrant/mailhog > /dev/null 2>&1 & | |
[Install] | |
WantedBy=multi-user.target | |
EOL | |
sudo systemctl enable mailhog | |
sudo systemctl start mailhog | |
# Install Sendmail replacement for MailHog | |
sudo go get github.com/mailhog/mhsendmail | |
sudo ln ~/go/bin/mhsendmail /usr/bin/mhsendmail | |
sudo ln ~/go/bin/mhsendmail /usr/bin/sendmail | |
sudo ln ~/go/bin/mhsendmail /usr/bin/mail | |
# Make it work with PHP | |
echo 'sendmail_path = /usr/bin/mhsendmail' | sudo tee -a /etc/php/7.2/fpm/conf.d/user.ini | |
reboot_webserver_helper | |
# /*======================================= | |
# = WELCOME MESSAGE = | |
# =======================================*/ | |
# Disable default messages by removing execute privilege | |
sudo chmod -x /etc/update-motd.d/* | |
# Set the new message | |
echo "$WELCOME_MESSAGE" | sudo tee /etc/motd | |
# /*=================================================== | |
# = LAST UPDATE FOR GOOD MEASURE = | |
# ===================================================*/ | |
sudo apt-get update | |
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade | |
reboot_webserver_helper | |
# /*==================================== | |
# = Thats All!!! = | |
# ====================================*/ | |
echo 'Time to log in an kick the tires!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment