Apache is currently the most frequently used web server in the world. For Linux users, it is also the most easy to use W
EB server, and it is free. In fact, if you just want to provide basic web page services with Apache
Then you may not need to adjust any configuration at all. However, on the other hand, Apache is a very powerful process.
Order, you can provide many professional features, in order to play its function, you must also understand the configuration about it.
.
First, if you use Apache on a non-Linux website, or your website is heavy (for example, 1000
The above connection is connected), then, usually you have to recompile Apache, which we don't introduce here.
(1) Start providing Web services
Apache's service has two ways, that is, the way HTTPD is performed by inetd or independently. Under normal circumstances
We use independent implementation. First you have to install Apache servers. The usual Linux distribution will contain
Apache's RPM package can be installed with rpm -i. Then you have to test it correct. Just take an HTML file.
, Named index.html, copy to / home / httpd / html directory, then execute httpd as root user
Down, use Browser on another machine to access your machine's IP address, you should display its content. If you are not
Check your work, turn again.
Apache uses the page files used by INDEX.html, error output is / var / log / httpd / if there is
Not normal, check the ERROR_LOG file inside.
Many times, you need to change the location of the web file, or introduce some CGI services for the web page, for this, you must
To modify the /etc/httpd/conf/srm.conf file. First, you will find the following paragraph:
DocumentRoot / Home / httpd / html
This sentence description, the page files used by Apache are stored in / home / httpd / html, so if you want to change the web
The storage path should be modified here.
Another corresponding paragraph is
DirectoryIndex Index.html Index.shtml Index.cgi
It indicates that if someone visits your machine, the homepage will be index.html or index under the path defined above.
SHTML, INDEX.CGI. If your website is another name, modify this sentence.
Another common option is
Scriptalias / cgi-bin / / home / httpd / cgi-bin /
It defines that when using the CGI program, the directory referenced by the page is / cgi-bin /, and the path actually stored is / HOME / HTT
PD / CGI-BIN /
(2) Use Apache to do Web Proxy
Proxy is a proxy. The web agent of the Apache refers to the client server to access WwW through Apache, so
The Apache server will receive a request from the client, and then first go to the target site, and save the inner
Store on the Apache server, then submit it to the customer. After another client needs to access the same content.
Apache will get content directly from the server hard disk and submit it to the customer.
To use Apache Proxy, you need to edit /etc/httpd/conf/httpd.conf, assume your Apache machine address
For 111.111.111.111, the proxy port is 8080 (usually the value greater than 1024), and the paragraph that needs to be changed.
Listen 111.111.111.111 8080 # Open 8080 port
ProxyRequest On # Start Proxy Service
Cacheroot / var / cache / httpd # default proxy cache directory, must be a writable directory
Cachesize 2000 #cache's size, unit is KB, set bigger a little harmless, right?
Cachegcinterval 48 # automatically cleans Cache every hour, delete the garbage exceeding the cache space
CacheMaxExpire 24 #Cache's maximum validity period, or that cache can get up behind the era?
CachedefaultExpire 4 # default Cache validity period, unit is hour
ProxyRemote http://something.com http://otherproxy.com:8080/# For access to http://something.com, automatically call the definition in other OtherProxy.com:8080
Web proxy,
# Can also use proxyRemote ftp http://otherproxy.com:8080/
# Define a specialized PROXY cascade of FTP.
NOPROXY .MYDOMain.com 111.111.111.0/24
# For request from 111.111.111.11.1-111.111.111.254 and pointing to * .mydomain.com
Reason,
# This can make Cache only valid for the external network.
Next, you should set only your own internal users to use Proxy, this requires modification / etc / httpd / conf / ACC
Ess.conf
Add the following paragraph:
#Proxy access limit
ORDER ALOW, DENY # Order: Default
Allow 111.111.11.0/24 # Allow 111.111.111.0-111.111.111.254,
# / 24 means that the network mask is 24 1, ie 255.255.255.0
# 段 结
Now, restart httpd, then set your client, set the proxy server to 111.111.111.111:8080
okay.
(3) Virtual host
Apache's name The virtual host is a good feature that can be provided with an Apache machine, one IP to provide multiple
Page, setting is very simple, you need to edit /etc/httpd/conf/httpd.conf, assume two names: A.DO
Main.com and B. Domain.com are all directions 111.111.111.111 (note that two coincidences generated by cname)
Can only be counted, to make a virtual host, you must define two records in the domain name), then you can add it
paragraph:
Listen 111.111.111.111 80
NamevirtualHost 111.111.111.111:80 # Description 111.111.111.111 is a virtual host
# 一一 虚 虚机
Servername a.domain.com # Virtual host name
Documentroot /Home/httpd/html/a.domain.com/ # a.domain.com's homepage file storage address
ErrorLog /var/log/a.log # Error message record
ServerAdmin mastera@domain.com # Administrators' email address (optional)
# 段 结
# 第二 第二 s s b d.com
DocumentRoot /Home/httpd/html/b.domain.com/
Errlog /var/log/b.log
ServerAdmin Masterb@domain.com
After the end is set, the httpd is restarted.
By the way, what if you want to configure the CGI script for each virtual user? Simple, it is related to this
Household
Scriptalias / cgi-bin / /Home/httpd/html/a.domain.com/cgi-bin/
This is automatically turned to /Home/httpd/html/a.d in this way of http://a.domian.com/cgi-bin/.
Omain.com/cgi-bin/
Down. Of course, you can put it in DirectoryIndex, huh, huh.
(4) Other instructions
There is now a program called Commanche, you can manage Apache through the web page, but I still like it.
Directly modify the configuration file, there is a problem better, huh, huh.
Another important question is, if you allow others to use your server to publish web pages, then you must be small
There is a very important paragraph in the heart, /etc/httpd/conf/httpd.conf is User Nobody
Group nobody
It defines whether the system uses Nobody permissions when HTTPD access, which avoids many security issues, absolutely don't put it
Set into root!
(Cited from http://www.foxlog.net/)