One, Apache and PHP combined
- First open the local Telnet client (test port use)
/usr/local/apache2.4/bin/apachectl start //启动apache服务
- Modifying the Apache configuration file
- Because PHP5 and PHP7 have been loaded before, so here's a close one, run one of them
vim/usr/local/apache2.4/conf/httpd.conf//Modification of the following 4 places
- ServerName in front of the # removed
- Require all denied to Require all granted
- Add AddType application/x-httpd-php. php
-
DirectoryIndex index.html after adding index.php
- After saving the configuration file
/USR/LOCAL/APACHE2.4/BIN/APACHECTL-T//test syntax is correct
/usr/local/apache2.4/bin/apachectl Graceful//reload config file (no need to restart Apache)
Enter the host address in the browser to see if it enters
Unable to connect
First Test if you can ping the pass, and then test whether Port 80 is
The tested IP can ping, but the 80 port is not available, suspect that the server firewall does not open 80 port
iptables -nvL //发现确实没有80端口iptables -I INPUT -p tcp --dport 80 -j ACCEPT //临时打开80端口
At this time in cmd in the Telnet 192.168.127.133 80 appears black window, prove that 80 port has been measured through
Re-enter the IP address in the browser
vim /usr/local/apache2.4/htdocs/test.php //增加如下内容
<?php
Phpinfo ();
?>
Open http://192.168.127.133/test.php in the browser
Successful display of PHP5 configuration files
- If Apache cannot parse PHP, but instead displays the source code, then we need to check the following items
- /USR/LOCAL/APACHE2.4/BIN/APACHECTL-M Check if the PHP extension is loaded, whether or not
/usr/local/apache2.4/modules/libphp5.so file to verify that it is a PHP problem or an Apache configuration issue
- Check Apache configuration
LoadModule whether to load PHP
3. Check Apache Configuration
AddType application/x-httpd-php. Does PHP add
4. Check Apache configuration
5.DirectoryIndex index.html index.php whether to add
40.apache with PHP, apache default virtual host