Some people may immediately ask: Why not install MySql? This is because this project plans to purchase cloud RDS, so I will not install MySql in the system myself. Let’s get down to business and start installing the system. 1, Preparation, first download the source code package of the required software, which are as follows: apr-1.5.2.tar.gzapr-util-1.5.4. tar.gzpcre-8.36.tar.gzhttpd-2.4.17.tar.gzphp-5.6.15.tar.gz Put all the source code The package is uploaded to the server. 2, install Apache2.4 First you need to install the dependency library of Apacheapr-1.5.2.tar.gz apr-util-1.5.4 .tar.gzpcre-8.36.tar.gztar zxvf apr-1.5.2.tar.gzcd apr-1.5.2./con figure - -prefix=/usr/local/aprmake && make installtar zxvf apr-util-1.5.4.tar.gzcd apr-util-1.5.4. /configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprmake && make installtar zxvf pcre-8.36.tar.gz cd pcre-8.36./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprmake && make installInstall PCRE When encountering the following error: You need a C++ compiler for C++ supportThe solution is: yum install -y gcc gcc-c++Note: This -y must not be missing. You can start installing Apache, Unzip cd httpd-2.4.17./configure --prefix=/usr/local/A pache2 --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so--enable-rewrite make && make install Note: The ./configure configuration parameters copied from windows during the previous installation. For some reason, there are some extra newlines in the result, causing the running result to be wrong, so everyone copies the instructions Be careful when doing so. 2, install PHP5.6.15Unzip Cd php-5.6.15The configuration parameters are too complicated, so I went to the Internet to find a recommendation from an expert, as follows: . /configure --prefix=/usr/local/php--with-apxs2=/usr/local/Apache2/bin/apxs --with-libxml-dir=/usr/include/libxml2--with-config -file-path=/usr/local/Apache2/conf --with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-gd--enable-gd-native-ttf --with-zlib --with-mcrypt--with-pdo-mysql=/usr/local/mysql --enable-shmop --enable-soap -- enable-sockets--enable-wddx --enable-zip --with-xmlrpc --enable-fpm --enable-mbstring--with-zlib-dir --with-bz2 --with-curl --enable-exif
--enable-ftp--with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/lib/So ever I encountered a series of errors. I recommended my previous article to introduce solutions to common errors: http://blog.csdn.net/dodott/article/details/49664379 I encountered The problem encountered is as follows: 【Error report】Configure: error: Please reinstall the BZip2 distributionSolution: centos: yum install bzip2 bzip2-develdebian: apt-get install bzip2 -devel【Error report】configure: error: Please reinstall the libcurl distribution - easy.h should be in/include/curl/ Solution Solution: centos: yum install curl curl-devel (For Redhat & Fedora)【Error report】configure: error: mcrypt.h not found. Please reinstalllibmcrypt. Solution: Most of the methods given on the Internet are to use the following instructions yum install libmcrypt libmcrypt-devel (For Redhat & Fedora)But basically it has no effect, and the system will even prompt: nothing to do. It may be related to the fact that the software version of the YUM source is too low. The correct way is to download the source code and install it yourself: libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7#Compile (installed to /usr by default) /local/lib/) ./configure --prefix=/usr/local/libmcrypt #Execute installation make && make install Note: Remember the installation path here, it will be used when you install PHP later. Continue back to the PHP installation. The configuration parameters at this time are modified to: ./configure --prefix=/usr/local/php--with-apxs2=/usr/local /Apache2/bin/apxs --with-libxml-dir=/usr/include/libxml2--with-config-file-path=/usr/local/Apache2/conf --with-mysql= /usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-gd --enable-gd-native-ttf--with-zlib --with-pdo-mysql=/usr/local/mysql --enable-shmop --enable-soap--enable-sockets -- enable-wddx --enable-zip --with-xmlrpc --enable-fpm--enable-mbstring --with-zlib-dir --with-bz2 --with-curl --enable-exif--enable-ftp
--with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/lib/ --with-mcrypt=/usr/local/libmcrypt The modification is: removed --with-mcrypt, and added --with-mcrypt=/usr/local/libmcrypt at the end 【Error report】configure: error: Cannot find MySQL header files under/usr/local/mysql.Note that the MySQL client library is not bundled anymore!This problem is because mysql is not installed, so the mysql operation cannot be found library. But this installation itself does not want to install the complete mysql software. I went to the php official website to check the information and found the following translated text: "For php-5.3.0 or newer versions, mysqli uses the Mysql Native Driver by default. Driver. This driver has some advantages over libmysql, --with-mysql=mysqlnd”The final configure parameter is modified to:./configure --prefix=/usr/local/php --with -apxs2=/usr/local/Apache2/bin/apxs--with-libxml-dir=/usr/include/libxml2--with-config-file-path=/usr/local/Apache 2/conf--with-mysql=mysqlnd
--with-mysqli=mysqlnd --with-gd --enable-gd-native-ttf--with-zlib --with-pdo-mysql=mysqlnd --enable-shmop --enable-soap--enable-sockets --enable-wddx --enable-zip --with-xmlrpc --enable-fpm--enable-mbstring --with-zlib-dir --with-bz2 --with-curl --enable-exif--enable -ftp
--with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/lib/ --with-mcrypt=/usr/local/libmcrypt Note: The directory marked in red above is the directory where php.ini needs to be placed later. At this point, the configure of PHP was finally passed successfully. make and makeinstall. PHP is installed. 3. Modify the PHP configuration file php.iniEnter the php source code directory, select php.ini-development and copy a copy to /usr/local/Apache2/conf, and rename it to php .ini is opened with vi, search for extension_dir, and change it to extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20131226". Readers can configure it according to their own PHP installation directory structure. The purpose is to find PHP extension libraries. Look for extension=php_, remove extension=php_curl.dll, extension=php_gd2.dll, extension=php_mbstring.dll, extension=php_mysql.dll, extension=php_mysqli.dll, extension=php_pdo_mysql.dll, extension=php_xmlrpc.dll The semicolon in front of. Find short_open_tag = Off and change it to short_open_tag
= On, allowing it to support short tags (I see that this is turned on by default). I also copied the following files from other people’s servers and put them in the
/usr/local/php/lib/php/extensions/no-debug-zts-20131226 directory,
The file is as follows:
Imap.so
Mcrypt.so
Memcache.so
Openssl.so
Zip.so
Then add the following configuration text at the end of php.ini:
extension=memcache.so
extension=openssl.so
extension=mcrypt.so
extension=zip.so
4,修改Apache配置文件httpd.conf相关修改以支持PHPvi /usr/local/Apache /conf/httpd.conf? Add php support.【Add field one】AddType application/x-httpd-php .php .phtmlAddType application/x-httpd-php-source .phps 【Add field two】 SetHandler application/x-httpd-php? Add the default indexpage index.php, and then find "DirectoryIndex", in Add "index.php" after index.htmlDirectoryIndex index.html index.php? 3. Do not display the directory structure, find "OptionsIndexes FollowSymLinks" and change it to Options FollowSymLinks? 4 . Enable Apache to support pseudo-static, find "AllowOverride None", change it to AllowOverride All restartApacheservice httpd restart Reminder: I really don’t know how For configuration, just find a server that has been successfully built and get the configuration file to compare. At this time, you will also encounter the following error:
httpd: Could not reliably determine the server's fully qualified domain name
Solution:
linux: /usr/local/ Apache/conf
Open httpd.conf with notepad
and remove the #ServerName localhost:80 comment inside.
At this point, the entire Apache+PHP5.6 environment is completed.
Recommended article:
Compilation and installation of PHP
The above introduces the installation of Apache24+PHP56 under CentOS65, including Apache, preparation, indexing, and installation of Apache. I hope it will be helpful to friends who are interested in PHP tutorials.