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

Install PHP from source on CentOS

WBOY
Release: 2016-08-08 09:28:12
Original
1061 people have browsed it

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
Copy after login

Create PHP log directory
mkdir -p /var/logs/php
Copy after login

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
Copy after login
Start compiling and installing
make && make install
Copy after login
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
Copy after login
’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
Copy after login
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
Copy after login

Modify nginx.conf



Restart nginx

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

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template