Linux Redhat 6.5 Apache virtual directory and multi-port multiple host name configuration

Source: Internet
Author: User

Apache is the world's most used Web server software. It can run on almost all widely used computer platforms and is one of the most popular Web server-side software due to its widespread use across platforms and security. It is fast, reliable, and can be augmented with simple APIs to compile perl/python and other interpreters into the server. * * The objective of the experiment is
  1. Implementing a virtual Directory
  2. Implement user login to display different pages
  3. Implementing Domain name Access experiment Preparation Environment Redhat version 6.5

    Install the corresponding RPM package

    • Mounting discs
    • [[email protected] ~]# rpm-ivh/mnt/packages/httpd-2.2.15-29.el6_4.x86_64.rpm provide Web services
    • [[email protected] ~]# rpm-ivh/mnt/packages/bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm domain name resolution
    • In fact, there is no configuration to access the Wed service provided by Redhat only need to open the service can
    • Modifying the httpd configuration file
    • [[email protected] ~]# vim/etc/httpd/conf/httpd.conf front start for serial number can be ignored without looking
    • 135 Listen 192.168.100.101:80 80 port to turn on the listening port for its native IP address
    • 136 Listen 192.168.100.101:8080 Open port access for later preparation
    • 137 #Listen 80 Comment out VLP6 listening port
    • 277 ServerName linuxc1.com:80 Server domain name can be selected to ignore but start the service will be an error, but no impact
    • [[Email protected] ~]# service httpd Restart Open
    • [[Email protected] ~]# service iptables stop shutdown firewall
    • [[email protected] ~]# Setenforce 0 turn off enhanced service capabilities
    • You can also do this without shutting down the firewall operation
    • Iptables-f Clear All chains
    • Vim/etc/sysctl.conf Modifying a configuration file
    • Net.ipv4.ip_forward = 1 Change 0 to 1 This will enable access from the client to the HTTPD service provided by Linux 1
    • [[email protected] ~]# mkdir/opt/test Create virtual directory
    • [[email protected] ~]# echo "This is VDir test" >/opt/test/index.html Create a virtual directory on the first page here ending with HTML if you want to support a file that does not ask for formatting changes in the main configuration file
    • /etc/httpd/conf/httpd.conf
    • 402 DirectoryIndex index.html Index.html.var supported file types
    • [[email protected] ~]# vim/etc/httpd/conf.d/vdir.conf Create virtual Access profile
    • The contents are as follows
    • Alias/test "/opt/test/" # Definition name Test physical path default Home store location
    • <directory "/opt/test/" > # Defining Physical Logic
    • Options Indexes multiviews followsymlinks #默认固定格式 Miniature
    • AllowOverride None #不让他进行重写
    • AuthName "Hello" #表示信息
    • AuthType Basic #基本认证
    • Authuserfile/etc/httpd/user # login account file for authentication
    • Authgroupfile/etc/httpd/group #认证组
    • #require Valid-user #开启用户验证
    • #require User Test #只允许那些用户进行登陆
    • #Require Group Admin #只允许那组登陆
    • </Directory> End
      Now access to the virtual directory is also a subdirectory of the site to access the home directory for easy Management
    • [[Email protected] ~]# service httpd Restart don't forget to reload
-The following is a new page that will be displayed after user access
  • [[email protected] ~]# vim/etc/httpd/conf.d/vdir.conf Create virtual Access profile modify the inside of the Vim editor is displayed in the previous number can be ignored
  • Require Valid-user can choose to turn on or off
  • Htpasswd-c/etc/httpd/user Zhangsan Create user Login
  • Service httpd Restart Reload
  • To access different Web pages based on different host names-
  • Mkdir/opt/benet Creating a site
  • MKDIR/OPT/ACCP Creating a site
  • echo "This is Benet" >/opt/benet/index.html Create Benet's homepage
  • echo "This is ACCP" >/opt/accp/index.html create ACCP's homepage
  • Vim/etc/httpd/conf.d/host.conf write a new host name to access different Web pages
  • The contents are as follows
  • Namevirtualhost 192.168.100.101:80 #制定相对应的IP地址和端口
  • <virtualhost 192.168.100.101:80> #固定格式
  • ServerAdmin [email protected] #建立管 Manager email
  • documentroot/opt/benet/#定义站点目录
  • ServerName www.benet.com #服务器名字
  • Errorlog Logs/benet.com-error_log #错误日志
  • Customlog Logs/benet.com-access_log Common #访问日志
  • </VirtualHost> End
  • <virtualhost 192.168.100.101:80> #固定格式
  • ServerAdmin [email protected] #建立管 Manager email
  • documentroot/opt/benet/#定义站点目录
  • ServerName www.benet.com #服务器名字
  • Errorlog Logs/benet.com-error_log #错误日志
  • Customlog Logs/benet.com-access_log Common #访问日志
  • </VirtualHost> End
  • To modify the DNS resolution master configuration file
  • vim/etc/named.conf Front number for Vim editor serial number
  • Listen-on Port 53 {192.168.100.101;}; Modify the server address for your own IP address
  • allow-query {any;}; The listening port is for all
  • Vim/etc/named.rfc1912.zones Modifying a zone configuration file
  • Add two forward parsing
  • echo "NameServer 192.168.100.101" >/etc/resolv.conf Add DNS Resolution

DNS resolution detailed configuration
-

    • -Different port number access
    • mkdir/opt/benet01 Creating a site
    • echo "This is benet8080" >/opt/benet01/index.html Create Benet01 home page

Linux Redhat 6.5 Apache virtual directory and multi-port multiple host name configuration

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.