Virtual host configuration and rewrite parameter description in Apache _linux

Source: Internet
Author: User
Tags http authentication php server

Virtual Host Configuration process

Here's our path to this example
DocumentRoot:/home/jb51/sites/demo.jb51.net
ServerName:demo.jb51.net

1. Enter Apache virtual host Setup Directory

Cd/etc/apache2/sites-available 

2. Create File Demo.jb51.net

<virtualhost *:80> 
    ServerAdmin webmaster@localhost 
    directoryindex 
    index.html Documentroot/home/jb51/sites/demo.jb51.net 
    ServerName demo.jb51.net 
    serveralias demo.jb51.net 
    < Directory "/home/jb51/sites/demo.jb51.net" > 
        allow from all Options + Indexes 
    </Directory> 
</VirtualHost> 


3. Activate the virtual host configuration

sudo a2ensite demo.jb51.net 


4. Enter the/etc/apache2/sites-enabled/directory to view all active virtual hosts. You can log off with sudo a2dissite demo.jb51.net

cd/etc/apache2/sites-enabled 
Ls-lt 

Show

Copy Code code as follows:

lrwxrwxrwx 1 root 2013-04-05 17:29 demo.jb51.net->. /sites-available/demo.jb51.net


5. Restart Apache Service

Sudo/etc/init.d/apache2 restart 


6.ubuntu Setting Host

 
 


127.0.0.1 demo.jb51.net


7.<directory> settings Open. htaccess and display directory structure list

<directory "/home/jb51/demo.jb51.net" > 
allowoverride none 
allowoverride all 
options-indexes FollowSymLinks 
</Directory> 

AllowOverride none indicates closing. htaccess, if you want to turn on the can set to allowoverride all
Options-indexes indicates that the directory structure is turned off to display if you want to turn on options Indexes
The Options followsymlinks indicates support for symbol link (soft connection), if you want to turn it off to be set to Options-followsymlinks

Rewrite module Important parameter description

Open rewrite:

sudo a2enmod rewrite 

Deactivate rewrite:

sudo a2dismod rewrite 

Server environment variables: Apache provides rewirte modules with an environment variable that is probably divided into 5 types.

Part I: HTTP headers partial parameters

1. Parameter name: http_user_agent
Sample reference value: mozilla/5.0 (Windows; U Windows NT 5.1; ZH-CN; rv:1.9.0.8) gecko/2009032609 firefox/3.0.8
Description: Equivalent to PHP server parameters: $_server["Http_user_agent"]

2. Parameter name: Http_referer
Sample reference value: http://www.test.cn/test.php
Description: Equivalent to PHP server parameters: _server["Http_referer"]

3. Parameter name: Http_cookie
Sample reference value: ZDEDEBUGGERPRESENT=PHP,PHTML,PHP3
Description: Equivalent to PHP server parameters: $_server["Http_cookie"]

4. Parameter name: http_forwarded
Sample reference value: If the use of Proxy server will be the IP address of the proxy server, local environment is not easy to test the value.
Description: Equivalent to PHP server parameters: $_server["http_forwarded"]

5. Parameter name: Http_host
Sample reference value: www.test.com
Description: Equivalent to PHP server parameters: $_server["Http_host"]

6. Parameter name: http_proxy_connection
Sample reference value: Information about the network connection agent. The same as the http_forwarded parameter. It is not easy to test the value of the environment locally.
Description: PHP does not seem to provide such a server information value. If again, it may be equivalent to: $_server["Http_proxy_connection"]

7. Parameter name: http_accept
Sample reference value: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Description: Equivalent to PHP server parameters: $_server["Http_accept"]

Part II: Server Internals Partial parameters

1. Parameter name: Document_root
Sample reference value: c:/webroot/t
Description: Equivalent to PHP server parameters: $_server["Document_root"]

2. Parameter name: server_admin
Sample reference value: youemailaddress@gmail.com
Description: Equivalent to PHP server parameters: $_server["Server_admin"]

3. Parameter name: server_name
Sample reference value: www.test.com
Description: Equivalent to PHP server parameters: $_server["SERVER_NAME"]

