Apache and PHP Combine

Source: Internet
Author: User


#vim/usr/local/apache2.4/conf/httpd.conf Edit httpd configuration file, PHP parsing, modify 4:
First place: Modify the #ServerName www.example.com:80 to ServerName www.example.com:80, and remove the previous #
#/usr/local/apache2.4/bin/apachectl Stop//Stop httpd Service
#/usr/local/apache2.4/bin/apachectl Start//Open httpd Service
Start HTTPD Error:/usr/local/apache2.4/bin/apachectl:line 79:47885 segmentation fault $HTTPD-K $ARGV
Workaround: vim/usr/local/apache2.4/conf/httpd.conf
Comment out 152 lines of PHP7 #LoadModule php7_module modules/libphp7.so
#/usr/local/apache2.4/bin/apachectl start//start again without an error.
#ps aux |grep httpd
In the browser directly enter the local IP test can be accessed, such as not access, troubleshooting reasons:
1, first ping the native IP can ping through
2. Telnet native 80 port (turn on the Telnet feature of Windows---Control Panel---Programs and features----turn Windows features on or off-open the Telnet client, and then telnet to the native IP 80 port to see if it can pass, Exit Telnet using CTRL +], and then quit exit
3, # IPTABLES-NVL//See if 80 ports are released, if not, add a rule
Iptables-i input-p TCP--dport 80-j ACCEPT
No problem with accessing the 80 port on this machine again.
Second place: Modify Require all denied to Require all granted
#/usr/local/apache2.4/bin/apachectl-t//Check the configuration file syntax is correct
#/usr/local/apache2.4/bin/apachectl Graceful//Reload configuration file
Third place: Add a line of PHP AddType application/x-httpd-php in the following two lines. php
AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
AddType application/x-httpd-php. php
Four: Add index.php on the second line as follows
<ifmodule dir_module>
DirectoryIndex index.html index.php
</IfModule>
#/usr/local/apache2.4/bin/apachectl-t//Test configuration file syntax is correct
#/usr/local/apache2.4/bin/apachectl Graceful//Reload
#vi/usr/local/apache2.4/htdocs/1.php//Manually create a test script 1.php with the following script:
<?php
Phpinfo ();
?>
Then we can access the native ip/1.php in the browser, we can see the following interface

If you do not increase the AddType application/x-httpd-php in the third place above, the access page will show the source code for this line of PHP.
Encountered PHP can not parse, look at the Apache configuration file, you need to check the options are:
1, #/USR/LOCAL/APACHE2.4/BIN/APACHECTL-M//Check that there is no load PHP5 module,
2, if not, please check if there is no this file # ls/usr/local/apache2.4/modules/libphp5.so, if there is this file, but not loaded, please check the Apache configuration file LoadModule php5_module Modules/libphp5.so whether this line is loaded
3. See if the configuration file has AddType application/x-httpd-php loaded. PHP This line
4, see if there is no add index.php, why need to add this index.php, is we visit a webpage it can jump to this page by default
<ifmodule dir_module>
DirectoryIndex index.html index.php
</IfModule>

Use PHP7 to disable PHP first:
Modify the configuration file, comment out PHP5 this line #LoadModule php5_module modules/libphp5.so
Use PHP7 this line LoadModule php7_module modules/libphp7.so
Shortcut Key Tip: When looking for a command history, press CTRL+R, and then enter the following parameters of the command, which will automatically help you quickly find the history command you used
#/usr/local/apache2.4/bin/apachectl-t//Check syntax is correct
#/usr/local/apache2.4/bin/apachectl Graceful//reload configuration, load up in browser can see PHP version changed to PHP7.1.6

Above the browser see the graphics and #/usr/local/php7/bin/php-i |less command See the information is actually the same

Apache and PHP Combine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.