php8.0.30 systemd启动脚本

今天编译安装了php-8.0.30版本,编译参数和脚本如下: #################################################脚本如下######################### [Unit] Description=PHP FastCGI Process...

今天编译安装了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

  • 发表于 2025-03-21 16:05
  • 阅读 ( 48 )

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
shitian
shitian

662 篇文章

作家榜 »

  1. shitian 662 文章
  2. 石天 437 文章
  3. 每天惠23 33 文章
  4. 小A 29 文章