六、安装并配置php
(1) 解压php-7.2.17.tar.gz
#tar -xvf php-7.2.17.tar.gz && cd php-7.2.17
(2) 安装依赖包
#yum install -y libxml2-devel openssl-devel net-snmp net-snmp-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel bzip2 bzip2-devel freetype-devel gmp-devel readline-devel libxslt-devel fontconfig
#./configure --prefix=/mnt/hg/php-7.2.17 --with-mysqli=/mnt/hg/mysql-last/bin/mysql_config --enable-inline-optimization --enable-fpm --enable-soap --enable-pcntl --enable-xml --with-libxml-dir --with-xmlrpc --with-openssl --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --without-pear
#make -j4
#make install
(3) 拷贝服务和配置文件
#cd ~/zabbix/php-7.2.17
#cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service
#cp /mnt/hg/php-7.2.17/etc/{php-fpm.conf.default,php-fpm.conf}
#cp /mnt/hg/php-7.2.17/etc/php-fpm.d/www.conf{.default,}
#cp php.ini-production /mnt/hg/php-7.2.17/lib/php.ini
(4) 更改php-7.2.17文件夹的拥有者和拥有组
#cd /mnt/hg
#chown nginx:nginx -R php-7.2.17
(5) 修改php.ini配置文件
vim /mnt/hg/php-last/lib/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = PRC
(6) 启动PHP
#systemctl start php-fpm.service && systemctl enable php-fpm.service
(7) 编辑nginx.conf配置文件,使nginx支持PHP
vim/mnt/hg/nginx-last/conf/nginx.conf
location ~ “.php$” {
root /mnt/hg/nginx-last/html/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /mnt/hg/nginx-last/html$fastcgi_script_name;
include fastcgi_params;
}
(8) 测试PHP效果① 编写测试页面
vim /mnt/hg/nginx-last/html/index.php
② 重新加载nginx配置,测试index.php页面
#nginx -s reload
本技术资料由广州九一乐维信息科技有限公司提供
作者:胡剑祺
转载请标明出处
延伸阅读
【专注】Zabbix源码安装教程—步骤详解(1)安装前准备
【专注】Zabbix源码安装教程—步骤详解(2)安装并配置mysql
【专注】Zabbix源码安装教程—步骤详解(3)安装并配置nginx
【专注】Zabbix源码安装教程—步骤详解(5)安装配置Zabbix