Apache sets user authentication and configures various virtual hosts

Source: Internet
Author: User
Tags nameserver nslookup

Sometimes in order to improve the security of the website background, in addition to the password verification in the background, you can also set password authentication for the website background directory on Apache. Sometimes we need to run multiple websites on one server. For example, to avoid wasting server resources, we can set up Apache Virtual Hosts to meet project requirements, there are three types of virtual hosts (Domain Name virtual hosts, IP virtual hosts, and port virtual hosts );

First install Apache

Tar zxf http-2.2.17.tar.gz

CD http-2.2.17

./Configure -- prefix =/usr/local/httpd -- enable-so -- enable-Rewrite

-- Enable-charset-lite -- enable-CGI


Make & make install


/Usr/local/httpd/bin/apachectl start


Generate an encrypted HTTP account password file:

/Usr/bin/htpasswd-C/usr/local/httpd/CONF/. awspwd Webadmin


Configure the Apache main configuration file:

<Directory "/usr/local/httpd/htdocs">

Options indexes followsymlinks

Authname "AWStats directory"

Authtype basic

Authuserfile/usr/local/httpd/CONF/. awspwd

Require valid-user

AllowOverride none

Order allow, deny

Allow from all


</Directory>


Restart the service and verify the validity of the service through a browser.

/Usr/local/httpd/bin/apachectl restart

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/3B/wKiom1QRQlmg-b_HAAFHoaYJAN0675.jpg "Title =" verify.jpg "alt =" wKiom1QRQlmg-b_HAAFHoaYJAN0675.jpg "/>


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/3B/wKiom1QRQsrxZFDEAADWWMNxXUk451.jpg "Title =" itwork.jpg "alt =" wkiom1qrqsrxzfdeaadwwmnxxuk451.jpg "/>


Domain name-based VM


Ifconfig eth0 limit 20.1/16

Ifconfig eth0: 0 too many requests 3/16

Ifconfig eth0: 1 too many bytes 4/16



Mkdir/usr/local/httpd/htdocs/web1

Mkdir/usr/local/httpd/htdocs/web2

Echo '

Echo '


Domain name-based virtual hosts require domain name resolution. Install the bind service on the system disc for help parsing:

Mkdir/Media/CDROM

Mount/dev/CDROM/Media/CDROM

Rpm-uvh/Media/CDROM/Server/bind-9.3.3-7.el5.i386.rpm

Rpm-uvh/Media/CDROM/Server/caching-nameserver-9.3.3-7.el5.i386.rpm

Rpm-uvh/Media/CDROM/Server/bind-chroot-9.3.3-7.el5.i386.rpm

CD/var/named/chroot/etc/

CP-P named. caching-nameserver.conf named. conf



Vim named. conf

Options {

Directory "/var/named ";

};

Zone "jiajia.com" in {

Type master;

File "dragon.com. Zone ";

};




CD/var/named/chroot/var/named

CP-P localhost. Zone dragon.com. Zone




Vim jiajia.com. Zone

$ TTL 86400

@ In SOA dargon.com. admin.dragon.com .(

42; Serial (D. Adams)

3 h; refresh

15 m; retry

1 W; expiry

1D); Minimum


In NS web1.dragon.com

Web1 in a memory limit 20.1

Web2 in a too many threads 3



Service named restart

Echo 'nameserver failed 20.1 '>/etc/resolv. conf


NSLookup web1.dragon.com

NSLookup web2.dragon.com


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/3D/wKioL1QRQseCugThAACDl6kmQ1I142.jpg "Title =" nslookup.jpg "alt =" wkiol1qrqsecugthaacdl6kmq1i142.jpg "/>



Write the configuration file to httpd. conf.

Echo"

Namevirtualhost 255.255.20.1

<Virtualhost route 20.1>

DocumentRoot/usr/local/httpd/htdocs/web1

Servername web1.dragon.com

</Virtualhost>

<Virtualhost strongswan 3>

DocumentRoot/usr/local/httpd/htdocs/web2

Servername web2.dragon.com

</Virtualhost>

">>>/Usr/local/httpd/CONF/httpd. conf


/Usr/local/httpd/bin/apachectl restart


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/49/3D/wKioL1QRQonxvYDhAAFp150QPQE089.jpg "Title =" domain.jpg "alt =" wkiol1qrqonxvydhaafp150qpqe089.jpg "/>





IP address-based VM:

Echo"

<Virtualhost route 20.1>

DocumentRoot/usr/local/httpd/htdocs/web1

Servername web1.dragon.com

</Virtualhost>

<Virtualhost strongswan 3>

DocumentRoot/usr/local/httpd/htdocs/web2

Servername web2.dragon.com

</Virtualhost>

">>>/Usr/local/httpd/CONF/httpd. conf

/Usr/local/httpd/bin/apachectl restart




650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/49/3B/wKiom1QRQo3wBgrYAAGeaRbWEd8838.jpg "Title =" ip.jpg "alt =" wkiom1qrqo3wbgryaagearbwed8838.jpg "/>




Port-based VM


Echo"

Listen limit 20.1: 81

Listen limit 20.1: 82

<Virtualhost 255.255.20.1: 81>

DocumentRoot/usr/local/httpd/htdocs/web1

Servername web1.dragon.com

</Virtualhost>

<Virtualhost route 000020.1: 82>

DocumentRoot/usr/local/httpd/htdocs/web2

Servername web2.dragon.com

</Virtualhost>

">>>/Usr/local/httpd/CONF/httpd. conf


/Usr/local/httpd/bin/apachectl restart



650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/49/3B/wKiom1QRQp6jwr8EAAF7s6oarvk287.jpg "Title =" port.jpg "alt =" wkiom1qrqp6jwr8eaaf7s6oarvk287.jpg "/>


This article from the "Dragon love Xueqi" blog, please be sure to keep this source http://dragon123.blog.51cto.com/9152073/1551156

Apache sets user authentication and configures various virtual hosts

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.