菜鸟学Linux 第052篇笔记 httpd-install and section2
菜鳥學Linux 第052篇筆記 ?httpd-install and section2
apache 17years
NCSA, httpd
A Patchey Server = Apache
FSF (GNU, GPL Free Software Foundation)
ASF (Apache Software Foundation)
web: httpd
?tomcat
?Hadoop
www.apache.org
httpd:
Web Server, Open Source
httpd feature
事先創建進程
按需維持適當的進程
模塊化設計,核心比較小,各種功能都可模塊添加(包括php)
支持運行時配置,支持單獨編譯模塊
支持多種方式的虛擬主機配置
Socket IP:Port
虛擬主機:
基于IP的虛擬主機
基于端口的虛擬主機
基于域名的虛擬主機
支持https協議 ?{mod_ssl}
支持用戶認證
支持基于IP或主機的ACL
支持每目錄的訪問控制
支持URL重寫
Redhat install httpd:
rpm包安裝
源碼編譯安裝
httpd受SELinux (由于未學,先讓其處于permissive)
getenforce
setenforce 0
httpd file:
/usr/sbin/httpd (MPM:prefork)
httpd: root, root (master process)
httpd: apache, apache (worker process)
/etc/rc.d/init.d/httpd
port: (80/tcp) (ssl: 443/tcp)
/etc/httpd 工作的根目錄,相當于程序安裝目錄
/etc/httpd/conf 主配置文件目錄
主配置文件: httpd.conf
/etc/httpd/conf.d/*conf
/etc/httpd/modules 模塊路徑
/etc/httpd/logs --> /var/log/httpd 日志目錄
日志文件有兩類 訪問日志access_log 錯誤日志 err_log
/var/www/
html 靜態內容路徑
cgi-bin 動態內容路徑
cgi: Common Gateway Interface
Client --> httpd (index.cgi) --> Spawn process --> httpd --> Client
Perl, python, java(servlet, JSP), PHP
fastcgi 使http server和動態解釋器分開(可以在物理分成兩個服務器)
程序: 指令和數據
數據: 數據庫服務 cpu-bound
LAMP
Linux
apache
MySQL
php
httpd 安裝
yum install httpd
/etc/httpd/conf
httpd.conf
### Section 1: Global Environment
### Section 2: 'Main' server configuration (默認)
### Section 3: Virtual Hosts
(注意第二段和第三段不可同時生效,同一時間只可有一個生效)
directive value
指令不區分字符大小寫
value則根據需要有可能要區分
loadRunner
測試web server (老師說不作講解,自學,)
MPM: Multi-Path Modules
mpm_winnt
prefork (一個請求用一個進程響應)
worker (一個請求用一個線程響應, (啟動多個進程,每個進程生成多個線程))
event (一個進程響應多個請求,生成子進程并且每個子進程生成多個線程) ? ? ?
修改apache processing model (MPM)
/etc/sysconfig/httpd
#HTTPD=/usr/sbin/httpd.event ? 刪除#號,后邊加模塊名字即可(需重啟服務)
apache 2.2 有event為測試版,不建議使用 ?
Options
None: 不支持任何選項
Indexes: 允許索引目錄
FollowSynLinks: 允許訪問符號連接指向的原文件
Section 2: 'Main' server configuration
ServerAdmin root@localhost
ServerName?
DocumentRoot "/var/www/html" ?(最后一個切記不要加斜線)
<Directory "/var/www/html">
Options?
Indexes(索引)?
FollowSymLinks(跟隨符號鏈接)?
None
SymLinksifOwnerMatch
ExecCGI 允許執行CGI腳本
MUltiViews?
All
AllowOverride None
Order 用于定義基于主機的訪問功能,IP,網絡地址或主機定義訪問控制機制
Order Allow,deny
allow from
deny from
e.g.
order deny,allow
deny from 192.168.11.5 192.168.11.3
地址的表示方式
IP
network/netmask
hostname: www.a.com
Domainname: a.com
partial IP: 172.16= 172.16.0.0/16
</Directory>
DirectoryIndex index.html index.html.var?
實現網站進行登錄訪問(不常用,了解即可)
? ? AllowOverride AuthConfig
? ? AuthType Basic
? ? AuthName "Restricted Site..."
? ? AuthUserFile "/etc/httpd/conf/htuser"
? ? AuthGroupFile "/etc/httpd/conf/htgroup"
# ? ?Require user red
? ? Require group myusers
加入以上配置后生成htpasswd文件使用命令,后跟的是用戶名
htpasswd -c -m /etc/httpd/conf/htuser hadoop ?
-c Creat
-m Use MD5
組文件直接編輯即可
vim /etc/httpd/conf/htgroup
格式 Group: user1 user2 ...
myusers: hadoop
是否啟用用戶家目錄建立個人網站頁面(默認關閉)
<IfModule mod_userdir.c> ??
UserDir disable
?? #UserDir public_html
</IfModule>
訪問方式: http://192.168.11.110/~userName
(注意:因為其它用戶對用戶的家目錄沒有訪問權限,如果想要訪問該用戶的網頁
?? 需要在其用戶目錄上o+x權限
???
DirectoryIndex index.html index.html.var 默認打開頁面 ??
???
Alias /icons/ "/var/www/icons/" 別名?
訪問方式 http://www.mysky.com/icons/ 注意別名有斜線,訪問時也要加
???
???
elinks http://172.168.11.1 ?以純文本顯示網頁
-dump? 顯示網頁內容后退出,不產生交互
-source 顯示源碼
PV: Page View
UV: user view
總結
MPM (Multi-path Modules) ?重點
定義網站文檔目錄
訪問選項 Options
基于主機的訪問控制
基于用戶或組的訪問控制
用戶個人站點
錯誤日志
日志格式
訪問日志 PV UV
路徑別名
本文轉自Winthcloud博客51CTO博客,原文鏈接http://blog.51cto.com/winthcloud/1883804如需轉載請自行聯系原作者Winthcloud
總結
以上是生活随笔為你收集整理的菜鸟学Linux 第052篇笔记 httpd-install and section2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VMware vSphere/vCent
- 下一篇: 适用于WinForm的一个定时器类