Home > Backend Development > PHP Tutorial > Compile and install php under centOS

Compile and install php under centOS

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-08 09:31:31
Original
908 people have browsed it

Continuing from the previous article, compiling and installing apache under centOS

I spent a long time compiling and installing php before, which was very annoying, but now I finally got it straightened out. Sort it out.

1. Install dependency files
yum groupinstall "Development tools"

If you do not install these development libraries, you will need to install a lot of things by yourself
Other dependency 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 it prompts
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 directory /usr/local/php

If no error is reported, there is no need for the with-mcrypt=/usr/local/libmcrypt/ 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 you are of good character, 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 apache configuration file has enabled association (usually , after installing php, it will be enabled, if it is not enabled, enable it)
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
Find 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
Visit: 127.0.0.1/info.php 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 introduces the compilation and installation of PHP under centOS, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template