apache服务器

下载地址:

 

 

# tar zxvf zlib-1.2.3.tar.gz                

# cd zlib-1.2.3                            
# ./configure --prefix=/usr/local/zlib
# make && make install           

# tar zxf httpd-2.2.9.tar.gz -C /usr/src
# cd /usr/src/httpd-2.2.9
# ./configure    --prefix=/usr/local/apache  --enable-so --enable-mods-shared=all --enable-rewrite --enable-ssl --with-

ssl=/usr/lib  --enable-auth-digest --enable-cgi --enable-suexec --with-suexec-caller=daemon --

with-suexec-docroot=/usr/local/apache/htdocs --with-z=/usr/local/zlib

# make && make install
# cd /usr/local/apache/conf
# ls
# cp httpd.conf httpd.conf.bak
# grep -v "#" httpd.conf.bak   | grep -v "^$" > httpd.conf
# cd /usr/local/apache/htdocs
# mkdir benetcom accpcom
# echo "111111111" > benetcom/index.html
# echo "222222222" > accpcom/index.html

1、基于域名:

# vi /usr/local/apache/conf/httpd.conf            (在最后编写)

NameVirtualHost  173.17.17.11

<VirtualHost 173.17.17.11>
        DocumentRoot         /usr/local/apache/htdocs/benetcom
        ServerName          
        ErrorLog             logs/www.benet.com.error.log
        CustomLog            logs/www.benet.com.access.log     common
</VirtualHost>

<VirtualHost 173.17.17.11>

      DocumentRoot    /usr/local/apache/htdocs/accpcom
      ServerName     
      CustomLog       logs/www.accpcom.access.log  common
</VirtualHost>

# /usr/local/apache/bin/apachectl restart
# service iptables stop
# vi /etc/hosts

173.17.17.11     

# vi /etc/resolv.conf

search benet.com   accp.com

nameserver      173.17.17.11

 

 

使用ab命令进行压力测试:

# /usr/local/apache/bin/ab -c 2000 -n 4000 '/1.html'

 

-n 4000表示总请求数为4000

-c 2000表示并发用户数为2000

客户端(windows):

http:\\www.benet.com

C:\windows\system32\drivers\etc\hosts

173.17.17.11   

 

客户端(linux):

# vi /etc/hosts

173.17.17.11     

# service iptables stop

 

2、基于端口:

 

# vi /usr/local/apache/conf/httpd.conf            (在最后编写)

Listen  173.17.17.11:80

Listen  173.17.17.11:8080

<VirtualHost 173.17.17.11:80>

        DocumentRoot         /usr/local/apache/htdocs/benetcom
        ServerName          
        ErrorLog             logs/www.benet.com.error.log
        CustomLog            logs/www.benet.com.access.log     common
</VirtualHost>

<VirtualHost 173.17.17.11:8080>

      DocumentRoot    /usr/local/apache/htdocs/accpcom
      ServerName      logs/www.accpcom.error.log
      CustomLog       logs/www.accpcom.access.log  common
</VirtualHost>

 

3、基于ip:

 

# vi /usr/local/apache/conf/httpd.conf            (在最后编写)

<VirtualHost 192.168.4.11>
        DocumentRoot         /usr/local/apache/htdocs/benetcom
        ServerName          
        ErrorLog             logs/www.benet.com.error.log
        CustomLog            logs/www.benet.com.access.log     common
</VirtualHost>

<VirtualHost 173.17.17.11>

      DocumentRoot    /usr/local/apache/htdocs/accpcom
      ServerName      logs/www.accpcom.error.log
      CustomLog       logs/www.accpcom.access.log  common
</VirtualHost>

:wq 

# vi /usr/local/apache/conf/http.conf

 

DocumentRoot         /usr/local/apache/htdocs

 

 

<Directory "/usr/local/apache/htdocs/accpcom">

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

 

<Directory "/usr/local/apache/htdocs/benetcom">

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

 

:wq