Home >Backend Development >PHP Tutorial >Install PHP from source on CentOS

Install PHP from source on CentOS

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-08-08 09:28:121116browse

System environment

CentOS 6.5 64-bit

Nginx 1.6.2

MySQL 5.6.23

PHP 5.6.6

Dependent libraries

#为了省事,直接用yum来安装吧
yum -y install libmcrypt-devel libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel openssl-devel

Create PHP log directory
mkdir -p /var/logs/php

Set compilation parameters
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/etc/php \
--with-mysql=/usr/local/mysql \
--with-mysqli \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-curl \
--enable-mbstring \
--enable-sockets \
--enable-pcntl \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mcrypt \
--with-openssl \
--with-pdo-mysql \
--with-libxml-dir \
--with-zlib \
--with-pcre-dir
Start compiling and installing
make && make install
Note: If the error "virtual memory exhausted: Cannot allocate memory" appears during the compilation process, it means that the machine's memory is too small. At this time, you can try adding a --diable-fileinfo to the compilation parameters, and then recompile. Install

Configure php-fpm.conf

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/etc/php/php-fpm.conf
vi /usr/local/etc/php/php-fpm.conf
’s main modifications are:

Note: user and group must be consistent with the running user and group of nginx

Configure php.ini

cp /usr/local/src/php-5.6.6/php.ini-development /usr/local/etc/php/php.ini
vi /usr/local/etc/php/php.ini
The main modifications are:

Start php-fpm

/usr/local/php/sbin/php-fpm -c /usr/local/etc/php/php.ini -y /usr/local/etc/php/php-fpm.conf

Modify nginx.conf



Restart nginx

/usr/local/sbin/nginx/nginx -s stop
/usr/local/sbin/nginx/nginx -c /usr/local/etc/nginx/nginx.conf

The above introduces how to install PHP in source code mode on CentOS, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:nginx command collectionNext article:nginx command collection