LINUX下的APACHE的配置
生活随笔
收集整理的這篇文章主要介紹了
LINUX下的APACHE的配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天寫一下LINUX下的APACHE的配置方法。
APACHE是作為WEB服務器的。它的優點在于用緩存方式來加快網頁的搜索速度。
APACHE缺省只支持靜態網頁
LINUX下有APACHE的RPM包
安裝上第一張盤里的httpd-2.0.40-21.i386.rpm 包
1 /etc/httpd/conf.d 放在這里的都是動態網頁的配置文件
2 /etc/httpd/conf/httpd.conf 主配置文件
3 /var/log/httpd?? 日志文件目錄。
4 /var/www/html 網頁的存放目錄
5 /etc/rc.d/init.d 工具文件目錄。
6 vi /etc/httpd/conf/httpd.conf
?
? Section 1: Global Environment(全局設置)
?
?ServerRoot "/etc/httpd" (APACHE安裝路徑)
?DirectoryIndex index.html index.html.var (網頁首頁的第一頁)
?Timeout 300 (超出時間)
?KeepAlive Off(保持Httpd激活)
?MaxKeepAliveRequests 100 (保持的連接的人數,改成0就是說沒有人數的限制)
?KeepAliveTimeout 15 (保持激活的超出時間)
?prefork MPM (預派生模式)
?worker MPM (工作者模式)
?Listen 80 (偵聽的端口)
?LoadModule (加載模塊) Section 2: 'Main' server configuration(服務器配置)
? User apache Group apache (由誰啟動APACHE服務器)
? ServerAdmin root@localhost (網頁出錯給誰發信通知)
? ServerName new.host.name:80(設置網站的域名)
? DocumentRoot "/var/www/html"(網頁存放的路徑)
? <Directory /> (目錄容器)
? Options (選項) FollowSymLinks(允許符號連接,允許這個網頁以外的地方)
? AccessFileName .htaccess(訪問文件定義名稱文件容器)
? <Files ~ "^\.ht"> 想把所有以 .ht 開頭的文件做限制
??? Order allow,deny 定義訪問順序 先允許,后拒絕
??? Deny from all? 拒絕所有人
</Files> Section 3: Virtual Hosts (虛擬主機)
??
? NameVirtualHost * (虛擬主機工作的IP)
? ServerAdmin [email]webmaster@dummy-host.example.com[/email] (虛擬主機的管理員的郵件地址)
? DocumentRoot /www/docs/dummy-host.example.com (網頁放在那)
? ServerName dummy-host.example.com (主機名是什么)
? ErrorLog logs/dummy-host.example.com-error_log(錯誤日記路徑)
? CustomLog logs/dummy-host.example.com-access_log common(訪問日志路徑)? 1 基于IP的虛擬主機
? 1 NameVirtualHost * 放開
? 2 <VirtualHost 192.168.0.12:80>
??? ServerAdmin [email]webmaster@yirehe.com[/email]
??? DocumentRoot /web1
??? ServerName [url]www.yirehe.com[/url]
??? ErrorLog logs/www.yirehe.com-error_log
??? CustomLog logs/www.yirehe.com-access_log common
?? </VirtualHost>
? 3 <VirtualHost 192.168.0.13:80>
??? ServerAdmin [email]webmaster@zuanmou.com[/email]
??? DocumentRoot /web2
??? ServerName [url]www.zuanmou.com[/url]
??? ErrorLog logs/www.zuanmou.com-error_log
??? CustomLog logs/www.zuanmou.com-access_log common
??? </VirtualHost>
2 基于端口的虛擬主機
? 1 NameVirtualHost 192.168.0.12 放開
? 2 <VirtualHost 192.168.0.12:8080>
??? ServerAdmin [email]webmaster@yirehe.com[/email]
??? DocumentRoot /web1
??? ServerName [url]www.yirehe.com[/url]
??? ErrorLog logs/www.yirehe.com-error_log
??? CustomLog logs/www.yirehe.com-access_log common
??? </VirtualHost>
? 3 <VirtualHost 192.168.0.12:80>
??? ServerAdmin [email]webmaster@zuanmou.com[/email]
??? DocumentRoot /web2
??? ServerName [url]www.zuanmou.com[/url]
??? ErrorLog logs/www.zuanmou.com-error_log
??? CustomLog logs/www.zuanmou.com-access_log common
??? </VirtualHost>
3 基于主機頭的虛擬主機
?
? 1 NameVirtualHost 192.168.0.12:80 放開
? 2 <VirtualHost 192.168.0.12:80>
??? ServerAdmin [email]webmaster@yirehe.com[/email]
??? DocumentRoot /web1
??? ServerName [url]www.yirehe.com[/url]
??? ErrorLog logs/www.yirehe.com-error_log
??? CustomLog logs/www.yirehe.com-access_log common
??? </VirtualHost>
? 3 <VirtualHost 192.168.0.12:80>
??? ServerAdmin [email]webmaster@zuanmou.com[/email]
??? DocumentRoot /web2
??? ServerName [url]www.zuanmou.com[/url]
??? ErrorLog logs/www.zuanmou.com-error_log
??? CustomLog logs/www.zuanmou.com-access_log common
??? </VirtualHost> 4 做虛擬目錄的認證 1找到 /Alias? 2 Alias /xinwe/ "/usr/web1" <Directory "/usr/web1">
??? Options Indexes MultiViews
??? AllowOverride None
??? Order allow,deny
??? Allow from all
??? AuthName "huiyuan"
??? AuthType Basic
??? AuthUserFile /etc/pass
??? require valid-user tom1 tom2
</Directory> 3 htpasswd -c /etc/pass tom1
4 htpasswd -c /etc/pass tom2
5 chown apache.apache /etc/pass
6 service httpd reload 另一種方式也可以實現做虛擬目錄的認證 1 找到 /Alias
2 Alias /xinwe/ "/usr/web1"
? <Directory "/usr/web1">
????? AllowOverride AuthConfig
? </Directory>
3 然后在/usr/web1文件夾下touch .htaccess 文本文件
4 vi /usr/web1/.htaccess 在里面寫入
??? Options Indexes MultiViews
??? Order allow,deny
??? Allow from all
??? AuthName "huiyuan"
??? AuthType Basic
??? AuthUserFile /etc/pass
??? require valid-user tom1 tom2
5 chown apache.apache /etc/pass
? htpasswd -c /etc/pass tom1
? htpasswd -c /etc/pass tom2
? service httpd reload APACHE有代理局域網上網的功能 把前面的#去掉
#<IfModule mod_proxy.c>
#ProxyRequests On? (當等于ON的時候說明打開代理)
#<Proxy *>
#??? Order deny,allow (把它改成Order allow,deny,)
#??? Deny from all? (把它改成Allow from all)
#??? Allow from .your-domain.com? (局域網網段比如:Allow from 192.168.0.0/24)
#</Proxy> #ProxyVia On (讓代理支持http) #CacheRoot "/etc/httpd/proxy" (緩存的路徑)
#CacheSize 5 (緩存的大小)
#CacheGcInterval 4
#CacheMaxExpire 24 (緩存最大的過期時間)
#CacheLastModifiedFactor 0.1
#CacheDefaultExpire 1 (最短的過期時間)
#NoCache a-domain.com another-domain.edu joes.garage-sale.com (不緩存那些域名)
?
客戶端改IE 依次 工具--Internet選項--連接--局域網設置--勾上為LAN使用使用代理服務器--填寫APACHE主機的
IP地址比如:192.168.0.20 端口:80 到這里APACHE的配置講完了. 希望看完我的配置你可以配置網站的服務器! LINUX 職場 APACHE 系統知識
APACHE是作為WEB服務器的。它的優點在于用緩存方式來加快網頁的搜索速度。
APACHE缺省只支持靜態網頁
LINUX下有APACHE的RPM包
安裝上第一張盤里的httpd-2.0.40-21.i386.rpm 包
1 /etc/httpd/conf.d 放在這里的都是動態網頁的配置文件
2 /etc/httpd/conf/httpd.conf 主配置文件
3 /var/log/httpd?? 日志文件目錄。
4 /var/www/html 網頁的存放目錄
5 /etc/rc.d/init.d 工具文件目錄。
6 vi /etc/httpd/conf/httpd.conf
?
? Section 1: Global Environment(全局設置)
?
?ServerRoot "/etc/httpd" (APACHE安裝路徑)
?DirectoryIndex index.html index.html.var (網頁首頁的第一頁)
?Timeout 300 (超出時間)
?KeepAlive Off(保持Httpd激活)
?MaxKeepAliveRequests 100 (保持的連接的人數,改成0就是說沒有人數的限制)
?KeepAliveTimeout 15 (保持激活的超出時間)
?prefork MPM (預派生模式)
?worker MPM (工作者模式)
?Listen 80 (偵聽的端口)
?LoadModule (加載模塊) Section 2: 'Main' server configuration(服務器配置)
? User apache Group apache (由誰啟動APACHE服務器)
? ServerAdmin root@localhost (網頁出錯給誰發信通知)
? ServerName new.host.name:80(設置網站的域名)
? DocumentRoot "/var/www/html"(網頁存放的路徑)
? <Directory /> (目錄容器)
? Options (選項) FollowSymLinks(允許符號連接,允許這個網頁以外的地方)
? AccessFileName .htaccess(訪問文件定義名稱文件容器)
? <Files ~ "^\.ht"> 想把所有以 .ht 開頭的文件做限制
??? Order allow,deny 定義訪問順序 先允許,后拒絕
??? Deny from all? 拒絕所有人
</Files> Section 3: Virtual Hosts (虛擬主機)
??
? NameVirtualHost * (虛擬主機工作的IP)
? ServerAdmin [email]webmaster@dummy-host.example.com[/email] (虛擬主機的管理員的郵件地址)
? DocumentRoot /www/docs/dummy-host.example.com (網頁放在那)
? ServerName dummy-host.example.com (主機名是什么)
? ErrorLog logs/dummy-host.example.com-error_log(錯誤日記路徑)
? CustomLog logs/dummy-host.example.com-access_log common(訪問日志路徑)? 1 基于IP的虛擬主機
? 1 NameVirtualHost * 放開
? 2 <VirtualHost 192.168.0.12:80>
??? ServerAdmin [email]webmaster@yirehe.com[/email]
??? DocumentRoot /web1
??? ServerName [url]www.yirehe.com[/url]
??? ErrorLog logs/www.yirehe.com-error_log
??? CustomLog logs/www.yirehe.com-access_log common
?? </VirtualHost>
? 3 <VirtualHost 192.168.0.13:80>
??? ServerAdmin [email]webmaster@zuanmou.com[/email]
??? DocumentRoot /web2
??? ServerName [url]www.zuanmou.com[/url]
??? ErrorLog logs/www.zuanmou.com-error_log
??? CustomLog logs/www.zuanmou.com-access_log common
??? </VirtualHost>
2 基于端口的虛擬主機
? 1 NameVirtualHost 192.168.0.12 放開
? 2 <VirtualHost 192.168.0.12:8080>
??? ServerAdmin [email]webmaster@yirehe.com[/email]
??? DocumentRoot /web1
??? ServerName [url]www.yirehe.com[/url]
??? ErrorLog logs/www.yirehe.com-error_log
??? CustomLog logs/www.yirehe.com-access_log common
??? </VirtualHost>
? 3 <VirtualHost 192.168.0.12:80>
??? ServerAdmin [email]webmaster@zuanmou.com[/email]
??? DocumentRoot /web2
??? ServerName [url]www.zuanmou.com[/url]
??? ErrorLog logs/www.zuanmou.com-error_log
??? CustomLog logs/www.zuanmou.com-access_log common
??? </VirtualHost>
3 基于主機頭的虛擬主機
?
? 1 NameVirtualHost 192.168.0.12:80 放開
? 2 <VirtualHost 192.168.0.12:80>
??? ServerAdmin [email]webmaster@yirehe.com[/email]
??? DocumentRoot /web1
??? ServerName [url]www.yirehe.com[/url]
??? ErrorLog logs/www.yirehe.com-error_log
??? CustomLog logs/www.yirehe.com-access_log common
??? </VirtualHost>
? 3 <VirtualHost 192.168.0.12:80>
??? ServerAdmin [email]webmaster@zuanmou.com[/email]
??? DocumentRoot /web2
??? ServerName [url]www.zuanmou.com[/url]
??? ErrorLog logs/www.zuanmou.com-error_log
??? CustomLog logs/www.zuanmou.com-access_log common
??? </VirtualHost> 4 做虛擬目錄的認證 1找到 /Alias? 2 Alias /xinwe/ "/usr/web1" <Directory "/usr/web1">
??? Options Indexes MultiViews
??? AllowOverride None
??? Order allow,deny
??? Allow from all
??? AuthName "huiyuan"
??? AuthType Basic
??? AuthUserFile /etc/pass
??? require valid-user tom1 tom2
</Directory> 3 htpasswd -c /etc/pass tom1
4 htpasswd -c /etc/pass tom2
5 chown apache.apache /etc/pass
6 service httpd reload 另一種方式也可以實現做虛擬目錄的認證 1 找到 /Alias
2 Alias /xinwe/ "/usr/web1"
? <Directory "/usr/web1">
????? AllowOverride AuthConfig
? </Directory>
3 然后在/usr/web1文件夾下touch .htaccess 文本文件
4 vi /usr/web1/.htaccess 在里面寫入
??? Options Indexes MultiViews
??? Order allow,deny
??? Allow from all
??? AuthName "huiyuan"
??? AuthType Basic
??? AuthUserFile /etc/pass
??? require valid-user tom1 tom2
5 chown apache.apache /etc/pass
? htpasswd -c /etc/pass tom1
? htpasswd -c /etc/pass tom2
? service httpd reload APACHE有代理局域網上網的功能 把前面的#去掉
#<IfModule mod_proxy.c>
#ProxyRequests On? (當等于ON的時候說明打開代理)
#<Proxy *>
#??? Order deny,allow (把它改成Order allow,deny,)
#??? Deny from all? (把它改成Allow from all)
#??? Allow from .your-domain.com? (局域網網段比如:Allow from 192.168.0.0/24)
#</Proxy> #ProxyVia On (讓代理支持http) #CacheRoot "/etc/httpd/proxy" (緩存的路徑)
#CacheSize 5 (緩存的大小)
#CacheGcInterval 4
#CacheMaxExpire 24 (緩存最大的過期時間)
#CacheLastModifiedFactor 0.1
#CacheDefaultExpire 1 (最短的過期時間)
#NoCache a-domain.com another-domain.edu joes.garage-sale.com (不緩存那些域名)
?
客戶端改IE 依次 工具--Internet選項--連接--局域網設置--勾上為LAN使用使用代理服務器--填寫APACHE主機的
IP地址比如:192.168.0.20 端口:80 到這里APACHE的配置講完了. 希望看完我的配置你可以配置網站的服務器! LINUX 職場 APACHE 系統知識
0
微博 QQ 微信收藏
上一篇:linux中建立網站服務器詳解 下一篇:Linux快速構建apache ... lanyue2492篇文章,22W+人氣,0粉絲
Ctrl+Enter?發布
發布
取消
1條評論
按時間倒序 按時間正序推薦專欄更多
VMware vSAN中小企業應用案例掌握VMware超融合技術
共41章?|?王春海
¥51.00 346人訂閱
訂???閱 基于Kubernetes企業級容器云平臺落地與實踐容器私有云平臺實踐之路
共15章?|?李振良OK
¥51.00 596人訂閱
訂???閱 網工2.0晉級攻略 ——零基礎入門Python/Ansible網絡工程師2.0進階指南
共30章?|?姜汁啤酒
¥51.00 1566人訂閱
訂???閱 負載均衡高手煉成記高并發架構之路
共15章?|?sery
¥51.00 507人訂閱
訂???閱 帶你玩轉高可用前百度高級工程師的架構高可用實戰
共15章?|?曹林華
¥51.00 462人訂閱
訂???閱猜你喜歡
我的友情鏈接 Cisco路由配置語句匯總 使用iLO遠程管理HP系列服務器 搭建ELK日志分析平臺(下)—— 搭建kibana和logstash服務器 CentOS6.4+LAMP+Postfix+Dovecot+Postfixadmin+Roundcubemail 打造企業級郵件服務器 (1) 用Windows Storage Server 2008做iSCSI存儲服務器 服務器排障 之 nginx 499 錯誤的解決 apache做反向代理服務器 體驗vSphere 6之3-使用vSphere Web Client Windows Server 2012圖形用戶界面(GUI)和服務器核心(Server Core)之間的切換 Linux運維高級篇—CentOS 7下Postfix郵件服務器搭建 最新免費HTTP代理服務器地址 簡述centOS 7系統用戶和組的管理及配置 解析DELL R710服務器遷移操作內容 開學季出大事:某教育局丟失3臺虛擬機 EVA4400存儲虛擬機+數據庫數據恢復成功案例 服務器數據恢復通用方法+服務器分區丟失恢復案例 在CentOS7上部署squid緩存服務器及代理功能 EMC 5400服務器raid陣列癱瘓數據恢復成功案例 服務器數據恢復案例 / raid5陣列多塊硬盤離線處理方法掃一掃,領取大禮包
1
1 分享 lanyue24轉載于:https://blog.51cto.com/lanyue24/30993
總結
以上是生活随笔為你收集整理的LINUX下的APACHE的配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 安装win32com_py
- 下一篇: Mobiscroll的介绍【一款兼容PC