Several common application examples and analysis of Apache

Source: Internet
Author: User
Tags access analysis apache application change create default directory

By default, you need to create the directory public_Html in your user's home directory, then put all your web files in this directory, type in http: // servername / ~ username, but please pay attention to the following point:

1. Login as root, modify the user home directory permissions (# chmod 705 / home / username), so that other people have the right to enter the directory browsing.

2. Log in with your own username, create a public_html directory, and ensure that the directory also has the correct permissions for others to enter.

3. Apache default homepage file is index.html, not index.htm, you can change the line in the /etc/mime.types file like below.

text / html html htm

Then Apache will read your index.htm file 4. The user's own directory created in the home directory is best to set the permissions to 0700, to ensure that other people can not access.

B. How to set up virtual hosting?

1. Suppose a server IP 192.168.11.2, to virtual another IP address 192.168.11.4, then add the following line to /etc/rc.d/rc.local

/ sbin / ifconfig eth0: 0 192.168.11.4 / sbin / route add -host 192.168.11.4 eth0: 0

2. Add the following line to /home/httpd/conf/httpd.conf

VirtualHost 192.168.11.4 (this line has <>)

ServerAdmin your_email_address

DocumentRoot / home / httpd / foldername

ServerName virtualservername

ErrorLog /var/log/httpd/foldername/error.log

TransferLog / var / log / httpd / foldername / Access_log / VirtualHost (this line has <>)

3. If you have a DNS server on your LAN, add the corresponding entry 192.168.11.4 ---> virtualservername

C. How to use Apache to a directory password protected?

By default, a file, .htaccess, can be placed in a directory like this:

AuthName stuff

AuthType Basic

AuthUserFile /etc/.userpasswd

require valid-user

To give access to user user1, # htpasswd -c /etc/.userpasswd user1 is assigned a password for user1.

D. How to share a list of browser access? Such as / home / FTP / pub /

1. Add the following line to /home/httpd/conf/srm.confAlias ​​/ pub / home / ftp / pub / 2. Change the default file type, change /home/httpd/conf/srm.conf a line:

DefaultType application / octet-stream 3. Restart Apache. /etc/rc.d/init.d/httpd restar

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.