Install PHP
Amin writing this tutorial, PHP is currently the latest version of 5.5, Believe that most of the site is still running 5.2 or older version, in fact, 5.2 version of PHP is very classic and stable, because Amin's company has been using the 5.2 version, but considering the version is too old, there will be some loopholes, it is recommended that you use the 5.3 or 5.4 version, PHP official:/http Www.php.net/downloads.php the stable version of the current php5.3 is php-5.3.27.
Download PHP:
[Email protected] httpd-2.2.24]# cd/usr/local/src[[email protected] src]# wget http://am1.php.net/distributions/ Php-5.3.27.tar.gz
Extract:
[Email protected] src]# tar zxf php-5.3.27.tar.gz
To configure the compilation parameters:
[Email protected] src]# CD Php-5.3.27[[email protected] php-5.3.27]#./configure--prefix=/usr/local/php--with-apxs2= /usr/local/apache2/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql-- With-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir-- with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets-- Enable-exif--disable-ipv6
In this step, Amin encounters the following error:
Configure:error:xml2-config not found. Please check your LIBXML2 installation.
The solution is:
Yum Install-y libxml2-devel
There are also errors:
Configure:error:Cannot find OpenSSL ' s <evp.h>
The solution is:
Yum Install-y OpenSSL Openssl-devel
Error:
Checking for BZIP2 in default path ... not foundconfigure:error:Please reinstall the BZIP2 distribution
Workaround:
Yum install-y bzip2 Bzip2-devel
Error:
Configure:error:png.h not found.
Workaround:
Yum install-y libpng Libpng-devel
Error:
Configure:error:freetype.h not found.
Workaround:
Yum install-y FreeType Freetype-devel
Error:
Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
Workaround:
Rpm-ivh "http://www.lishiming.net/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm" Yum install-y Libmcrypt-devel
because the centos6.x default yum source does not libmcrypt-devel this package, it can only be assisted by a third-party yum source .
Compile:
[[email protected] php-5.3.27] #make
In this step, you may also encounter many errors, no relationship, please carefully review the error message, the solution is very simple, is to install the missing library. You can copy the error information to Google search, if it is not resolved, please go to Amin forum (http://www.lishiming.net/forum-40-1.html) post to consult Amin Bar.
Installation:
[[email protected] php-5.3.27] #make Install
Copy the configuration file:
[email protected] php-5.3.27]# CP Php.ini-production/usr/local/php/etc/php.ini
Apache with PHP
The Apache master configuration file is:/usr/local/apache2/conf/httpd.conf
Vim/usr/local/apache2/conf/httpd.conf
Found it:
AddType application/x-gzip. gz. tgz
Under this line, add the following:
AddType application/x-httpd-php. php
Found it:
<ifmodule dir_module> DirectoryIndex index.html</ifmodule>
Change the line to read:
<ifmodule dir_module> directoryindex index.html index.htm index.php</ifmodule>
Found it:
#ServerName www.example.com:80
Modified to:
ServerName localhost:80
Test if lamp is successful
Verify that the configuration file is correct before starting Apache:
/usr/local/apache2/bin/apachectl-t
If there is an error, please continue to modify httpd.conf, if it is correct is displayed as "Syntax OK", the command to start Apache:
/usr/local/apache2/bin/apachectl start
To see if it starts:
[[email protected] ~]# NETSTAT-LNP |grep httpdtcp 0 0::: +:::* LISTEN 7667/htt Pd
If this line is displayed, it is started. You can also use the Curl command to simply test:
[Email protected] ~]# Curl Localhost
This is only true if it is displayed.
Test if PHP is parsed correctly:
vim/usr/local/apache2/htdocs/1.php
Write:
<?php echo "PHP parse normal";? >
After saving, continue testing:
Curl localhost/1.php
See if you can see the following information:
[[email protected] ~]# Curl localhost/1.phpphp parse normal [[email protected] ~]#
Only shown as Amin is correct.
Lamp environment is set up, this is actually only installed on the software, and the specific configuration still have a lot of work to do? In other words, although you set up the environment, but if you do not configure the details of things, the equivalent of no work experience, so still more configuration configuration Apache or PHP bar, specific reference materials can be found in the corresponding version of the Amin forum, most of the posts for Amin work is configured, Amin sincerely hope you can follow the Amin of the post configuration, this will be of great benefit to you. Forum Address: http://www.lishiming.net/forum.php
Amin suggest you better expand your study: http://www.lishiming.net/thread-5441-1-1.html
1.4-php Compile and install--installation sequence at the end