安装扩展包
# yum install -y epel-release
安装依赖包
# yum install -y libxml2 libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-devel openssl openssl-devel
上传安装包
# rz
安装包我一般放在/usr/local/src目录下
解压安装包
# tar zxf php-7.3.5.tar.gz
配置并安装
# cp -frp /usr/lib64/libldap* /usr/lib/
# wget https://nih.at/libzip/libzip-1.2.0.tar.gz
# tar zxf libzip-1.2.0.tar.gz
# cd libzip-1.2.0
# ./configure
# make && make install
# cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/
1)添加搜索路径到配置文件
# echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
2)更新配置
# ldconfig -v
在PHP源码目录下 vim Makefile 找到 EXTRA_LIBS = -lcrypt -lz行,在行末添加 ‘ -llber ‘ 保存退出再次make && make install即可
# cd php-7.3.5
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm --with-ldap
问题
1、提示configure: error: Cannot find OpenSSL's
# yum install -y openssl openssl-devel
执行完毕后,问题解决;已将该服务加入
2、提示configure: error: Cannot find ldap libraries in /usr/lib.
# cp -frp /usr/lib64/libldap* /usr/lib/
执行完毕后,问题解决。
3、提示configure: error: Please reinstall the libzip distribution
# yum install -y libzip libzip-devel
执行完毕,未解决,版本过低;
4、提示checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11
编译安装libzip,问题解决;
5、提示configure: error: off_t undefined; check your library configuratio
1)添加搜索路径到配置文件
# echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
2)更新配置
# ldconfig -v
# make && make install
问题
1、提示/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory
# cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/
执行完毕后,问题解决;
2、提示//usr/lib64/liblber-2.4.so.2: error adding symbols: DSO missing from command line
在PHP源码目录下 vim Makefile 找到 EXTRA_LIBS = -lcrypt -lz行,在行末添加 ‘ -llber ‘ 保存退出再次make && make install即可
# vim Makefile
# make && make install
配置文件
# cp /usr/local/src/php-7.3.5/php.ini-production /usr/local/php/etc/pnp.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
设置php-fpm.pid文件位置
# vim /usr/local/php/etc/php-fpm.conf
pid = /usr/local/php/var/run/php-fpm.pid
优化
PHP命令
# vim /etc/profile
export PATH=$PATH:/usr/local/php/sbin:/usr/local/php/bin/
# source /etc/profile
systemctl配置
# vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
启动停止重启
# systemctl start php-fpm 启动
# systemctl stop php-fpm 停止
# systemctl status php-fpm 查看状态
# systemctl enable php-fpm 开机自启
nginx+php-fpm结合的配置
nginx的默认配置无法处理php程序;
# vim /usr/local/nginx/html/test.php
echo "taobao zabbix";
?>
# vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}