From 976d7da675fa05054ee770f2e6038c7a552a9d5f Mon Sep 17 00:00:00 2001 From: Dan Storm Date: Fri, 9 Dec 2016 08:31:32 +0100 Subject: [PATCH 1/3] Updating PHP Installations --- Vagrantfile | 10 +++++----- scripts/mailcatcher.sh | 8 +++++--- scripts/nginx.sh | 6 ++++-- scripts/php.sh | 41 +++++++++++++++++------------------------ scripts/zeromq.sh | 8 +++++--- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 4a162005..6eaa6169 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -43,7 +43,7 @@ mongo_enable_remote = "false" # remote access enabled when true # Languages and Packages php_timezone = "UTC" # http://php.net/manual/en/timezones.php -php_version = "5.6" # Options: 5.5 | 5.6 +php_version = "5.6" # Options: 5.5 | 5.6 | 7.0 | 7.1 ruby_version = "latest" # Choose what ruby version should be installed (will also be the default version) ruby_gems = [ # List any Ruby Gems that you want to install #"jekyll", @@ -219,7 +219,7 @@ Vagrant.configure("2") do |config| # config.vm.provision "shell", path: "#{github_url}/scripts/apache.sh", args: [server_ip, public_folder, hostname, github_url] # Provision Nginx Base - # config.vm.provision "shell", path: "#{github_url}/scripts/nginx.sh", args: [server_ip, public_folder, hostname, github_url] + # config.vm.provision "shell", path: "#{github_url}/scripts/nginx.sh", args: [server_ip, public_folder, hostname, github_url, php_version] #### @@ -239,7 +239,7 @@ Vagrant.configure("2") do |config| # config.vm.provision "shell", path: "#{github_url}/scripts/rethinkdb.sh", args: pgsql_root_password # Provision Couchbase - # config.vm.provision "shell", path: "#{github_url}/scripts/couchbase.sh" + # config.vm.provision "shell", path: "#{github_url}/scripts/couchbase.sh", args: [php_version] # Provision CouchDB # config.vm.provision "shell", path: "#{github_url}/scripts/couchdb.sh" @@ -305,7 +305,7 @@ Vagrant.configure("2") do |config| # config.vm.provision "shell", path: "#{github_url}/scripts/kibana.sh" # Install ØMQ - # config.vm.provision "shell", path: "#{github_url}/scripts/zeromq.sh" + # config.vm.provision "shell", path: "#{github_url}/scripts/zeromq.sh", args: [php_version] # Install RabbitMQ # config.vm.provision "shell", path: "#{github_url}/scripts/rabbitmq.sh", args: [rabbitmq_user, rabbitmq_password] @@ -341,7 +341,7 @@ Vagrant.configure("2") do |config| # config.vm.provision "shell", path: "#{github_url}/scripts/screen.sh" # Install Mailcatcher - # config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh" + # config.vm.provision "shell", path: "#{github_url}/scripts/mailcatcher.sh", args: [php_version] # Install git-ftp # config.vm.provision "shell", path: "#{github_url}/scripts/git-ftp.sh", privileged: false diff --git a/scripts/mailcatcher.sh b/scripts/mailcatcher.sh index 634be7e2..90970e00 100644 --- a/scripts/mailcatcher.sh +++ b/scripts/mailcatcher.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +PHP_VERSION=$1 + echo ">>> Installing Mailcatcher" # Test if PHP is installed @@ -43,9 +45,9 @@ sudo service mailcatcher start if [[ $PHP_IS_INSTALLED -eq 0 ]]; then # Make php use it to send mail - echo "sendmail_path = /usr/bin/env $(which catchmail)" | sudo tee /etc/php5/mods-available/mailcatcher.ini - sudo php5enmod mailcatcher - sudo service php5-fpm restart + echo "sendmail_path = /usr/bin/env $(which catchmail)" | sudo tee /etc/php/${PHP_VERSION}/mods-available/mailcatcher.ini + sudo phpenmod mailcatcher + sudo service php${PHP_VERSION}-fpm restart fi if [[ $APACHE_IS_INSTALLED -eq 0 ]]; then diff --git a/scripts/nginx.sh b/scripts/nginx.sh index 9e07c223..e6755664 100644 --- a/scripts/nginx.sh +++ b/scripts/nginx.sh @@ -34,6 +34,8 @@ else github_url="$4" fi +PHP_VERSION=$5 + # Add repo for latest stable nginx sudo add-apt-repository -y ppa:nginx/stable @@ -70,9 +72,9 @@ sudo ngxdis default if [[ $HHVM_IS_INSTALLED -ne 0 && $PHP_IS_INSTALLED -eq 0 ]]; then # PHP-FPM Config for Nginx - sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php5/fpm/php.ini + sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/${PHP_VERSION}/fpm/php.ini - sudo service php5-fpm restart + sudo service php${PHP_VERSION-fpm restart fi sudo service nginx restart diff --git a/scripts/php.sh b/scripts/php.sh index e72d9416..1afdd615 100644 --- a/scripts/php.sh +++ b/scripts/php.sh @@ -31,42 +31,35 @@ if [[ $HHVM == "true" ]]; then else echo ">>> Installing PHP $PHP_VERSION" - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C - - if [ $PHP_VERSION == "5.5" ]; then - # Add repo for PHP 5.5 - sudo add-apt-repository -y ppa:ondrej/php5 - else - # Add repo for PHP 5.6 - sudo add-apt-repository -y ppa:ondrej/php5-5.6 - fi + sudo add-apt-repository -y ppa:ondrej/php sudo apt-key update sudo apt-get update # Install PHP # -qq implies -y --force-yes - sudo apt-get install -qq php5-cli php5-fpm php5-mysql php5-pgsql php5-sqlite php5-curl php5-gd php5-gmp php5-mcrypt php5-memcached php5-imagick php5-intl php5-xdebug + + sudo apt-get install -qq php${PHP_VERSION}-cli php${PHP_VERSION}-fpm php${PHP_VERSION}-mysql php${PHP_VERSION}-pgsql php${PHP_VERSION}-sqlite php${PHP_VERSION}-curl php${PHP_VERSION}-gd php${PHP_VERSION}-gmp php${PHP_VERSION}-mcrypt php${PHP_VERSION}-memcached php${PHP_VERSION}-imagick php${PHP_VERSION}-intl php-xdebug # Set PHP FPM to listen on TCP instead of Socket - sudo sed -i "s/listen =.*/listen = 127.0.0.1:9000/" /etc/php5/fpm/pool.d/www.conf + sudo sed -i "s/listen =.*/listen = 127.0.0.1:9000/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf # Set PHP FPM allowed clients IP address - sudo sed -i "s/;listen.allowed_clients/listen.allowed_clients/" /etc/php5/fpm/pool.d/www.conf + sudo sed -i "s/;listen.allowed_clients/listen.allowed_clients/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf # Set run-as user for PHP5-FPM processes to user/group "vagrant" # to avoid permission errors from apps writing to files - sudo sed -i "s/user = www-data/user = vagrant/" /etc/php5/fpm/pool.d/www.conf - sudo sed -i "s/group = www-data/group = vagrant/" /etc/php5/fpm/pool.d/www.conf + sudo sed -i "s/user = www-data/user = vagrant/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf + sudo sed -i "s/group = www-data/group = vagrant/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf - sudo sed -i "s/listen\.owner.*/listen.owner = vagrant/" /etc/php5/fpm/pool.d/www.conf - sudo sed -i "s/listen\.group.*/listen.group = vagrant/" /etc/php5/fpm/pool.d/www.conf - sudo sed -i "s/listen\.mode.*/listen.mode = 0666/" /etc/php5/fpm/pool.d/www.conf + sudo sed -i "s/listen\.owner.*/listen.owner = vagrant/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf + sudo sed -i "s/listen\.group.*/listen.group = vagrant/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf + sudo sed -i "s/listen\.mode.*/listen.mode = 0666/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf # xdebug Config - cat > $(find /etc/php5 -name xdebug.ini) << EOF -zend_extension=$(find /usr/lib/php5 -name xdebug.so) + cat > /etc/php/${PHP_VERSION}/mods-available/xdebug.ini << EOF +zend_extension=xdebug.so xdebug.remote_enable = 1 xdebug.remote_connect_back = 1 xdebug.remote_port = 9000 @@ -81,12 +74,12 @@ xdebug.var_display_max_data = 1024 EOF # PHP Error Reporting Config - sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/fpm/php.ini - sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/fpm/php.ini + sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/${PHP_VERSION}/fpm/php.ini + sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php/${PHP_VERSION}/fpm/php.ini # PHP Date Timezone - sudo sed -i "s/;date.timezone =.*/date.timezone = ${PHP_TIMEZONE/\//\\/}/" /etc/php5/fpm/php.ini - sudo sed -i "s/;date.timezone =.*/date.timezone = ${PHP_TIMEZONE/\//\\/}/" /etc/php5/cli/php.ini + sudo sed -i "s/;date.timezone =.*/date.timezone = ${PHP_TIMEZONE/\//\\/}/" /etc/php/${PHP_VERSION}/fpm/php.ini + sudo sed -i "s/;date.timezone =.*/date.timezone = ${PHP_TIMEZONE/\//\\/}/" /etc/php/${PHP_VERSION}/cli/php.ini - sudo service php5-fpm restart + sudo service php${PHP_VERSION}-fpm restart fi diff --git a/scripts/zeromq.sh b/scripts/zeromq.sh index ab979371..21ea1cb8 100644 --- a/scripts/zeromq.sh +++ b/scripts/zeromq.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +PHP_VERSION=$1 + # Test if PHP is installed php -v > /dev/null 2>&1 PHP_IS_INSTALLED=$? @@ -14,7 +16,7 @@ sudo apt-get install -qq libtool autoconf automake uuid uuid-dev uuid-runtime bu echo "" | sudo pecl install zmq-beta > /dev/null -sudo echo "extension=zmq.so" >> /etc/php5/mods-available/zmq.ini -sudo php5enmod zmq > /dev/null -sudo service php5-fpm restart > /dev/null +sudo echo "extension=zmq.so" >> /etc/php/${PHP_VERSION}/mods-available/zmq.ini +sudo phpenmod zmq > /dev/null +sudo service php${PHP_VERSION}-fpm restart > /dev/null From 3470756bdbd58d6aa43ec06c0edcaafafaeb0e6a Mon Sep 17 00:00:00 2001 From: Dan Storm Date: Fri, 9 Dec 2016 08:39:48 +0100 Subject: [PATCH 2/3] Fixed missing curly bracket --- scripts/nginx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/nginx.sh b/scripts/nginx.sh index e6755664..dcc94668 100644 --- a/scripts/nginx.sh +++ b/scripts/nginx.sh @@ -74,7 +74,7 @@ if [[ $HHVM_IS_INSTALLED -ne 0 && $PHP_IS_INSTALLED -eq 0 ]]; then # PHP-FPM Config for Nginx sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/${PHP_VERSION}/fpm/php.ini - sudo service php${PHP_VERSION-fpm restart + sudo service php${PHP_VERSION}-fpm restart fi sudo service nginx restart From 98f8c03e39bb4eb00bafea6639c6738c8137ba28 Mon Sep 17 00:00:00 2001 From: Dan Storm Date: Fri, 9 Dec 2016 08:58:56 +0100 Subject: [PATCH 3/3] Added a few packages to support phpunit --- scripts/php.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/php.sh b/scripts/php.sh index 1afdd615..8a1cd814 100644 --- a/scripts/php.sh +++ b/scripts/php.sh @@ -39,7 +39,7 @@ else # Install PHP # -qq implies -y --force-yes - sudo apt-get install -qq php${PHP_VERSION}-cli php${PHP_VERSION}-fpm php${PHP_VERSION}-mysql php${PHP_VERSION}-pgsql php${PHP_VERSION}-sqlite php${PHP_VERSION}-curl php${PHP_VERSION}-gd php${PHP_VERSION}-gmp php${PHP_VERSION}-mcrypt php${PHP_VERSION}-memcached php${PHP_VERSION}-imagick php${PHP_VERSION}-intl php-xdebug + sudo apt-get install -qq php${PHP_VERSION}-cli php${PHP_VERSION}-fpm php${PHP_VERSION}-mysql php${PHP_VERSION}-pgsql php${PHP_VERSION}-sqlite php${PHP_VERSION}-curl php${PHP_VERSION}-gd php${PHP_VERSION}-gmp php${PHP_VERSION}-mcrypt php${PHP_VERSION}-memcached php${PHP_VERSION}-imagick php${PHP_VERSION}-intl php${PHP_VERSION}-mbstring php${PHP_VERSION}-xml php-xdebug # Set PHP FPM to listen on TCP instead of Socket sudo sed -i "s/listen =.*/listen = 127.0.0.1:9000/" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf