Compile and install PHP 7.0.13 in Centos 6.5, centos7.0.13

Source: Internet
Author: User
Tags sapi

Compile and install PHP 7.0.13 in Centos 6.5, centos7.0.13

The official PHP7.0 version is also available. I have compiled and installed it today and wrote down the installation steps. I compiled it in the centos6.6 environment. The installation steps are as follows:

Environment dependency

yum install gcc gcc-c++ libxml2 libxml2-python libxml2-devel -y

Download

wget http://cn2.php.net/distributions/php-7.0.13.tar.gz

Extract

tar -zxvf php-7.0.13.tar.gzcd php-7.0.13./configure --enable-fpm --with-mysqlmakemake install

Create a configuration file and copy it to the correct location.

cp php.ini-development /usr/local/php/php.inicp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.confcp sapi/fpm/php-fpm /usr/local/bin

Note that, if the file does not exist, Nginx is prevented from sending requests to the backend PHP-FPM module to avoid malicious script injection attacks.

Set the configuration items in the php. ini filecgi.fix_pathinfoSet to 0.

vim /usr/local/php/php.ini

Gocgi.fix_pathinfo= And modify it as follows:

cgi.fix_pathinfo=0

Before starting the service, you need to modify the php-fpm.conf configuration file to ensure that the php-fpm module runs as the hz user and hz user group.

Copy fpm

cp /usr/local/etc/php-fpm.d/www.conf.default php-fpm.conf

Modify the fpm Module

vim /usr/local/etc/php-fpm.d/php-fpm.conf

Modify default port

listen = 127.0.0.1:9001; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user's group;  will be used.user = hzgroup = hz

Start the php-fpm service:

./usr/local/bin/php-fpm

Fpm Detection

./usr/local/bin/php-fpm -t [01-Dec-2016 18:11:43] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful

Default php Directory

find / -name php/php-7.0.13/sapi/cli/php/usr/local/include/php/usr/local/bin/php/usr/local/php/usr/local/php/php/usr/local/lib/php

Test page

Create phpinfo for work

echo '<?php phpinfo(); ?>' > /var/www/html/info.php

Create test page

curl http://localhost/info.php | grep 'PHP Version' | tail -1 | sed -e 's/<[^>]*>//g'

Webpage Testing

Http: // 192.168.31.66/info. php

Summary

The above is all about compiling and installing PHP 7.0.13 in Centos 6.5. I hope the content in this article will help you in your study or work, if you have any questions, you can leave a message.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.