Skip to content

Commit

Permalink
Optimize OpCache and more
Browse files Browse the repository at this point in the history
  • Loading branch information
joglomedia committed Jan 9, 2022
1 parent 09d1d32 commit cd43f2a
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions scripts/install_php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# PHP Installer
# Min. Requirement : GNU/Linux Ubuntu 18.04
# Last Build : 11/12/2021
# Last Build : 09/01/2022
# Author : MasEDI.Net ([email protected])
# Since Version : 1.0.0

Expand Down Expand Up @@ -195,6 +195,14 @@ function install_php() {
run mkdir -p /var/log/php
fi

if [[ ! -d "/home/${LEMPER_USERNAME}/logs/php" ]]; then
run mkdir -p "/home/${LEMPER_USERNAME}/logs/php"
fi

# Log rotation.
run cp -f "etc/logrotate.d/php${PHPv}-fpm" /etc/logrotate.d/ && \
run chmod 0644 "/etc/logrotate.d/php${PHPv}-fpm"

# Optimize PHP & FPM configuration.
optimize_php_fpm "${PHPv}"
fi
Expand Down Expand Up @@ -253,6 +261,12 @@ function optimize_php_fpm() {
run cp -f "etc/php/${PHPv}/fpm/php.ini" "/etc/php/${PHPv}/fpm/"
else
if [[ "${DRYRUN}" != true ]]; then
if [[ "${ENVIRONMENT}" =~ "prod" ]]; then
OVT="${OVT:-"0"}"
else
OVT="${OVT:-"1"}"
fi

cat >> "/etc/php/${PHPv}/fpm/php.ini" <<EOL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand All @@ -262,13 +276,14 @@ function optimize_php_fpm() {
[opcache]
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=512
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=32531
opcache.max_wasted_percentage=5
opcache.validate_timestamps=1
opcache.revalidate_freq=1
opcache.validate_timestamps=${OVT}
opcache.revalidate_freq=600
opcache.save_comments=1
opcache.fast_shutdown=1
opcache.error_log="/var/log/php/php${PHPv}-opcache_error.log"
EOL
else
Expand Down Expand Up @@ -408,7 +423,8 @@ pm.max_requests = 500
pm.status_path = /status
ping.path = /ping
slowlog = /var/log/php/php${PHPv}-fpm_slow.\$pool.log
;slowlog = /var/log/php/php${PHPv}-fpm_slow.\$pool.log
slowlog = /home/${POOLNAME}/logs/php/php${PHPv}-fpm_slow.log
request_slowlog_timeout = 10s
;chroot = /home/${POOLNAME}
Expand All @@ -424,7 +440,7 @@ php_flag[display_errors] = On
;php_admin_value[error_reporting] = E_ALL & ~E_DEPRECATED & ~E_STRICT
;php_admin_value[disable_functions] = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,exec,passthru,popen,proc_open,shell_exec,system
php_admin_flag[log_errors] = On
php_admin_value[error_log] = /var/log/php/php${PHPv}-fpm.\$pool.log
php_admin_value[error_log] = /home/${POOLNAME}/logs/php/php${PHPv}-fpm.log
php_admin_value[date.timezone] = ${TIMEZONE}
php_admin_value[memory_limit] = 128M
php_admin_value[opcache.file_cache] = /home/${POOLNAME}/.lemper/php/opcache
Expand Down

0 comments on commit cd43f2a

Please sign in to comment.