Skip to content

Instantly share code, notes, and snippets.

@levabd
Last active January 23, 2017 05:42
Show Gist options
  • Save levabd/13c3213830cecacbd347 to your computer and use it in GitHub Desktop.
Save levabd/13c3213830cecacbd347 to your computer and use it in GitHub Desktop.
Laravel 5.2 recipe for stack-updater

Simple Laravel 5.2 stack with web serer (php-fpm) and db drivers

  • NGINX
  • PHP7
  • PHP mongo driver for php-fpm and php-cli
  • PHP mbstring module
  • PHP bz2 module
  • PHP imagick module
  • Memcached + PHP memcached
  • Mysql PHP driver
  • Postgre PHP driver
  • Composer
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
apt-get update
apt-get install -y curl
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
[
{
"name": "Nginx",
"command": "/usr/bin/dpkg -l | awk '$2==\"nginx\" { print $3 }'",
"required": "1.10.1",
"comparison": ">=",
"installer": "nginx.sh",
"order": "1"
},
{
"name": "PHP",
"command": "/usr/bin/php -r 'echo phpversion();'",
"required": "7.0.9",
"comparison": ">=",
"installer": "php7.sh",
"order": "2"
},
{
"name": "MBString for PHP7",
"command": "/usr/bin/php -r 'echo phpversion(\"mbstring\");'",
"required": "7.0.9",
"comparison": ">=",
"installer": "php7mbstring.sh",
"order": "3"
},
{
"name": "BZ2 for PHP7",
"command": "/usr/bin/php -r 'echo phpversion(\"bz2\");'",
"required": "7.0.9",
"comparison": ">=",
"installer": "php7bz2.sh",
"order": "4"
},
{
"name": "Postgres driver for PHP7",
"command": "/usr/bin/dpkg -l | awk '$2==\"php7.0-pgsql\" { print $3 }'",
"required": "7.0.9",
"comparison": ">=",
"installer": "php7pgsql.sh",
"order": "5"
},
{
"name": "Imagick for PHP7",
"command": "/usr/bin/php -r 'echo phpversion(\"imagick\");'",
"required": "3.4.0",
"comparison": ">=",
"installer": "php7imagick.sh",
"order": "6"
},
{
"name": "Composer",
"command": "/usr/local/bin/composer -V | awk '{ print $3 }'",
"required": "1.2.0",
"comparison": ">=",
"installer": "composer.sh",
"order": "7"
}
]
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
echo "deb http://nginx.org/packages/debian/ jessie nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
wget -qO - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
apt-get update
apt-get remove -y apache2*
apt-get purge -y apache2*
apt-get autoremove -y
rm -rf /etc/apache2
apt-get install -y nginx
sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx restart
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
apt-get remove -y php5*
apt-get purge -y php5*
apt-get install -y software-properties-common python-software-properties
sudo locale-gen en_US.UTF-8
#export LC_ALL=en_US.UTF-8 && add-apt-repository ppa:ondrej/php -y
echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/php7.list
apt-get update
apt-get install -y php7.0 php7.0-fpm php7.0-dev php7.0-cli
apt-get install -y php7.0-gd php7.0-curl php7.0-curl php7.0-mcrypt php7.0-sqlite3 php7.0-json php-pear
phpenmod mcrypt
phpenmod gd
phpenmod curl
phpenmod sqlite3
phpenmod json
sudo /etc/init.d/php7.0-fpm start
sudo /etc/init.d/php7.0-fpm restart
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
apt-get update
apt-get install php7.0-bz2
sudo /etc/init.d/php7.0-fpm start
sudo /etc/init.d/php7.0-fpm restart
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
sudo locale-gen en_US.UTF-8
#export LC_ALL=en_US.UTF-8 && add-apt-repository ppa:ondrej/php -y
echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/php7.list
apt-get update
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
cd imagick-3.4.0
phpize
./configure
make install
rm -rf /tmp/imagick-3.4.0*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
echo extension=imagick.so >> /etc/php/7.0/fpm/php.ini
sudo /etc/init.d/php7.0-fpm start
sudo /etc/init.d/php7.0-fpm restart
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
apt-get update
apt-get install php7.0-mbstring
phpenmod mbstring
sudo /etc/init.d/php7.0-fpm start
sudo /etc/init.d/php7.0-fpm restart
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
apt-get update
apt-get install php7.0-memcached
phpenmod memcached
sudo /etc/init.d/php7.0-fpm start
sudo /etc/init.d/php7.0-fpm restart
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
# Get key and add to sources
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
# Debian cant use Upstart syste? but Ubuntu can use SysV. That's why we use debian repo instead ubuntu repo
echo "deb http://repo.mongodb.org/apt/debian/ wheezy/mongodb-org/3.2 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
# Update
sudo apt-get update --fix-missing
# Install MongoDB
sudo apt-get install -y mongodb-org
# install dependencies
sudo apt-get install --yes --force-yes liblua5.1-0-dev liblua50-dev liblualib50-dev
sudo apt-get install --yes --force-yes autoconf g++ make openssl libssl-dev libcurl4-openssl-dev pkg-config libsasl2-dev libpcre3-dev
sudo apt-get upgrade --yes --fix-missing
#fix libtool symlink according to https://github.com/mongodb/mongo-php-driver/issues/255#issuecomment-194243738
sudo rm /usr/lib/php/20151012/build/ltmain.sh
#Debian wheeze
#sudo ln -s /usr/share/libtool/build-aux/ltmain.sh /usr/lib/php/20151012/build/ltmain.sh
#Debian jessie and new ubuntu
sudo ln -s /usr/share/libtool/config/ltmain.sh /usr/lib/php/20151012/build/ltmain.sh
# install php extension
echo ">>> Start sudo pecl install mongodb"
sudo pecl install -f mongodb
sudo pecl upgrade mongodb
echo ">>> End sudo pecl install mongodb"
# add extension file and restart service
sudo bash -c 'echo "extension=mongodb.so" >> /etc/php/7.0/cli/php.ini'
sudo bash -c 'echo "extension=mongodb.so" >> /etc/php/7.0/fpm/php.ini'
sudo service php7.0-fpm restart
echo ">>> End to Install MongoDB"
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
sudo locale-gen en_US.UTF-8
#export LC_ALL=en_US.UTF-8 && add-apt-repository ppa:ondrej/php -y
echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/php7.list
apt-get update
apt-get install -y php7.0-mysql
sudo /etc/init.d/php7.0-fpm start
sudo /etc/init.d/php7.0-fpm restart
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
sudo locale-gen en_US.UTF-8
#export LC_ALL=en_US.UTF-8 && add-apt-repository ppa:ondrej/php -y
echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/php7.list
# for php7.0-pgsql and Debian wheezy
echo "Importing repository signing key ..."
test -e "/etc/apt/trusted.gpg.d/apt.postgresql.org.gpg" || touch "/etc/apt/trusted.gpg.d/apt.postgresql.org.gpg"
sudo apt-key --keyring "/etc/apt/trusted.gpg.d/apt.postgresql.org.gpg" add - <<EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQINBE6XR8IBEACVdDKT2HEH1IyHzXkb4nIWAY7echjRxo7MTcj4vbXAyBKOfjja
UrBEJWHN6fjKJXOYWXHLIYg0hOGeW9qcSiaa1/rYIbOzjfGfhE4x0Y+NJHS1db0V
G6GUj3qXaeyqIJGS2z7m0Thy4Lgr/LpZlZ78Nf1fliSzBlMo1sV7PpP/7zUO+aA4
bKa8Rio3weMXQOZgclzgeSdqtwKnyKTQdXY5MkH1QXyFIk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VYRY0Ro/ISrR78CnANNsMIy3i11U5uvdeWVCoWV1BXNLzOD
4+BIDbMB/Do8PQCWiliSGZi8lvmj/sKbumMFQonMQWOfQswTtqTyQ3yhUM1LaxK5
PYq13rggi3rA8oq8SYb/KNCQL5pzACji4TRVK0kNpvtxJxe84X8+9IB1vhBvF/Ji
/xDd/3VDNPY+k1a47cON0S8Qc8DA3mq4hRfcgvuWy7ZxoMY7AfSJOhleb9+PzRBB
n9agYgMxZg1RUWZazQ5KuoJqbxpwOYVFja/stItNS4xsmi0lh2I4MNlBEDqnFLUx
SvTDc22c3uJlWhzBM/f2jH19uUeqm4jaggob3iJvJmK+Q7Ns3WcfhuWwCnc1+58d
iFAMRUCRBPeFS0qd56QGk1r97B6+3UfLUslCfaaA8IMOFvQSHJwDO87xWGyxeRTY
IIP9up4xwgje9LB7fMxsSkCDTHOk
=s3DI
-----END PGP PUBLIC KEY BLOCK-----
EOF
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
apt-get update
apt-get install -y php7.0-pgsql
sudo /etc/init.d/php7.0-fpm start
sudo /etc/init.d/php7.0-fpm restart
#!/bin/bash
set -e #exit immediately if a simple command exits with a nonzero exit value
add-apt-repository ppa:ondrej/php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment