Apache configuration and virtual host settings in Windows

Source: Internet
Author: User

Next, let's take a look at the Apache configuration and virtual host settings in Windows. This article tells you how to install apache and configure the php environment in apache.

Download Apache: http://httpd.apache.org/download.cgi

Installation Steps skipped ....

After the Apache program is installed, the Monitor apache servers cannot be started, and the icon is displayed as a red stop sign. Hover the mouse over the Apache service icon in the taskbar to display "No services installed". The reason is as follows:

The Apache service is not successfully installed.

If the Apache service program is successfully installed, right-click "my computer"-"manage"-"services and applications"-"services"-"services", and you can see that the apache service exists in the list on the right. If it does not exist, the server is not successfully installed. The specific solution is as follows:

1) Enter cmd to enter the dos operation interface;
2) Go to the Apache installation directory:


Cd C:/Program Files/Apache Software Foundation/Apache2.2/bin
3) type the command:


Httpd.exe-k install-n apache2
Add apache as a Service. In apache2

Apache.exe-k install-n apache2.
4) start the service. Enter the command: net start apache2.

If apache cannot be started, set httpd. remove ServerName # comment in the conf file, change the original host name to localhost, and use netstat-anb to check the occupied process and terminate the program of the process if port 80 is occupied, or change the port number.

Combine php with Apache in module mode to integrate php into Apache

Open httpd. conf and add the following five lines:

LoadModule php5_module C:/PHP/php5apache2_2.dll
LoadFile C:/PHP/libeay32.dll
LoadFile C:/PHP/ssleay32.dll
PHPIniDir "C:/PHP" # directory of the php. ini file
AddType application/x-httpd-php. php
Find
DirectoryIndex index.html
Changed:
DirectoryIndex index. php index.html
-------------------
The following method is more neat, with the same effect as above

Find:
# LoadModule vhost_alias_module modules/mod_vhost_alias.so
Add a row after
LoadModule php5_module C:/PHP/php5apache2_2.dll
LoadFile C:/PHP/libeay32.dll
LoadFile C:/PHP/ssleay32.dll
PHPIniDir "C:/PHP"
 
Find:
AddType application/x-gzip. gz. tgz
Add a row after
AddType application/x-httpd-php. php
Add AddType application/x-httpd-php. html extension to this line. You can also run the php program.
The libeay32.dll and ssleay32.dll files are php. the extension = php_curl.dll extension is enabled in the ini file. If the extension is not enabled, you can delete the two lines of code that call the two files.

========================================================== ======================================
To add a VM:

Find
ServerAdmin
Add "#" (not including double quotation marks) to comment out this section.

Find


DocumentRoot "DocumentRoot" C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
This is the location where you install apache. You should note this section.

If all the sites in the virtual space are under the wwwroot directory of the d disk, add this section

<Directory "D:/wwwroot">
Options Indexes FollowSymLinks
AllowOverride All
Order allow, deny
Allow from all
</Directory>
This is very important. Next, we will put all the sites under the wwwroot directory for normal access.

Find


# Include conf/extra/httpd-vhosts.conf
Cancel the previous # comment to make it take effect

Then you can go to the extra directory, set the httpd-vhosts.conf, add site
Example:

<VirtualHost *: 80>
ServerAdmin webmaster @ domain name. com
DocumentRoot "D:/wwwroot/Domain Name. com/www"
ServerName domain name. com
ServerAlias www. Domain Name. com
ErrorLog "D:/wwwroot/Domain Name. com/logs/Domain Name. com-error.log"
CustomLog "D:/wwwroot/Domain Name. com/logs/Domain Name. com-access.log" common
</VirtualHost>
</Directory>
To create a virtual directory (File ing) for the site, add the following content to the <VirtualHost *: 80> </VirtualHost> label:

Alias/uploads "D:/wwwroot/Domain Name. com/www/wp-content/uploads"
<Directory "D:/wwwroot/Domain Name. com/www/wp-content/uploads">
Order allow, deny
Allow from all
</Directory>


Through the virtual directory (File ing), the regular expression:

Http: // www. Domain Name. com/wp-content/uploads/

Access by using the following alias:

Http: // www. Domain Name. com/uploads/

If you need to use the html static function of rewrite,
In the httpd. conf file, find
# LoadModule rewrite_module modules/mod_rewrite.so

Cancel the # comment to make the mod_rewrite.so module take effect.

And put all
AllowOverride None

Change
AllowOverride All

Okay, everything is okay. Don't forget restat Apache

Related Article

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.