Compile and install php under centOS

Source: Internet
Author: User
Tags mcrypt
: This article describes how to compile and install php in centOS. if you are interested in the PHP Tutorial, refer to it. Next, compile and install apache in centOS.

I had a long time before compiling and installing php, and I was very annoyed. now I have finally figured it out. Sort it out.

1. install dependency files
Yum groupinstall "Development tools"

If you do not install these development libraries, you need to install many things by yourself.
Other dependent files
Yum install libxml2-devel gd-devel libmcrypt-devel libcurl-devel openssl-devel
For example
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 to compile php and install it to the/usr/local/php directory.

If no error is reported, the compilation option with-mcrypt =/usr/local/libmcrypt/is not required.
. /Configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache/bin/apxs -- disable-cli -- enable-shared -- with-libxml-dir -- -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. associate with apache
Check whether the association is enabled for the apache configuration file. (generally, it is enabled after php is installed. if it is not enabled, it is enabled)
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 AddType and add the following two rows:
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 to view the php Installation Information. 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 how to compile and install php in centOS, including some content. I hope my friends who are interested in PHP tutorials can help me.

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.