CentOS Install PHP php-fpm nginx

Source: Internet
Author: User
Tags curl fpm install php install openssl openssl php source code readline zend

I. Installation of Nginx

Be careful not to forget to install Pcre

Two. Install PHP

1, download the PHP source code package

http://www.php.net/downloads.php

2. Install PHP

TAR-XVF php-5.5.13.tar.bz2

CD php-5.5.13

./configure--prefix=/usr/local/php--with-config-file-path=/etc--enable-inline-optimization--disable-debug- Disable-rpath--enable-shared--enable-opcache--enable-fpm--with-fpm-user=www--with-fpm-group=www Mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--with-gettext--enable-mbstring--with-iconv-- With-mhash--with-openssl--enable-bcmath--enable-soap--with-libxml-dir--enable-pcntl-- Enable-sysvmsg--enable-sysvsem--enable-sysvshm--enable-sockets--with-curl--with-zlib- With-readline--without-sqlite3--without-pdo-sqlite--with-pear

Error occurred: Congigure error:xml2-config not found.

Solution:

Execute command: sudo yum install Libxml2-devel

See if success: Find/-name "Xml2-config"

Error occurred: Congigure error:cannot find OpenSSL ' s <evp.h>

Solution:

Yum Install OpenSSL Openssl-devel

Ln-s/usr/lib64/libssl.so/usr/lib/

Error occurred: Configure:error:Please Reinstall the BZIP2 distribution

Solution: Yum Install bzip2 Bzip2-devel

Error occurred: Configure:error:Please Reinstall the Libcurl distribution-easy.h should is in <curl-dir>/include/curl/

Solution: Yum-y Install Curl-devel

Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.

sudo yum install libmcrypt libmcrypt-devel mcrypt Mhash

Configure:error:Please Reinstall Readline-i Cannot find readline.h
sudo yum install Readline-devel

Make

Make install

Add PHP command to environment variable

Vim/etc/profile

Add at end

Path= $PATH:/usr/local/php/bin

Export PATH

To make the changes take effect immediately

. /etc/profile or Source/etc/profile

View environment variables

Echo $PATH

View PHP Version

Php-v

PHP 5.5.13 (CLI) (Built:jun 20 2014 11:11:26)
Copyright (c) 1997-2014 the PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Configure PHP-FPM

Cd/usr/local/php/etc

CP Php-fpm.conf.default php-fpm.conf

Start PHP-FPM

sudo/usr/local/php/sbin/php-fpm

Modify the Nginx profile (/etc/nginx/conf.d/default.conf)

Location/{

root Web roots directory;

Index index.html index.htm index.php;

}

Location ~ \.php$ {

root HTML;

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Fastcgi_param script_filename Web root directory $fastcgi_script_name;

Include Fastcgi_params;

}

Restart Nginx

/etc/init.d/nginx restart

Create a index.php under the Web root directory

<?php echo phpinfo ();?>

Enter http://ip/index.php in the browser to view success.

Note: Modify the Web root directory according to your own configuration, as my/usr/share/nginx/html.

If there is an error starting PHP-FPM: Can not get uid for WWW, modify php-fpm.conf user is Nginx group for Nginx

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.