Last active
April 8, 2023 06:10
-
-
Save dptole/951be99e10f0513fffa5daedcb994c72 to your computer and use it in GitHub Desktop.
[Centos] Install php7.3 from source + fpm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assume MySQL /var/run/mysqld/mysqld.sock | |
rm /var/mail/nginx | |
rm -rf /home/nginx | |
userdel nginx | |
useradd nginx -M -l -s /sbin/nologin -U | |
mkdir -p /app/php | |
cd /app/php | |
wget https://www.php.net/distributions/php-7.3.0.tar.gz | |
tar xzf php-7.3.0.tar.gz | |
cd php-7.3.0 | |
CONFIG="--prefix=/app/php \ | |
--with-pdo-pgsql \ | |
--with-zlib-dir \ | |
--enable-mbstring \ | |
--enable-soap \ | |
--enable-calendar \ | |
--with-curl \ | |
--disable-rpath \ | |
--enable-inline-optimization \ | |
--with-bz2 \ | |
--enable-sockets \ | |
--enable-sysvsem \ | |
--enable-sysvshm \ | |
--enable-pcntl \ | |
--enable-mbregex \ | |
--enable-exif \ | |
--enable-bcmath \ | |
--with-mhash \ | |
--with-pdo-mysql \ | |
--with-mysqli \ | |
--with-mysql-sock=/var/run/mysqld/mysqld.sock \ | |
--with-openssl \ | |
--with-fpm-user=nginx \ | |
--with-fpm-group=nginx \ | |
--with-libdir=/lib/x86_64-linux-gnu \ | |
--enable-ftp \ | |
--with-kerberos \ | |
--with-gettext \ | |
--with-xmlrpc \ | |
--with-xsl \ | |
--enable-opcache \ | |
--enable-intl \ | |
--with-pear \ | |
--enable-fpm" | |
./configure $CONFIG & make & make install | |
rm /usr/local/bin/php-fpm | |
rm /usr/local/bin/php | |
ln -s /app/php/sbin/php-fpm /usr/local/bin/php-fpm | |
ln -s /app/php/bin/php /usr/local/bin/php | |
mv /app/php/etc/php-fpm.conf.default /app/php/etc/php-fpm.conf | |
mv /app/php/etc/php-fpm.d/www.conf.default /app/php/etc/php-fpm.d/www.conf | |
cat <<'EOF' -> /lib/systemd/system/php-7.4-fpm.service | |
[Unit] | |
Description=The PHP 7.4 FastCGI Process Manager | |
After=network.target | |
[Service] | |
Type=simple | |
PIDFile=/var/run/php/php7.3-fpm.pid | |
ExecStart=/app/php/bin/php-fpm --nodaemonize --fpm-config /app/php/etc/php-fpm.conf | |
ExecReload=/bin/kill -USR2 $MAINPID | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cp /app/php/etc/php-fpm.conf /app/php/etc/php-fpm.conf.default | |
cat <<'EOF' -> /app/php/etc/php-fpm.conf | |
[global] | |
error_log = /app/php/log/php-fpm.log | |
include=/app/php/etc/php-fpm.d/*.conf | |
EOF | |
cp /app/php/etc/php-fpm.d/www.conf /app/php/etc/php-fpm.d/www.conf.default | |
cat <<'EOF' -> /app/php/etc/php-fpm.d/www.conf | |
[www] | |
prefix = | |
user = nginx | |
group = nginx | |
listen = /app/php/var/run/php7.3-fpm.sock | |
listen.owner = nginx | |
listen.group = nginx | |
listen.mode = 0660 | |
pm = dynamic | |
pm.max_children = 50 | |
pm.start_servers = 10 | |
pm.min_spare_servers = 10 | |
pm.max_spare_servers = 40 | |
pm.max_requests = 100 | |
pm.status_path = /status | |
ping.path = /ping | |
access.log = /app/php/log/$pool.access.log | |
access.format = "[%{%Y-%m-%dT%H:%M:%S%z}t] METHOD=\"%m\" URI=\"%{REQUEST_URI}e\" STATUS=\"%s\" HTTP_X_FORWARDED_FOR=\"%{HTTP_X_FORWARDED_FOR}e\" IP=\"%R\" PHP_REMOTE_ADDR=\"%{REMOTE_ADDR}e\" HTTP_X_REAL_IP=\"%{HTTP_X_REAL_IP}e\" DURATION=\"%{mili}dms\" MEMORY=\"%{kilo}Mkb\" CPU=\"%C%%\" CONTENT_LENGTH=\"%l\" CONTENT_TYPE=\"%{Content-Type}o\" USER_AGENT=\"%{HTTP_USER_AGENT}e\"" | |
slowlog = /app/php/log/$pool.slow.log | |
request_slowlog_timeout = 5s | |
request_slowlog_trace_depth = 20 | |
php_value[error_log] = /app/php/log/$pool.error.log | |
php_flag[log_errors] = on | |
EOF | |
chown -R nginx.nginx /app | |
systemctl daemon-reload | |
systemctl enable php-fpm.service | |
service php-fpm restart | |
chown -R nginx.nginx /app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment