--enable-exif \
--enable-ftp \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix
[root@ansible ~]# ansible php -m script -a '/scripts/php.sh'
[root@ansible ~]# ansible php -m shell -a 'cd /usr/src/php-8.1.11/ && make && make install'
//配置文件
[root@ansible ~]# ansible php -a 'cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf'
[root@ansible ~]# ansible php -a 'cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf'
//头文件
[root@ansible ~]# ansible php -a 'ln -sv /usr/local/php /usr/include/php'
//编写service文件
[root@ansible ~]# vim /scripts/phpservice
#!/bin/bash
cat > /usr/lib/systemd/system/php.service << EOF
[Unit]
Description=php server daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
ExecStop=ps -ef |grep php |grep -v grep|awk '{print$2}'|xargs kill
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
EOF
[root@ansible ~]# ansible php -m script -a '/scripts/phpservice.sh'
[root@ansible ~]# ansible php -a 'systemctl daemon-reload'
//开启服务并开机自启
[root@ansible ~]# ansible php -m service -a 'name=php state=started enabled=yes'
[root@ansible ~]# ansible php -a 'ss -antl'
192.168.118.132 | CHANGED | rc=0 >>
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
//在php端上配置网站
[root@ansible ~]# vim /scripts/phpindex.sh
[root@ansible ~]# cat /scripts/phpindex.sh
#!/bin/bash
mkdir -p /var/www/html
cat > /var/www/html/index.php << EOF
<?php
phpinfo();
?>
EOF
[root@ansible ~]# ansible php -m script -a '/scripts/phpindex.sh'
//修改php/usr/local/php/etc/php-fpm.d/www.conf文件的clisten和clisten.allowed_clients指向
[root@ansible ~]# ansible php -a 'sed -i "36c listen = 192.168.118.132:9000" /usr/local/php/etc/php-fpm.d/www.conf'
[root@ansible ~]# ansible php -a 'sed -i "63c listen.allowed_clients = 192.168.118.130" /usr/local/php/etc/php-fpm.d/www.conf'
//重启nginx服务和php服务
[root@ansible ~]# ansible nginx -m service -a 'name=nginx state=restarted'
[root@ansible ~]# ansible php -m service -a 'name=php state=restarted'
浏览器访问查看
|