Software version

  • Apache 2.4.29
  • PHP 5.4.45

PHP installation

# tar-zxvf php-5.4.45.tar.gz # CD php-5.4.45 #./configure --prefix=/usr/local/ PHP --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml2=/usr/include/libxml2 # make # make install

Errors in installation and resolution

An error occurred in the following steps

/configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-libxml2=/usr/include/libxml2

Error log:

Sorry, I cannot run apxs.  Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

The output of /usr/local/apache2/bin/apxs follows:
./configure: /usr/local/apache2/bin/apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory
configure: error: Aborting

Follow the instructions to install Perl

# yum install -y perl # perl-v // This is perl, # yum install -y perl // V5.10.1 (*) Built for x86_64-linux-multithread Copyright 1987-2009, v5.10.1 (*) Built for x86_64-linux-multithread Copyright 1987-2009, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Again./configure still shows this error. So Baidu… If you install Apache without Perl, APXS will not run. Remedy: Check the file

# cat /usr/local/apache2/bin/apxs

The first line is #! / replace/with/path/to/perl/interpreter – w: #! /usr/bin/perl-w again:

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml2=/usr/include/libxml2

Success!

Integration with apache

1. HTTPD. Conf

If PHP is installed correctly, the Apache configuration file will be automatically backed up (httpd.conf.bak) and modified as follows: Open the following comments and load the PHP module. LoadModule php5_module modules/libphp5.so

If you want Apache to parse PHP files, you need to add this to httpd.conf (# addoutputFilter Includes. Shtml) :

AddType application/x-httpd-php .html
AddHandler php5-script .php
  1. Let Apache parse the PHP code addHandler php5-script.php
  2. Tell Apache to parse the PHP code in the HTML addType application/ x-httpd-php.html

2. Add PHP files such as info.php to apache/htdos/

<? php phpinfo(); ? >

3. Restart the apache

4. Visithttp:ip/info.phpSee if it’s parsed