今天编译安装了php-8.0.30版本,编译参数和脚本如下:
export CFLAGS="-O3 -march=native -fstack-protector-strong"
export CXXFLAGS="-O3 -march=native -fstack-protector-strong"
./configure --prefix=/usr/local/php8.0 --enable-fpm --with-openssl --with-pcre-jit --with-zlib --enable-mbstring --enable-exif --enable-intl --enable-opcache --enable-pcntl --with-curl --with-gd --with-jpeg --with-freetype --with-webp --with-xpm --enable-gd-jis-conv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zip --with-gettext --with-sodium --with-pear --enable-bcmath --enable-calendar --enable-ftp --enable-sockets --without-sqlite3 --without-pdo-sqlite --with-config-file-path=/usr/local/php8.0/etc --with-config-file-scan-dir=/usr/local/php8.0/etc/conf.d
#脚本如下#
[Unit]
Description=PHP FastCGI Process Manager (PHP 8.0.30)
After=syslog.target network.target
[Service]
Type=forking # 必须使用forking类型
User=www
Group=www
ExecStart=/usr/local/php8.0/sbin/php-fpm --fpm-config /usr/local/php8.0/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGQUIT $MAINPID
Restart=on-failure
RestartSec=3s
# 安全设置调整
PrivateTmp=true
ProtectSystem=strict # 从full改为strict允许写入日志目录
ProtectHome=read-only
NoNewPrivileges=true
LimitNOFILE=65535
# 确保PID文件路径与php-fpm.conf中的配置一致
PIDFile=/usr/local/php8.0/var/run/php-fpm.pid
# 日志目录权限修复(重要!)
ReadWritePaths=/usr/local/php8.0/var/log/
ReadWritePaths=/usr/local/php8.0/var/run/
# 环境变量
Environment="PATH=/usr/local/php8.0/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
[Install]
WantedBy=multi-user.target
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!