From f054d5cfd2737fde1a613a7eae08baa3bfae2d35 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Tue, 13 Jun 2017 22:18:05 +0200 Subject: [PATCH] install and use php7 --- conf/nginx.conf | 2 +- scripts/_common.sh | 20 ++++++++++++++++++-- scripts/install | 28 ++++++++++++++++++---------- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f0a9587..db10d02 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,7 +4,7 @@ location ^~ YNH_EXAMPLE_PATH { location ~ \.php { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/scripts/_common.sh b/scripts/_common.sh index 489ba9b..1a94bba 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -50,7 +50,7 @@ exec_composer() { shift 1 COMPOSER_HOME="${WORKDIR}/.composer" \ - php "${WORKDIR}/composer.phar" $@ \ + /usr/bin/php7.0 "${WORKDIR}/composer.phar" $@ \ -d "${WORKDIR}" --quiet --no-interaction } @@ -63,7 +63,7 @@ init_composer() { # install composer curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="${DESTDIR}/.composer" \ - php -- --quiet --install-dir="$DESTDIR" \ + /usr/bin/php7.0 -- --quiet --install-dir="$DESTDIR" \ || ynh_die "Unable to install Composer" # update dependencies to create composer.lock @@ -158,3 +158,19 @@ ynh_remove_nodejs () { fi } +ynh_install_php7 () { + sudo echo 'deb https://packages.dotdeb.org jessie all' > /etc/apt/sources.list.d/dotdeb.list + curl http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add - + ynh_package_update + ynh_package_install apt-transport-https --no-install-recommends + ynh_package_install php7.0 php7.0-fpm php7.0-mysql php7.0-xml php7.0-intl php7.0-mbstring --no-install-recommends + sudo update-alternatives --install /usr/bin/php php /usr/bin/php5 70 +} + +ynh_remove_php7 () { + sudo rm -f /etc/apt/sources.list.d/dotdeb.list + sudo apt-key del 4096R/89DF5277 + ynh_package_update + ynh_package_remove php7.0 php7.0-fpm php7.0-mysql php7.0-xml php7.0-intl php7.0-mbstring +} + diff --git a/scripts/install b/scripts/install index 5b402d9..28881b4 100755 --- a/scripts/install +++ b/scripts/install @@ -40,6 +40,8 @@ final_path=/var/www/$app sudo mkdir -p $final_path sudo chmod 775 $final_path +ynh_install_php7 + ### MySQL (can be removed if not used) ### # If your app use a MySQL database you can use these lines to bootstrap # a database, an associated user and save the password in app settings. @@ -74,16 +76,17 @@ sudo sed -i "s@YNH_EXAMPLE_PATH@$path_url@g" ../conf/nginx.conf sudo sed -i "s@YNH_WWW_PATH@$final_path\/public\/@g" $nginx_conf sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +# setup application config sudo cp ../conf/.env $final_path/.env -cd $final_path && php artisan -n key:generate --force -cd $final_path && php artisan config:clear +cd $final_path && /usr/bin/php7.0 artisan -n key:generate --force +cd $final_path && /usr/bin/php7.0 artisan config:clear sudo sed -i "s/yunouser/$dbuser/g" $final_path/.env sudo sed -i "s/yunopass/$dbpass/g" $final_path/.env sudo sed -i "s/yunobase/$dbname/g" $final_path/.env sudo sed -i "s/yunomail/$email/g" $final_path/.env sudo sed -i "s/yunodomain/$domain/g" $final_path/.env -# uses commas because path url contains a slash +## uses commas because path url contains a slash sudo sed -i "s,yunopath,${path_url},g" $final_path/.env # Install nodejs packages @@ -92,17 +95,22 @@ cd $final_path && sudo_path "$nodejs_path/pnpm" install cd $final_path && sudo_path "$nodejs_path/pnpm" install -g bower gulp cd $final_path && sudo_path "$nodejs_path/bower" install -f --allow-root -cd $final_path && php artisan -q migrate --force -cd $final_path && php artisan -q storage:link -cd $final_path && php artisan -q optimize -cd $final_path && php artisan -q db:seed --class ActivityTypesTableSeeder --force -cd $final_path && php artisan -q db:seed --class CountriesSeederTable --force -cd $final_path && php artisan -q db:seed --class CreateUser --force +# setup application config +cd $final_path && /usr/bin/php7.0 artisan -q migrate --force +cd $final_path && /usr/bin/php7.0 artisan -q storage:link +cd $final_path && /usr/bin/php7.0 artisan -q optimize +cd $final_path && /usr/bin/php7.0 artisan -q db:seed --class ActivityTypesTableSeeder --force +cd $final_path && /usr/bin/php7.0 artisan -q db:seed --class CountriesSeederTable --force +cd $final_path && /usr/bin/php7.0 artisan -q db:seed --class CreateUser --force + +# create a cronjob to run the scheduler +echo "* * * * * www-data cd $final_path && /usr/bin/php7.0 $final_path/artisan schedule:run >/dev/null 2>&1" > /tmp/cron$app +sudo mv /tmp/cron$app /etc/cron.d/$app +sudo chown root /etc/cron.d/$app # Install files and set permissions sudo chown -R www-data: "$final_path" - # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway.