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