天天看點

Apache服務

1.使用rpm包安裝apache

  rpm -ivh httpd-version.rpm

  rpm -ivh httpd-manual-version.rpm

  背景程序:http

  啟動腳本: /etc/rc.d/init.d/httpd

  使用端口: 80(http) 443(https)

  網頁位置: /var/www/html

  手冊使用: http://localhost/manual/

  配置路徑: /etc/httpd/

  [root@stu254 httpd]# pwd

  /etc/httpd

  [root@stu254 httpd]# ls

  conf  conf.d  logs  modules  run

  [root@stu254 httpd]#

2.httpd.conf檔案的格式

  ServerRoot "/etc/httpd"

  Listen 80

  Include conf.d/*.conf

  User apache

  Group apache

  ServerName www.example.com:80

  DocumentRoot "/var/www/html"

  DirectoryIndex index.html index.html.var

3.web服務的基本配置方法

  vim /var/www/html/index.html

4.userdir alias子產品的使用

  userdir配置

   httpd.conf

      # UserDir disable

      UserDir public_html

   mkdir /home/seker/public_html

   echo "hello.. seker's web..." > /home/seker/public_html/index.html

   chmod 755 /home/seker

   service httpd restart

   http://localhost/~seker/

  alias配置

   conf.d/down.conf

 alias  /down  /var/ftp/pub

 <directory /var/ftp/pub>

  options indexes

 </directory>

   http://localhost/down

5.  使用者認證

  authtype basic

  authname "seker password"

  AuthBasicProvider file

  AuthUserFile /etc/httpd/passwdb

  Require user seker zorro # 隻允許兩個使用者通路

  # Require valid-user # 允許密碼檔案中的所有使用者通路

   建立密碼檔案和使用者

 htpasswd -c -b /etc/httpd/passwdb zorro 1234

 htpasswd -b /etc/httpd/passwdb seker 1234

6.  通路控制

  order deny,allow

  deny from all

  allow from 10.10.10.32

 # 先去把規則全解釋一遍,之後發現有沖突,那麼使用order表,order表從後向前的順序應用.

7.虛拟主機

  基于名稱的虛拟主機

 需要兩個域名能夠解析到你的伺服器

 [root@stu254 conf]# tail -n 2 /etc/hosts

 10.10.10.31 www.seker.com

 10.10.10.31 web.seker.com

 [root@stu254 conf]#

 # cd /var/www/html/

 # mkdir www web

 # echo "hello..wwww. this is www.seker.com" >> www/index.html

 # echo "hello..webb. this is web.seker.com" >> web/index.html

 修改配置檔案httpd.conf

 NameVirtualHost *:80

 <VirtualHost *:80>

         DocumentRoot /var/www/html/www

         ServerName www.seker.com

 </VirtualHost>

         DocumentRoot /var/www/html/web

         ServerName web.seker.com

    service httpd restart

    http://www.seker.com

 http://web.seker.com

下一篇: Apache名字

繼續閱讀