Apache Configuration file httpd.conf description
- DocumentRoot "/var/www/html"---Apache default server home directory path
- DirectoryIndex index.html index.htm index.php index.html.var---Default document, separated by spaces between multiple files
- Listen 192.168.1.1:80 Setting the listening IP is 192.168.1.1 address and port is 80
- Listen 192.168.1.2:8080 Setting the listening IP is 192.168.1.2 address and port is 8080
- ServerRoot "/ETC/HTTPD" sets the path relative to the root directory, usually where the configuration and log files are stored. The default is:/ETC/HTTPD typically includes conf and logs subdirectories
- Errorlog Logs/error_log Setting Error log Note: If the log file storage path does not start with "/", it means that the file is relative to the ServerRoot directory
- Customlog Logs/access_log Combined Access log (combined indicates the format used by the log and common format)
- ServerAdmin [email protected] Set up the network administrator's email-when the client server error occurs, the server will usually return to the client Error prompt page, in order to facilitate the resolution of the error, this page usually has an administrator's email address, you can use the Se Rveradmin statement to set the administrator's email address
- ServerName www.iigoogle.com:80 Set the server host name (if there is a domain name can be filled in the domain name, no domain name can be filled in the server IP address)
- Adddefaultcharset GB2312 Sets the default character set and defines the default character set that the server returns to the client (since Western Europe UTF-8 is the Apache default character set, so garbled when accessing a Chinese-language Web page, if you change the character set to GB2312 and then restart the AP Ache service)
- Alias/down "/software/download" creates a virtual directory (creates a virtual directory named down, which corresponds to a physical path of:/software/download)
- Alias/ftp "/var/ftp" to create the virtual directory (create a virtual directory named FTP, which corresponds to the physical path is:/var/ftp)
- <directory "/var/www/html" > Set directory Permissions (<directory "directory path" > This write statement to set directory permissions </Directory>)
- Options FollowSymLinks page:116
- AllowOverride None
- </Directory>
Domain-based virtual host
- Namevirtualhost 220.123.55.99---First specify which IP address is responsible for responding to requests to the virtual host with the Namevirtualhost directive
- <virtualhost www.iigoogle.com>
- ServerName www.iigoogle.com:80
- ServerAdmin [email protected]
- Documentroot/www/docs/iigoogle
- DirectoryIndex index.jsp
- Errorlog Logs/www/iigoogle/error_log
- Customlog Logs/www/iigoogle/access_log Common
- </VirtualHost>
Another way of writing
- Namevirtualhost 220.123.55.99:80
- <virtualhost www.iigoogle.com:80>
- ServerName www.iigoogle.com
- ServerAdmin [email protected]
- Documentroot/www/docs/iigoogle.com
- Errorlog Logs/www/iigoogle/error_log
- Customlog Logs/www/iigoogle/access_log Common
- </VirtualHost>
What is virtual Hosting (web hosting)?
Simply put, the same server can handle more than one domain name at a time. Assuming that both www.example1.net and www.example2.net have two domain names pointing to the same server, and the Web server supports virtual Hosting, Then www.example1.net and www.example2.net can access different web spaces on the same server (the site file directory).
Configuration format
In Apache2, valid site information is stored in the/etc/apache2/sites-available/user name (file). We can add the format of the following information to increase a valid virtual space, copy most of the contents of the default is OK, remember to change documentroot as the default directory, set the path in directory, note that the port number should not be duplicated with other virtual hosts:
- <virtualhost * Custom Ports >
- # Add your website name after servername
- ServerName Www.jianzhan.love
- # If you want multiple site names to get the same site, you can add additional site aliases after Serveralias.
- # aliases are separated by a space.
- Serveralias ftp.linyupark.com mail.linyupark.com
- # after the serveradmin with the webmaster's e-mail address, convenient for others to have a problem is to contact the webmaster.
- ServerAdmin [email protected]
- # after DocumentRoot, add the directory path (user's personal directory) to store the contents of the website.
- Documentroot/home/linyupark/public_html
- <Directory/home/linyupark/public_html>
- Options Indexes followsymlinks MultiViews
- AllowOverride None
- Order Allow,deny
- Allow from all
- </Directory>
- scriptalias/cgi-bin//usr/lib/cgi-bin/
- <directory "/usr/lib/cgi-bin" >
- AllowOverride None
- Options execcgi-multiviews +symlinksifownermatch
- Allow from all
- </Directory>
- Errorlog/home/linyupark/public_html/error.log
- # Possible values Include:debug, info, notice, warn, error, crit,
- # Alert, Emerg.
- LogLevel warn
- Customlog/home/linyupark/public_html/access.log combined
- Serversignature on
- </VirtualHost>
If your server has more than one IP, and the different IP has the same virtual user, can be modified to:
- <virtualhost IP Address [: Port]>
- ...
- </VirtualHost>
Enable configuration
The previously configured content is only "effective" virtual host, the actual effect of the words must be placed under the/etc/apache2/sites-enabled folder. We can use the LN command to create a pair of associated files:
sudo ln-s/etc/apache2/sites-available/linyupark/etc/apache2/sites-enabled/linyupark
Check syntax, restart Web service
As a precaution, we check the syntax before restarting the service:
sudo apache2ctl configtest
If there are no errors, then restart Apache.
Sudo/etc/init.d/apache2-k restart
Or
sudo service apache2 restart
View Effects
The main setup work has been completed, it is simple ^_^. How do you see the effect?
Also simple, as long as the host (I use XP) in the table of the host to change the line. The address is:
Windows/system32/drivers/etc
Open and add a sentence:
192.168.1.22 Www.jianzhan.love
The effect is that the browser input www.jianzhan.love will go directly to the IP 192.168.1.22 server to receive the request, see if there is a compatible virtual host domain name, some words to the corresponding directory of the Web file to the requesting user
Errors that may occur
Could not reliably determine the server ' s fully qualified domain name
Modify/etc/apache2/httpd.conf This file is empty, add
ServerName localhost
Can.
Reprint: http://www.knowsky.com/888386.html
Ubuntu under Installation configuration apache2 (with virtual host configuration) 2