How to install php and configure Apache server in linux
1 php1.1 preparation work
You need to install Apache first, those that have been installed can be skipped, and those that are not installed can see here.
1.2 download
Official website
1.3 decompress tar-zxvf php-7.4.3.tar.gzcd php-7.4.31.4 compile and install. / configure-- prefix=/usr/local/php-- with-apxs2=/usr/local/apache/bin/apxs
Prefix is the installation location, and the later option is apxs under the apache installation directory bin. After that:
Make sudo make install1.5 profile
You need to copy a php.ini file:
Sudo cp php.ini-development / usr/local/lib/php.ini2 Apache
At the end of conf/httpd.conf, add:
LoadModule php7_module modules/libphp7.so SetHandler application/x-httpd-php
If php5, please change it to:
LoadModule php5_module modules/libphp5.so
Finally, restart the apache service:
/ usr/local/apache/bin/apachectl restart3 test
Create a new test.php under htdocs under the apache directory: