Build and install PHP under CentOS

Source: Internet
Author: User
Tags mcrypt
Next post, CentOS under compile and install Apache

Before compiling and installing PHP was a long time, very annoyed, and now finally straightened out. Tidy up a bit.

1. Install dependent files
Yum Groupinstall "Development tools"

If you do not install these libraries, then you will need to install a lot of things yourself
Other dependent files
Yum install libxml2-devel gd-devel libmcrypt-devel libcurl-devel openssl-devel
If prompted
2. Install PHP
wget Http://us3.php.net/get/php-5.5.20.tar.gz/from/cn2.php.net/mirror
TAR-XVF php-5.5.20.tar.gz
CD php-5.5.20
Compile, if prompted
Configure:error:mcrypt.h not found. Please reinstall Libmcrypt

You need to install Libmcrypt
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
TAR-ZXVF libmcrypt-2.5.7.tar.gz
CD libmcrypt-2.5.7
./configure prefix=/usr/local/libmcrypt/
Continue compiling PHP, install to directory/usr/local/php

If there is no error, you do not need to with-mcrypt=/usr/local/libmcrypt/this compilation option
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs--disable-cli--enable-shared--with-libxml-dir--WITH-GD-- With-openssl--enable-mbstring--with-mysqli--with-mysql--enable-opcache--enable-mysqlnd--enable-zip-- With-zlib-dir--with-pdo-mysql--with-jpeg-dir--with-freetype-dir--with-curl--without-pdo-sqlite-- Without-sqlite3--with-mcrypt=/usr/local/libmcrypt/
Make
Make install
If the character is good, the installation should be successful.


Copy php.ini
CP Php.ini-production/usr/local/php/lib/php.ini
3. Associating with Apache
See if the Apache profile is already connected (normally, after installing PHP, it will open if it is not turned on)
Vim/usr/local/apache/conf/httpd.conf
LoadModule Php5_module modules/libphp5.so
Add the following code:

SetHandler application/x-httpd-php

Change the code:
DirectoryIndex index.html index.shtml index.cgi index.php index.phtml index.php3
Locate the AddType and add the following 2 lines:
AddType application/x-httpd-php. php. PhP3. Phtml. Inc
AddType Application/x-httpd-php-source. Phps
4. Test PHP
vim/usr/local/apache/htdocs/info.php
Enter the code:
Phpinfo ();
?>
Restart Apache
/ETC/INIT.D/HTTPD restart
Access: 127.0.0.1/info.php can see the installation information of PHP, enjoy it!
Reference
1, http://www.onepx.com/centos-php-55.html
2, http://blog.163.com/yxba_02/blog/static/1875576201272583532588/

The above describes the installation of CentOS under the compiler to install PHP, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.