First enter the command vim/usr/local/apache2.4/conf/httpd.conf, enter to view, see,
E2.4/conf/httpd.conf/usr/local/apache2.4/conf/httpd.conf/usr/loc
To parse PHP, here are 4 places to modify:
1, ServerName
2, Require all denied
3, AddType application/x-httpd-php. php
4, DirectoryIndex index.html index.php
1, ServerName
Like before command/usr/local/apache2.4/bin/apachectl restart, enter, see,
This hint seems to be an error, in fact, is a normal hint. If we don't want to see this, we can change it in the file/usr/local/apache2.4/conf/httpd.conf. Re-use VIM to enter the file, search/ServerName, specific changes See,
Remove the # in the red box and save and exit. Re-enter the order you just made, see,
There is an error on this side, displaying 79 rows with a problem, using the VIM command to enter the view again, see,
Found 79 lines, at the beginning of the line with # comment out the content, save and exit, and then restart, see,
The error still exists, after it has been stopped and reopened. It's time to think about the results of two PHP open. Use the!vim command, enter, 79 lines of # To remove, restore the original state, the PHP7 with # comment out, see,
Save and exit, and then try restarting, see,
There is no hint at this time. It is clear that php5 and PHP7 are in conflict. Then look at the process, enter the command PS aux |grep httpd, enter, see,
2, Require all denied
This side need to add a line of configuration, now look at the IP, input command ifconfig, enter, see,
The IP is shown in the Red box 192.168.218.128. Then enter the IP address in the address bar on the browser, carriage return, see,
After a while, you can see that the IP is inaccessible, and the Blue font prompts "Check proxy server and firewall". So, how to troubleshoot this problem? First ping the IP on Windows cmd, see,
You can see that the IP is available, and then judge its 80 port. Show no Telnet This command, is because we did not open the Telnet client, now the client's program opens, the concrete operation see,
First open "Control Panel", click "Program", enter,
Click "Enable or disable Windows features" to enter,
Select "Telnet Client" and click "OK", after a few minutes, it will be displayed,
Click Close to return to Windows CMD, re-enter the command telnet 192.168.128.218 80, enter, see,
Display 80 port connection failed. Since the 80 port is not open on the Linux virtual machine, you can use the command IPTABLES-NVL on Putty to view, see,
You can see that there are no 80 ports, to allow Windows to access 80 ports, you can use the command iptables-i input-p TCP--dport 80-j ACCEPT, temporarily add 80 ports, see,
After executing the above command, go back to the cmd on Windows, reenter the command just now telnet 192.168.218.128 80, enter, see,
Entering such a interface, it means that port 80 is through. CTRL + ", you can exit the interface, and then enter the command quit, you can return to the original interface. See
Then go back to the browser to refresh the IP address, see,
You can see several "it works!", which means you can access it.
Back to Putty, enter command vim/usr/local/apache2.4/conf/httpd.conf, return, search/require, enter, see,
We need to make a change to the contents of the two red box here, see,
Save and exit. After you change the configuration, use the command/usr/local/apache2.4/bin/apachectl-t to check that the configuration file is syntactically correct. See
You can see that the result is OK, stating that there is no problem with the configuration file syntax. Can intentionally add some arbitrary content in the configuration file, see,
Save and exit, re-execute command/usr/local/apache2.4/bin/apachectl-t, see,
Can see the error, so this is a very useful command, you can detect the configuration file syntax. Then change the configuration file back, this way does not show the process. Then reload the configuration file, use the command/usr/local/apache2.4/bin/apachectl graceful, enter, see,
Then go back to the browser and refresh the IP address you just made, see,
You will see a page that shows a ban, that is, the meaning of not allowing access. So, go back to the configuration file, to change both sides of the content to granted, save and exit, see,
This ensures that the Web page is allowed to be accessed.
3, AddType application/x-httpd-php. php
4, DirectoryIndex index.html index.php
Add a line of PHP-related content, input command vim/usr/local/apache2.4/conf/httpd.conf, enter, search/addtype, enter, find content,
Add the contents of the Red box AddType application/x-httpd-php php, search again/index, enter, find content,
Add the contents of the Red box index.php, save and exit. Then check the configuration file syntax and reload the configuration file, see,
Now to verify that Apache can support parsing PHP, first to write a test php script, input command vi/usr/local/apache2.4/htdocs/1.php, enter, see,
Enter the content, save and exit. Then go back to the browser, access the address 192.168.218.128/1.php,
Can see this very beautiful page, explained that PHP support parsing success. Now take a look, what page will appear if parsing is not supported? Change configuration file to Putty, enter command vim/usr/local/apache2.4/conf/httpd.conf, return, see,
This line of red box is commented out with the # number, save and exit. Then check and load the configuration file, see,
Then go back to the browser, refresh the page, see,
Is the source code, this is the case that PHP cannot parse. Therefore, after encountering PHP can not parse the situation, it is necessary to check the Apache file, first to check whether PHP is loaded, use command/usr/local/apache2.4/bin/apachectl-m, enter, see,
You can see that the last item has a PHP5. If not loaded, to see if there is no module file, input command ls/usr/local/apache2.4/modules/libphp5.so, enter, see,
Without this file, PHP cannot be loaded. If there is a file, and the add-in does not show PHP, it is necessary to check the configuration file, input command vim/usr/local/apache2.4/conf/httpd.conf, enter, search/libphp5.so, see,
See if there is a red box in this line, no words, certainly cannot parse. Then continue checking, search/addtype, enter, see,
See if there is a red box in this line, and then carefully check that the red box content format is correct, this side can use command/usr/local/apache2.4/bin/apachectl-t to check. Then search/index.php, enter, see,
Notice whether the contents of the red box are added. This is the function of the index, use the command ls/usr/local/apache2.4/htdocs/, enter, see,
There is a index.html file, this is the previous definition of the index.php, this side can jump directly to access index.html this file, so in the browser to access 192.168.218.128, it works!, the words will appear.
Because PHP5 and PHP7 cannot coexist, now try Php7. Go to config file, search/libphp, enter, see,
Change the contents of the red box, see,
Save and exit, then check and load the configuration file, see,
Back to the browser, refresh the page, see,
Also can see this beautiful page, this side note the version number, and the front of the PHP5 is not the same. The explanation PHP7 also takes effect, can parse. Enter a command on Putty/usr/local/php7/bin/php-i |less, enter, see,
You can see that the content displayed on the Web page and the content on this side are basically the same. Press the letter Q to exit the interface.
Apache and PHP Combine