Skip to content

Commit

Permalink
add PHP version as a variable (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
enoch85 committed May 17, 2019
1 parent 1dda674 commit 1e75fa5
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 44 deletions.
4 changes: 2 additions & 2 deletions lets-encrypt/activate-ssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ then
### SETTINGS ###
<FilesMatch "\.php$">
SetHandler "proxy:unix:/run/php/php7.2-fpm.nextcloud.sock|fcgi://localhost"
SetHandler "proxy:unix:/run/php/php$PHPVER-fpm.nextcloud.sock|fcgi://localhost"
</FilesMatch>
DocumentRoot $NCPATH
Expand Down Expand Up @@ -192,7 +192,7 @@ then
sed -i "s|<FilesMatch.*|# Removed due to that PHP-FPM is missing|g" "$ssl_conf"
sed -i "s|SetHandler.*|#|g" "$ssl_conf"
sed -i "s|</FilesMatch.*|#|g" "$ssl_conf"
elif ! dpkg -s php7.2-fpm | grep "Status: install ok installed" >/dev/null 2>&1
elif ! dpkg -s php"$PHPVER"-fpm | grep "Status: install ok installed" >/dev/null 2>&1
then
sed -i "s|<FilesMatch.*|# Removed due to that PHP-FPM is missing|g" "$1"
sed -i "s|SetHandler.*|#|g" "$ssl_conf"
Expand Down
9 changes: 5 additions & 4 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ DHPARAMS="$CERTFILES/$SUBDOMAIN/dhparam.pem"
HTTPS_CONF="/etc/apache2/sites-available/$SUBDOMAIN.conf"
HTTP2_CONF="/etc/apache2/mods-available/http2.conf"
# PHP-FPM
PHP_INI=/etc/php/7.2/fpm/php.ini
PHP_POOL_DIR=/etc/php/7.2/fpm/pool.d
PHPVER=7.2
PHP_INI=/etc/php/$PHPVER/fpm/php.ini
PHP_POOL_DIR=/etc/php/$PHPVER/fpm/pool.d
# Adminer
ADMINERDIR=/usr/share/adminer
ADMINER_CONF=/etc/apache2/conf-available/adminer.conf
Expand Down Expand Up @@ -467,9 +468,9 @@ fi

restart_webserver() {
check_command systemctl restart apache2
if which php7.2-fpm > /dev/null
if which php"$PHPVER"-fpm > /dev/null
then
check_command systemctl restart php7.2-fpm.service
check_command systemctl restart php"$PHPVER"-fpm.service
fi

}
Expand Down
2 changes: 1 addition & 1 deletion nextcloud-startup-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ sed -i "s|DocumentRoot /var/www/html|DocumentRoot $HTML|g" /etc/apache2/sites-av
sed -i '14i\ # http://lost.l-w.ca/0x05/apache-mod_proxy_fcgi-and-php-fpm/' /etc/apache2/sites-available/000-default.conf
sed -i '15i\ <FilesMatch "\.php$">' /etc/apache2/sites-available/000-default.conf
sed -i '16i\ <If "-f %{SCRIPT_FILENAME}">' /etc/apache2/sites-available/000-default.conf
sed -i '17i\ SetHandler "proxy:unix:/run/php/php7.2-fpm.nextcloud.sock|fcgi://localhost"' /etc/apache2/sites-available/000-default.conf
sed -i '17i\ SetHandler "proxy:unix:/run/php/php'$PHPVER'-fpm.nextcloud.sock|fcgi://localhost"' /etc/apache2/sites-available/000-default.conf
sed -i '18i\ </If>' /etc/apache2/sites-available/000-default.conf
sed -i '19i\ </FilesMatch>' /etc/apache2/sites-available/000-default.conf
sed -i '20i\ ' /etc/apache2/sites-available/000-default.conf
Expand Down
48 changes: 24 additions & 24 deletions nextcloud_install_production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ is_this_installed postgresql
is_this_installed apache2
is_this_installed php
is_this_installed php-fpm
is_this_installed php7.2-fpm
is_this_installed php"$PHPVER"-fpm
is_this_installed php7.1-fpm
is_this_installed php7.0-fpm
is_this_installed mysql-common
Expand Down Expand Up @@ -223,30 +223,30 @@ a2enmod rewrite \
# We don't use Apache PHP (just to be sure)
a2dismod mpm_prefork

# Install PHP 7.2
# Install PHP "$PHPVER"
apt update -q4 & spinner_loading
check_command apt install -y \
php7.2-fpm \
php7.2-intl \
php7.2-ldap \
php7.2-imap \
php7.2-gd \
php7.2-pgsql \
php7.2-curl \
php7.2-xml \
php7.2-zip \
php7.2-mbstring \
php7.2-soap \
php7.2-smbclient \
php7.2-json \
php7.2-gmp \
php7.2-bz2 \
php"$PHPVER"-fpm \
php"$PHPVER"-intl \
php"$PHPVER"-ldap \
php"$PHPVER"-imap \
php"$PHPVER"-gd \
php"$PHPVER"-pgsql \
php"$PHPVER"-curl \
php"$PHPVER"-xml \
php"$PHPVER"-zip \
php"$PHPVER"-mbstring \
php"$PHPVER"-soap \
php"$PHPVER"-smbclient \
php"$PHPVER"-json \
php"$PHPVER"-gmp \
php"$PHPVER"-bz2 \
php-pear
# php7.2-imagick \
# php"$PHPVER"-imagick \
# libmagickcore-6.q16-3-extra

# Enable php-fpm
a2enconf php7.2-fpm
a2enconf php"$PHPVER"-fpm

# Enable HTTP/2 server wide
print_text_in_color "$ICyan" "Enabling HTTP/2 server wide..."
Expand All @@ -265,7 +265,7 @@ cat << POOL_CONF > "$PHP_POOL_DIR/nextcloud.conf"
[Nextcloud]
user = www-data
group = www-data
listen = /run/php/php7.2-fpm.nextcloud.sock
listen = /run/php/php"$PHPVER"-fpm.nextcloud.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
Expand Down Expand Up @@ -296,8 +296,8 @@ restart_webserver
calculate_php_fpm

# Enable SMB client # already loaded with php-smbclient
# echo '# This enables php-smbclient' >> /etc/php/7.2/apache2/php.ini
# echo 'extension="smbclient.so"' >> /etc/php/7.2/apache2/php.ini
# echo '# This enables php-smbclient' >> /etc/php/"$PHPVER"/apache2/php.ini
# echo 'extension="smbclient.so"' >> /etc/php/"$PHPVER"/apache2/php.ini

# Install VM-tools
install_if_not open-vm-tools
Expand Down Expand Up @@ -415,7 +415,7 @@ then
### SETTINGS ###
<FilesMatch "\.php$">
SetHandler "proxy:unix:/run/php/php7.2-fpm.nextcloud.sock|fcgi://localhost"
SetHandler "proxy:unix:/run/php/php$PHPVER-fpm.nextcloud.sock|fcgi://localhost"
</FilesMatch>
DocumentRoot $NCPATH
Expand Down Expand Up @@ -475,7 +475,7 @@ then
### SETTINGS ###
<FilesMatch "\.php$">
SetHandler "proxy:unix:/run/php/php7.2-fpm.nextcloud.sock|fcgi://localhost"
SetHandler "proxy:unix:/run/php/php$PHPVER-fpm.nextcloud.sock|fcgi://localhost"
</FilesMatch>
DocumentRoot $NCPATH
Expand Down
24 changes: 12 additions & 12 deletions nextcloud_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ fi
print_text_in_color "$ICyan" "Trying to upgrade the Redis PECL extension..."
if ! pecl list | grep redis >/dev/null 2>&1
then
if dpkg -l | grep php7.2 > /dev/null 2>&1
if dpkg -l | grep php"$PHPVER" > /dev/null 2>&1
then
install_if_not php7.2-dev
install_if_not php"$PHPVER"-dev
elif dpkg -l | grep php7.3 > /dev/null 2>&1
then
install_if_not php7.3-dev
Expand All @@ -101,21 +101,21 @@ then
if [ -f /etc/php/7.0/apache2/php.ini ]
then
! [[ "$(grep -R extension=redis.so /etc/php/7.0/apache2/php.ini)" == "extension=redis.so" ]] > /dev/null 2>&1 && echo "extension=redis.so" >> /etc/php/7.0/apache2/php.ini
# PHP 7.2 apache
elif [ -f /etc/php/7.2/apache2/php.ini ]
# PHP "$PHPVER" apache
elif [ -f /etc/php/"$PHPVER"/apache2/php.ini ]
then
! [[ "$(grep -R extension=redis.so /etc/php/7.2/apache2/php.ini)" == "extension=redis.so" ]] > /dev/null 2>&1 && echo "extension=redis.so" >> /etc/php/7.2/apache2/php.ini
# PHP 7.2 fpm
! [[ "$(grep -R extension=redis.so /etc/php/"$PHPVER"/apache2/php.ini)" == "extension=redis.so" ]] > /dev/null 2>&1 && echo "extension=redis.so" >> /etc/php/"$PHPVER"/apache2/php.ini
# PHP "$PHPVER" fpm
elif [ -f "$PHP_INI" ]
then
! [[ "$(grep -R extension=redis.so "$PHP_INI")" == "extension=redis.so" ]] > /dev/null 2>&1 && echo "extension=redis.so" >> "$PHP_INI"
fi
restart_webserver
elif pecl list | grep redis >/dev/null 2>&1
then
if dpkg -l | grep php7.2 > /dev/null 2>&1
if dpkg -l | grep php"$PHPVER" > /dev/null 2>&1
then
install_if_not php7.2-dev
install_if_not php"$PHPVER"-dev
elif dpkg -l | grep php7.3 > /dev/null 2>&1
then
install_if_not php7.3-dev
Expand All @@ -131,11 +131,11 @@ then
if [ -f /etc/php/7.0/apache2/php.ini ]
then
! [[ "$(grep -R extension=redis.so /etc/php/7.0/apache2/php.ini)" == "extension=redis.so" ]] > /dev/null 2>&1 && echo "extension=redis.so" >> /etc/php/7.0/apache2/php.ini
# PHP 7.2 apache
elif [ -f /etc/php/7.2/apache2/php.ini ]
# PHP "$PHPVER" apache
elif [ -f /etc/php/"$PHPVER"/apache2/php.ini ]
then
! [[ "$(grep -R extension=redis.so /etc/php/7.2/apache2/php.ini)" == "extension=redis.so" ]] > /dev/null 2>&1 && echo "extension=redis.so" >> /etc/php/7.2/apache2/php.ini
# PHP 7.2 fpm
! [[ "$(grep -R extension=redis.so /etc/php/"$PHPVER"/apache2/php.ini)" == "extension=redis.so" ]] > /dev/null 2>&1 && echo "extension=redis.so" >> /etc/php/"$PHPVER"/apache2/php.ini
# PHP "$PHPVER" fpm
elif [ -f "$PHP_INI" ]
then
! [[ "$(grep -R extension=redis.so "$PHP_INI")" == "extension=redis.so" ]] > /dev/null 2>&1 && echo "extension=redis.so" >> "$PHP_INI"
Expand Down
2 changes: 1 addition & 1 deletion static/redis-server-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ then
fi

# Install Redis
install_if_not php7.2-dev
install_if_not php"$PHPVER"-dev
pecl channel-update pecl.php.net
if ! yes no | pecl install -Z redis
then
Expand Down

0 comments on commit 1e75fa5

Please sign in to comment.