Table of Contents
Software version
php installation
Installation Errors and solutions in
The following steps lead to errors
Integration with apache
1.httpd.conf modification
2. Add php files to apache/htdos/ such as: info.php
3. Restart apache
4. Visit http: Check whether ip/info.php is parsed
Home Backend Development PHP Tutorial Introduction to PHP installation and integration with apache

Introduction to PHP installation and integration with apache

Jul 13, 2018 pm 03:24 PM
apache linux perl php

This article mainly introduces the installation of PHP and the integration with apache. It has certain reference value. Now I share it with you. Friends in need can refer to it

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
Copy after login

Installation Errors and solutions in

The following steps lead to errors

/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
Copy after login

Follow the prompts to install perl

# perl -v  //先查看果然没安装
# yum install -y perl
# perl -v  //安装成功
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi

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.
Copy after login

Again./configure still prompts this error. So Baidu. . . .
I learned that you need to follow perl first and then apache. If you install apache without installing perl, apxs will not run.
Remedy:
Check the file

# cat /usr/local/apache2/bin/apxs
Copy after login

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

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

Success!

Integration with apache

1.httpd.conf modification

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

If you want apache to parse the php file, you also need to add it to httpd.conf (#AddOutputFilter INCLUDES .shtml below):

AddType application/x-httpd-php .html
AddHandler php5-script .php
Copy after login
  1. Let apache parse the PHP code
    AddHandler php5-script .php

  2. Let apache parse the PHP code in html
    AddType application/x-httpd-php. html

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

<?php
phpinfo();
?>
Copy after login

3. Restart apache

4. Visit http: Check whether ip/info.php is parsed

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Android and PHP realize simple login

The above is the detailed content of Introduction to PHP installation and integration with apache. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1663
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Docker on Linux: Containerization for Linux Systems Docker on Linux: Containerization for Linux Systems Apr 22, 2025 am 12:03 AM

Docker is important on Linux because Linux is its native platform that provides rich tools and community support. 1. Install Docker: Use sudoapt-getupdate and sudoapt-getinstalldocker-cedocker-ce-clicotainerd.io. 2. Create and manage containers: Use dockerrun commands, such as dockerrun-d--namemynginx-p80:80nginx. 3. Write Dockerfile: Optimize the image size and use multi-stage construction. 4. Optimization and debugging: Use dockerlogs and dockerex

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Beyond the Hype: Assessing Apache's Current Role Beyond the Hype: Assessing Apache's Current Role Apr 21, 2025 am 12:14 AM

Apache remains important in today's technology ecosystem. 1) In the fields of web services and big data processing, ApacheHTTPServer, Kafka and Hadoop are still the first choice. 2) In the future, we need to pay attention to cloud nativeization, performance optimization and ecosystem simplification to maintain competitiveness.

How to process and display percentage numbers in Java? How to process and display percentage numbers in Java? Apr 19, 2025 pm 10:48 PM

Display and processing of percentage numbers in Java In Java programming, the need to process and display percentage numbers is very common, for example, when processing Excel tables...

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

NGINX and Apache: Understanding the Key Differences NGINX and Apache: Understanding the Key Differences Apr 26, 2025 am 12:01 AM

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

CentOS: Security, Stability, and Performance CentOS: Security, Stability, and Performance Apr 21, 2025 am 12:11 AM

CentOS is the first choice for server and enterprise environments for its superior security, stability and performance. 1) Security provides forced access control through SELinux to improve system security. 2) Stability is supported by the LTS version for up to 10 years to ensure the stability of the system. 3) Performance significantly improves system response speed and resource utilization by optimizing kernel and system configuration.

See all articles