4. Parameter name: SERVER_ADDR
Sample reference value: 127.0.0.1
Description: Equivalent to PHP server parameters: $_server["SERVER_ADDR"]

5. Parameter name: Server_port
Sample reference value: 80
Description: Equivalent to PHP server parameters: $_server["Server_port"]

6. Parameter name: Server_protocol
Sample reference value: http/1.1
Description: Equivalent to PHP server parameters: $_server["Server_protocol"]

7. Parameter name: Server_software
Sample reference value: apache/2.2.11 (WIN32) php/5.2.9-1
Description: Equivalent to PHP server parameters: $_server["Server_software"]

Part III: Connection & Request Parameters

1. Parameter name: REMOTE_ADDR
Sample reference value: 127.0.0.1 is browsing the IP address of the user of the current page.
Description: Equivalent to PHP server parameters: $_server["REMOTE_ADDR"]

2. Parameter name: Remote_host
Sample reference value: 127.0.0.1 is browsing the user's host name for the current page. Reverse domain name resolution based on the user's remote_addr
Description: Equivalent to PHP server parameters: $_server["Remote_host"]

3. Parameter name: Remote_port
Sample reference value: 2574 (varying value) the port used by the user to connect to the server
Description: Equivalent to PHP server parameters: $_server["Remote_port"]

4. Parameter name: Remote_user
Sample reference value: null
Description: PHP does not seem to provide relevant $_server values.

5. Parameter name: remote_ident
Sample reference value: null
Description: PHP does not seem to provide relevant $_server values.

6. Parameter name: Request_method
Sample reference value: Get
Description: Equivalent to PHP server parameters: $_server["Request_method"]

7. Parameter name: Script_filename
Sample reference value: c:/webroot/t/share77.html
Description: Equivalent to PHP server parameters: $_server["Script_filename"]

8. Parameter name: Path_info
Sample reference value: null
Description: Equivalent to PHP server parameters: $_request["Path_info"]

9. Parameter name: query_string
Sample reference value: A=b&c=d&e=f
Description: Equivalent to PHP server parameters: $_server["Query_string"]

10. Parameter name: Auth_type
Sample reference value: Empty PHP runs in the Apache module mode, and is using the HTTP authentication function, this is the authentication type
Description: Equivalent to PHP server parameters: $_server["Auth_type"]

Part IV: Date and time partial parameters

1. Parameter name: time_year
Sample reference Value: 2009
Description: The server gets the current year value

2. Parameter name: Time_mon
Sample reference value: 04
Description: The server gets the current month value

3. Parameter name: Time_day
Sample reference value: 22
Description: The server gets the current day value

4. Parameter name: Time_hour
Sample reference value: 16
Description: The hour the server gets the current time

5. Parameter name: time_min
Sample reference value: 26
Description: The minute the server gets the current time

6. Parameter name: time_sec
Sample reference value: 34
Description: Seconds the server gets the current time

7. Parameter name: Time_wday
Sample Reference value: 3
Description: The server gets the day of the week, from Sunday-Saturday, the number from 0-6

8. Parameter name: Time
Sample reference value: 20090422162634
Description: The server obtains the current time, the format is: The month and the day time

Part V: Specials Partial parameters

1. Parameter name: api_version
Sample reference value: 20,051,115:21
Description: Apache API version information.

2. Parameter name: the_request
Sample reference value: Get/share77.html http/1.1
Description: The request value that the browser sends to the server. Does not include other header information.

3. Parameter name: Request_uri
Sample reference value:/share77.html
Description: The resource information requested by the browser.

4. Parameter name: Request_filename
Sample reference value: c:/webroot/t/share77.html
Description: The physical address of the requested resource on the disk.

5. Parameter name: Is_subreq
Sample reference value: False
Description: Displays True if it is sub-request, or false.

6. Parameter name: HTTPS
Sample reference value: Off
Note: If the connection uses SSL/TLS mode, the value is on, otherwise the value is off, and this parameter is safe even if the Mod_ssl module is not loaded.

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.