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.
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.
cd /path/to/apache_source_code ./configure --prefix=/usr/local/apache2 make make install
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.
/usr/local/apache2/bin/apachectl start
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.
cd /path/to/php_source_code ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs make make install
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.
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
/usr/local/apache2/bin/apachectl restart
Create the info.php
file in the Web directory with the content:
<?php phpinfo(); ?>
Access in the browser http://your_domain/info.php
, if the PHP information page can be displayed normally, the PHP installation is successful.
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!