Installation and configuration of Apache HTTP Server 2.0

Source: Internet
Author: User

Install and run Apache 2 as a service
Double-click the file apache_2.0.48-win32-x86-no_ssl.msi to automatically install Apache HTTP Server 2.0.48, assuming the installation directory is % apache2_home %. The following options are available during installation:
For all users, on port 80, as a service
Only for the current user, on port 8080, when started manually
We recommend that you install Apache as the startup service and listen on port 80. If it is installed to manually start and listen on port 8080, it will conflict with the port number occupied by Tomcat, And I have encountered some trouble when manually starting and stopping the Apache server.
If an old version of Apache server (for example, Apache 1.38.0 is installed as a startup service and uses port 80, you can enter the directory where the installation directory of the apacheserver (apache.exe file) is located, use the following command to close and remove it:
Apache-K shutdown
Apache-K uninstall
If Apache 2 is not installed as a startup service, run the following command to add apache2 to start the service:
% Apache2_home % \ bin \ apache-K install
After Apache 2 is installed successfully, it will be automatically started on port 80 when Windows is started. Apachemonitor (Program Added to the Start/Program/Start Menu ). Apachemonitor can monitor the running status of Apache 2 and provide convenient startup, shutdown, and restart operations, similar to apmgr.exe in Apache 1.3. For hot users, you can also exit apachemonitor and delete it from the start/Program/Start Menu, which does not affect the running of Apache 2.
To manually start, shut down, and restart Apache 2, follow these steps:
% Apache2_home % \ bin \ apache-K start
% Apache2_home % \ bin \ apache-K restart
% Apache2_home % \ bin \ apache-K shutdown
Possible problems and solutions:
When Apache 2 is started, restarted, or disabled, the following error occurs: no installed service named apache2-Apache 2 is not installed as a startup service, run the command % apache2_home % \ bin \ apache-K install to start the service.
When Apache 2 is started, the following prompt appears: cocould not bind to address 0.0.0.0: 80-other programs occupy port 80, which may be earlier versions of Apache, it may also be other HTTP servers (such as Windows IIS). You need to disable them before starting Apache 2 on port 80.
Or, because IIS is running and IIS uses port 80, change Apache to port 8080,
Change Listen 80 in the httpd. conf file --> listen 8080,
--> Remove Apache --> reinstall Apache,
Then restart Apache services,
Enter http: // localhost: 8080/index.html. En in the browser.
Apache 2 Configuration
You can change Apache configuration file % apache2_home %/CONF/httpd. conf to set your own Apache server. Note that you must stop the running Apache server before modifying the configuration file.
Add the following lines to the corresponding location to define your own file system container and set the ing between your local file system and the network space:
Alias/Homepage "D:/heavyz/Homepage"
<Directory "D:/heavyz/Homepage">
Options indexes followsymlinks-execcgi
Directoryindex index. php index.html home/index. php home/index.html
Order allow, deny
Allow from all
Deny from enpc. fr
</Directory>
The preceding statement defines a file system container using the <directory> label and maps the container to the/homepage URL using the alias command. This file system container also defines a series of attributes. The preceding configurations are described as follows:
<Directory "D:/heavyz/Homepage"> and </directory>: defines the local file system container, which is located in D:/heavyz/homepage.
Alias/Homepage "D:/heavyz/Homepage": when the path name in the URL is/homepage, It is mapped to the file system container.
Options indexes followsymlinks-execcgi: When the default homepage is not found, the contents of the Directory are allowed to be listed; the symbolic chains in the directory are allowed; CGI scripts are not allowed.
Directoryindex index. php index.html home/index. php home/index.html: Search for the default homepage based on the four local URLs listed. The first file found is returned as the homepage.
Order allow, deny: Order specifies the HTTP client's access permissions. Allow and then deny (allow, deny) indicates that the allowed access permission in allow has a higher priority than the access permission in deny.
Allow from all: First allow access requests from HTTP customers from any location.
Deny from enpc. FR: Disable the domain name as enpc. requests from HTTP customers of FR (the host of National Luqiao school enpc is not allowed to access this page). For these customers, the server returns 403 Forbidden information. Note that the deny priority defined in order is higher than allow, so this command will take effect.
Assume that the file D: \ heavyz \ homepage \ index.html exists on the local file system, restart the Apache server, and access the page: http: // localhost/homepage can access the above files (provided that you are not in the enpc network ).
For more information about Apache configuration, see Apache HTTP server documentation project.
Comments
The pages returned by Apache are always ISO-8859-1 encoded and inconvenient to display gb2312 Chinese or UTF-8 Unicode. How can I fix this?
Modify the configuration file % apache2_home %/CONF/httpd. conf and comment out the following lines:
Adddefacharcharset ISO-8859-1
How can we make Apache listen on another port (such as 81?
First uninstall apache service:
% Apache2_home % \ bin \ apache-K uninstall
Modify the following lines in the configuration file % apache2_home % \ conf \ httpd. conf:
Listen 80 --> listen 81
Reinstall apache service:
% Apache2_home % \ bin \ apache-K install

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.