11.14/11.15 Apache and PHP combined 11.16/11.17 Apache default virtual Host

Source: Internet
Author: User

11.14/11.15 Apache and PHP combined

When you start httpd, there are warning prompts to define the servername in the configuration file.

Vim/usr/local/apache2.4/conf/httpd.conf
Enter/ServerName search to cancel the previous #, enter/ Php5.so Search will PHP7 or PHP5 commented out, according to the actual situation of the Apache module, I here is the comment PHP5, the comment php7 Restart service will error, because the PHP7 module is called, if the call is PHP5 then comment out PHP7


Then restart the service without a warning prompt
/usr/local/apache2.4/bin/apachectl Restartrs
Win Ping Linux IP, whether it is possible to connect the next 80 port telnet 192.168.137.129 80, if the prompt does not have this command, it is necessary to add Telnet client under the Windows function under the Control Panel under startup or shutdown
Open the Linux 80 port so that win can access
IPTABLES-NVL View port, if there is no 80 port
This temporarily adds 80 ports.

Then reopen the Win DOS window and connect telnet 192.168.137.129 80, this time you can connect, press CTRL +] Enter quit
Change require all denied
Vim/usr/local/apache2.4/conf/httpd.conf
Enter/denied Search
Change require all denied to require all granted

Just now in win can access is because require all denied below is a require all granted, if require all granted changed to require all denied And then see if the configuration file has syntax errors for the command, this command is very useful
/usr/local/apache2.4/bin/apachectl-t

After changing the configuration file reload, use the following command, but it does not pin restart service
/usr/local/apache2.4/bin/apachectl Graceful
Just change the require all granted down there is a require all granted, if you change this to
Require all denied win access error, do not allow access

Because you want to support PHP, so you need to add a line of PHP-related configuration, if you do not add this line, PHP will not be able to parse
Vim/usr/local/apache2.4/conf/httpd.conf
Enter/addtype search and add AddType application/x-httpd-php in the following location. php

Also to modify the index page
Edit the configuration file, enter/index search, find this line directoryindex index.html add index.php at the back
Then check the configuration for any errors, reload the configuration file

Verify if Apache supports PHP
It accesses this directory is/usr/local/apache2.4/htdocs file, edit this directory can write a 1.php

The contents are as follows

At this time in win access to this page, you can open this page, explained that support PHP parsing

If you hit this line, comment out DirectoryIndex index.html and reload the configuration file.
Win re-visit the web will not be supported, cannot open the page
If you encounter Apach parsing, check the Apache configuration file
First line to check
/usr/local/apache2.4/bin/apachectl-m See if there are any PHP5 or PHP7 modules loaded

If not loaded to see if there is no this module

If you have this module but not the load then check that the configuration file has no php5 or PHP7 add this line
Vim/usr/local/apache2.4/conf/httpd.conf

Find used command search, you can ctrl+r and then enter the search characters, such as Grac, will show the command just used
/usr/local/apache2.4/bin/apachectl Graceful

11.16 11.17 Apache Default virtual Host

Open the virtual host configuration file
Vim/usr/local/apache2/conf/httpd.conf
Search for/extra and find the # Comment of the line below the virtual hosts

Each 80 port represents a host
Change the host parameters as shown
Vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

Create a directory separately

Define the file under the corresponding site root directory abc.com

The contents are as follows

Define the file at the corresponding site root directory 111.com

The contents are as follows

Check the configuration file for any errors and reload

Curl-x will abc.com specify the IP and port, regardless of that domain name as long as access to this IP will access to abc.com
Because abc.com is the default virtual host

The following is the specified to 111.com, if not specified, will access the ABC.com

Once you open the virtualhosts,httpd.conf inside, the servername will fail.

11.14/11.15 Apache and PHP combined 11.16/11.17 Apache default virtual Host

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.