Detailed steps to install php from source code under centos

Background: Because I want to write a PHP extension, I used yum to install lnmp before. This time I uninstall the package installed by yum and recompile it. If it is a new installation, please start from the fourth step.

Step 1: Delete PHP Version (if it has not been installed before, skip this step)
(1) This command is to delete the unclean
yum remove php*
(2) It must be deleted forcibly, pay attention to uninstall the undependable ones first, pdo is a dependency of mysql; common is a dependency of gd
Check :
rpm -qa|grep php
delete:
rpm -e php-mysql-5.1.6-27.el5_5.3
rpm -e php-pdo-5.1.6-27.el5_5.3
rpm - e php-xml-5.1.6-27.el5_5.3
rpm -e php-cli-5.1.6-27.el5_5.3
rpm -e php-gd-5.1.6-27.el5_5.3
rpm -e php -common-5.1.6-27.el5_5.3 and
then use # php -v, there is no prompt to view the version information.

Step 2 : Prepare the installation environment and compilation tools (because I have already installed it before, I ignored this step )

yum install -y libxml2 libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel 

yum install gcc gcc-c++

Step 3: Check the linux version (list all version information, you can ignore)



Step 4: Download the corresponding PHP version, upload it to the server, and decompress it

(1) PHP source code download address:
http://php.net /downloads.php

(2).tar.gz compressed package decompression command:
tar -xvzf php-5.6.30



Step 5: Enter the source code directory and install the packages that php depends on​​(prefix is ​​the installation directory)

​./configure - -prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable -sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml --enable-mbstring --disable -rpath --disable-debug --disable-fileinfo --with-mysql --with-mysqli --with-pdo-mysql --with-pcre-regex --with-iconv --with-zlib --with- mcrypt --with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl --with-imap-ssl




Step 6: Compile, install
1, make



2. make install




3. If there are no errors in the previous steps, the installation is successful. If you encounter errors, please solve them first. Step



7
Configuration 1. Copy the configuration file
cp php.ini-production /usr/local/php/etc/php. ini

2, then we may also need to use php-fpm as a server service
cp /usr/local/src/php-5.6.30/sapi/fpm/init.d.php-fpm /etc/init.d/php- fpm

3, set the permissions, and add the service
chmod a+x /etc/init.d/php-fpm
chkconfig --add php-fpm





4, the installation is complete, you can use the following commands to manage php-fpm later
#service php-fpm (start|stop|restart|reload)


Step 7: How to install an extension (this is an extension, it can be ignored if the extension is not installed temporarily)

PHP extension directory: $PHP_PATH/lib/php/extensions/no-debug-non-zts -yyyymmdd
PHP.ini directory: $PHP_PATH/etc/php.ini



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326267801&siteId=291194637