PHP---编译安装PHP

Posted 秋天的风吹过原野

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP---编译安装PHP相关的知识,希望对你有一定的参考价值。

1.安装PHP所有的依赖软件包
[[email protected] ~]# yum install zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel  libcurl-devel libxslt-devel  openssl-devel -y
检查是否安装成功
[[email protected] ~]# rpm -qa zlib-devel libxml2-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel  openssl-devel
安装yum无法安装的libiconv库
[[email protected] tools]#  tar zxf libiconv-1.14.tar.gz
[[email protected] tools]#  cd libiconv-1.14
[[email protected] libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[[email protected] libiconv-1.14]# make && make install
添加阿里的epel.repo源(
yum源无法安装的支持库)libmcrypt-devel mhash mhash-devel mcrypt
 wget -O /etc/yum.repos.d/epel.repo 技术分享图片http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install libmcrypt libmcrypt-devel mhash mhash-devel mcrypt 
 
2. 编译安装PHP (php-5.5.32.tar.gz)
[[email protected] tools]# rz 
[[email protected] tools]# rz -y
[[email protected] tools]# tar xf php-5.5.32.tar.gz 
[[email protected] tools]# cd php-5.5.32
 
3. 已安装玩mysql的情况下编译参数:
[[email protected] php-5.3.32]# 
./configure \
--prefix=/application/php5.5.32 \
--with-mysql=/application/mysql/ \
--with-iconv-dir=/usr/local/libiconv \
--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-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=apache \
--with-fpm-group=apache \
--enable-opcache=no
--enable-ftp
 
4.编译PHP软件过程
[[email protected] php-5.5.32]# ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[[email protected] php-5.5.32]# touch ext/phar/phar.phar
[[email protected] php-5.5.32]# make                                  #出现Bulit complete.
 
5.安装PHP生成文件到系统
[[email protected] php-5.5.32]# make install                        #Installing PDO headers:
 
6.配置PHP引擎配置文件php.ini
[[email protected] php-5.5.32]# ln -s /application/php5.5.32 /application/php
[[email protected] php-5.5.32]# ll /application/php
lrwxrwxrwx 1 root root 22 Aug 26 18:32 /application/php -> /application/php5.5.32
[[email protected] php-5.5.32]# ls php.ini*
php.ini-development  php.ini-production                  #分别用于测试环境和生产环境
[[email protected] php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[[email protected] php-5.5.32]# ls -l /application/php/lib/php.ini
-rw-r--r-- 1 root root 69266 Aug 26 18:33 /application/php/lib/php.ini
 
7.配置PHP服务(FastCGI方式)的配置文件php-fpm.conf
[[email protected] php-5.5.32]# cd /application/php/etc/
pear.conf  php-fpm.conf.default
[[email protected] etc]# cp php-fpm.conf.default  php-fpm.conf      #php-fpm.conf后续会有优化
            
 
8. 启动PHP服务(FastCGI方式)
[[email protected] etc]# /application/php/sbin/php-fpm 
[[email protected] etc]# ps -ef|grep php-fpm
root     13440     1  0 18:39 ?        00:00:00 php-fpm: master process (/application/php5.5.32/etc/php-fpm.conf)
nginx    13441 13440  0 18:39 ?        00:00:00 php-fpm: pool www            
nginx    13442 13440  0 18:39 ?        00:00:00 php-fpm: pool www            
root     13451  1724  0 18:40 pts/1    00:00:00 grep php-fpm
[[email protected] etc]# lsof -i:9000
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 13440  root    7u  IPv4 184892      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 13441 nginx    0u  IPv4 184892      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 13442 nginx    0u  IPv4 184892      0t0  TCP localhost:cslistener (LISTEN)
 


































以上是关于PHP---编译安装PHP的主要内容,如果未能解决你的问题,请参考以下文章

编译安装 PHP 扩展

php5.5.38编译安装

php编译安装php-5.6

php编译安装

PHP8、FPM及部分扩展编译安装

如何在openSUSE42.1下编译安装PHP7