Home > Backend Development > PHP Tutorial > Apache PHP compilation and installation tutorial under the directory

Apache PHP compilation and installation tutorial under the directory

PHPz
Release: 2024-03-08 22:22:02
Original
703 people have browsed it

目录下Apache PHP编译安装教程

Apache PHP compilation and installation tutorial in the directory

1. Introduction

When building a website server, Apache and PHP are two commonly used software. This tutorial will introduce how to install Apache and PHP by compiling source code under a Linux system for more flexible configuration and customization.

2. Install Apache

2.1 Download the Apache source code

First, visit the Apache official website (https://httpd.apache.org/) to download the latest version of the source code Bag. Extract the compressed package to the specified directory.

2.2 Compile and install Apache

cd /path/to/apache_source_code
./configure --prefix=/usr/local/apache2
make
make install
Copy after login

2.3 Configure Apache

Edit the Apache configuration file/usr/local/apache2/conf/httpd.conf, according to Configuration is required, such as setting up a virtual host, modifying ports, etc.

2.4 Start Apache

/usr/local/apache2/bin/apachectl start
Copy after login

3. Install PHP

3.1 Download PHP source code

Visit PHP official website (https://www.php.net /) Download the required version of the PHP source code package and extract it to the specified directory.

3.2 Compile and install PHP

cd /path/to/php_source_code
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
make
make install
Copy after login

3.3 Configure PHP

Edit the PHP configuration file/usr/local/php/php.ini, configure according to requirements PHP parameters, such as setting time zone, adjusting memory limit, etc.

3.4 Configure Apache to load the PHP module

Add the following content in the Apache configuration file:

LoadModule php7_module        modules/libphp7.so
AddHandler php7-script php
Include conf/extra/php7_module.conf
Copy after login

3.5 Restart Apache

/usr/local/apache2/bin/apachectl restart
Copy after login

4. Test PHP

Create the info.php file in the Web directory with the content:

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

Access in the browser http://your_domain/info.php , if the PHP information page can be displayed normally, the PHP installation is successful.

Summary

Through the above steps, we successfully compiled and installed Apache and PHP on the Linux system, and completed the integration configuration between them. This method allows us to better understand the operating mechanism of these two software, and also facilitates customized configuration according to actual needs. Hope this tutorial is helpful to you.

The above is the detailed content of Apache PHP compilation and installation tutorial under the directory. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template