Examples and analysis of several common Apache applications

Source: Internet
Author: User
Article title: Examples and analysis of several common Apache applications. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   A. How do I set A separate homepage for each user?
By default, you need to create the public_html directory in your user's home directory, and put all your webpage files under this directory, and then enter http: // servername /~ But pay attention to the following points:
  
1. log on to the root directory and modify the user's main directory permissions (# chmod 705/home/username) so that others can access the directory.
2. log on with your username and create the public_html directory to ensure that the directory has the correct permissions for others to access.
3. the main page file of apachetings is index.html, not index.htm. you can change the line in the/etc/mime. types file to the following.
Text/html htm
Then, apachewill read your index.htm file. 4. you 'd better set the permission to 0700 for the directory you created in the main directory to ensure that others cannot access the directory.
  
   B. how to set up a VM?
1. if the IP address of a server is 192.168.11.2 and another IP address is 192.168.11.4, 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 row 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 row has <>)
3. if there is a DNS server in your LAN, add the corresponding item 192.168.11.4 ---> virtualservername
  
   C. how to use Apache to protect a directory with a password?
By default, you can place a file. htaccess in a directory, as shown below:
  
AuthName stuff
AuthType Basic
AuthUserFile/etc/. userpasswd
Require valid-user
To access user1, use # htpasswd-c/etc/. userpasswd user1 to assign a password to user1.
  
   D. how to share a directory and access it in a browser? For example,/home/ftp/pub/
1. add the following line to/home/httpd/conf/srm. confAlias/pub/home/ftp/pub/2. change the default file type to/home/httpd/conf/srm. action in conf:
DefaultType application/octet-stream 3. restart Apache./etc/rc. d/init. d/httpd restar
  

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.