當前位置:首頁 » 雲伺服器 » centos搭建http伺服器搭建

centos搭建http伺服器搭建

發布時間: 2022-01-08 04:25:54

① 如何自己搭建centos伺服器

舉個例子:Apache web服務是否安裝的幾個檢查命令 ps aux |grep http netstat -an|grep :80 rpm -qa |grep http

② 如何在CentOS6上搭建一個簡單的HTTP服務

直接輸入命令 yum install httpd -y
我們來解析一下這個命令,yum是yellowdog updater modified的縮寫。它使用中心倉庫(repository)管理應用程序之間的相互關系,根據計算出來的軟體依賴關系對軟體進行升級、安裝、刪除等操作,減少了CentOS用戶一直頭痛的依賴關系的問題。一般這類軟體通過一個或者多個配置文件描述的倉庫的網路地址,通過http或者ftp協議在需要的時候從倉庫獲取軟體信息,下載相關的軟體包。這樣,本地用戶通過建立不同倉庫描述說明,在有網路連接時就能方便的進行系統的升級維護工作。
二,配置防火牆
回到我們的教程,安裝完成後如果您的系統自帶了防火牆功能,那麼就需要您執行如下命令 /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT

那我們再來解析一下這個命令,-I INPUT所指的是允許數據傳入伺服器,-p tcp是指允許tcp協議,而後面的dport 80 -j ACCEPT應該很容易理解。整條命令的意思就是允許用戶通過80埠的tcp協議傳入連接,以達到訪問頁面的效果。

三,啟動服務

接著,我們重啟防火牆以使我們剛添加的防火牆規則生效 service iptables restart
然後接著啟動apache服務 service httpd start

同樣,我不厭其煩的再解析一下service指令,service的英文意思為服務(不是你們想的那個服務.........),而這個指令的作用就是負責管理CentOS上你安裝的或者系統自帶的服務。而上面的兩條指令如果要解釋就是 服務iptables重啟 服務httpd開啟。多麼簡單對不對。

接著你就可以將你寫好的網頁傳到目錄/var/www/html下了。

③ 在虛擬機中安裝了centos 如何實現http服務

你虛擬機上裝完centos還需要在centos上安裝apache就可以提供http服務了,

④ centos7.2怎麼搭建網站

需要配置php環境,然後上傳網站程序進行安裝即可。聽說落櫻網路工作室還不錯,搭建的網站美觀,而且優化好,售後及時、很不錯。

⑤ 如何在centos7當中安裝http

安裝背景 :CPU32 bit,CentOS 6.4版本,openERP7.0,linux shell為bash,Postgresql9.2

1. CentOS 的安裝選項有最小化安裝、基本伺服器安裝、虛擬主機安裝等等的,這里採用的是基本伺服器安裝。

2、安裝postgresql9.2

如果有其他版本的pgsql的話,可以通過命令卸載 #yum remove postgres

#su root 用root用戶來安裝, 中間會切換用戶!

#mkdir /tmp

#cd /tmp 這是系統的臨時目錄,裡面的文件不重要,即使誤刪危害也不大,所以推薦在tmp目錄下做臨時性操作

⑥ centos 5.5 怎麼安裝web伺服器

一、web的安裝配置
1、安裝:yum install httpd mod_ssl -y
mod_ssl 是實現 https 協議時所依賴的包
2、配置文件的相關說明:
配置文件:
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d/*.conf
服務腳本
/etc/rc.d/init.d/httpd
腳本配置文件:/etc/sysconfig/httpd,這里可以定義MPM的類型
模塊目錄:
/usr/lib64/httpd/moles
/etc/httpd/moles
/etc/httpd/moles是/usr/lib64/httpd/moles的鏈接文件
主程序:
/usr/sbin/httpd: prefork 模式
/usr/sbin/httpd.event: event模式
/usr/sbin/httpd.worker: worker模式
日誌文件:
/var/log/httpd/access_log: 訪問日誌
/var/log/httpd/error_log: 錯誤日誌
站點文檔的根目錄:
/var/www/html

二、httpd的配置文件說明
# grep "Section" httpd.conf
### Section 1: Global Environment
### Section 2: 'Main' server configuration
### Section 3: Virtual Hosts
主要分為三部分:全局配置,主伺服器配置,虛擬主機的配置。主伺服器和虛擬主機一般不同時使用;默認僅啟用了主伺服器。在每個部分中有許多指令參數,這些指令參數不區分字元大小寫,但其值有可能會區分大小寫。

三、配置文件選項詳細說明
1、持久連接
通常的參數有:
KeepAlive {On|Off} 是否開啟持久連接功能。默認是 Off。
以下這2個指令參數只有在KeepAlive On 時才有效
KeepAliveRequests 100 允許的一次持久連接的最大請求數。
KeepAliveTimeout 2次持久連接時間的間隔

驗證效果:

2、MPM 參數
ServerStart 參數的驗證,共有9個相關的進程,其中一個是其他 8 個的父進程:

3、監聽的埠
指定格式:Listen [IP:]port 默認的埠號是80
這個埠可以自己指定,一般使用大家熟知的埠,常用的有 80 和 8080。
4、DSO 動態共享對象
在這里可以實現動態庫的裝載,可以使用 httpd -D MODULES 或者 httpd -M 來查看已載入的模塊名。

示例:
使用 mod_deflate 模塊壓縮頁面來優化傳輸速度。
未使用 mod_deflate 模塊,訪問 http;//192.168.1.66/messages 文件時相應的位元組數大小是:316080 位元組。
載入 mod_deflate 模塊,並進行配置 vim /etc/httpd/conf/httpd.conf。

載入後的驗證,載入 mod_deflate 模塊後的大小是 41902 位元組,壓縮比還是相當可觀的。

5、指定站點的根目錄
DocumentRoot 「/var/www/html」 這是 rpm 安裝方式的默認的根站點目錄。當然這個可以根據自己的需求來設定。
6、基於目錄和文件的訪問控制

使用 directory 指令基於本地文件系統來實現對目錄的訪問控制。
常見的控制指令有:
Options:
Indexes:Indexes: 當訪問的路徑下無默認的主頁面,將所有資源以列表形式呈現給用戶。
FollowSymlinks: 跳躍符號鏈接
AloowOverride: 支持在每個頁面目錄下創建.htaccess用於實現對此目錄中資源訪問時的訪問控制功能。
AuthCofig:用於實現用戶認證的目的。
Order結合deny from、allow from 一起使用,來基於 IP 地址設定訪問控制
例如:
這是設置訪問白名單的設置,只允許 172.16 網段的客戶端來訪問對應的目錄。當然 from 後面的地址是比較靈活的,像:172.16,172.16.0.0,172.16.0.0/16,172.16.0.0/255.255.0.0這種形式的都是允許的。
Order allow,deny
Allow from 172.16.0.0/16
當然,上面對目錄的控制,也可以使用 Locaton 指令基於URL來實現。
DocumentRoot 「/var/www/html」
<Directory "/var/www/html/admin">
訪問控制參數
</Directory>
等價於:
<Location "/admin">
訪問控制參數
</Location>
對於 Option Indexex參數示例,一般此選項作為文件伺服器,提供下載使用時使用到此選項,其他情況應慎重使用。
7、指定默認訪問的主頁面
默認的使用格式如下:這里也可以自己定義主頁面
DirectoryIndex index.html index.html.var
8、配置日誌功能

ErrorLog "/path/to/error_log" 指明錯誤日誌的路徑,可以適應相對地址。相對於 ServerRoot 指令所定義的目錄
LogLevel {debug|info|notice|warn|error|crit|alert|emerg} 指定日誌的級別
LogFormat 指定日誌文件的格式
CustomLog "/path/to/access_log" LogFormat_Name 指定 access_log 的路徑個和使用的格式
%h: 客戶端地址
%l: 遠程登錄名,通常為-
%u: 認證時輸入用戶名,沒有認證時為-
%t: 伺服器收到 用戶請求時的時間
%>s: 響應狀態碼
%b: 響應報文的長度,單位是位元組
%{HEADER_NAME}i: 記錄指定首部對應的值
9、路徑別名
使用指令參數:Alias 實現URL 路徑映射時,訪問的路徑不在依賴於站點的根目錄。
10、基於用戶訪問控制
基於用戶的認證的方式有基本認證(Basic)和摘要認證(digest)。這里是基於虛擬用戶來實現的。實現的方式有:文本文件、資料庫、ldap、資料庫引擎來提供API介面。
以基於文件的形式實現用戶訪問的控制來示例:
1、vim /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/admin">
Options none# optons 選項控制
AllowOverride AuthConfig # 實現用戶認證
AuthType Basic # 認證方式是 Basic
AuthName "Admin Area." # 提示信息
#AuthBasicProvider file # 認證方式的提供者
AuthUserFile /etc/httpd/conf/.htpasswd # 認證文件的路徑
Require valid-user # 登陸用戶控制 require user USER_NAME
</Directory>
2、提供認證文件
由 htpasswd 命令得到。常用選項:
-c: 如果此文件事先不存在,則創建;注意,只能在創建第一個用戶時使用
-m: 以md5的格式編碼存儲用戶的密碼信息
-D: 刪除指定用戶
例如:
htpasswd -c -m /etc/hhtpd/.htpasswd tom
3、組認證
<Directory "/var/www/html/admin">
Options none
AllowOverride AuthConfig
AuthType Basic
AuthName "Admin Area."
#AuthBasicProvider file
AuthUserFile /etc/httpd/conf/.htpasswd
AuthGroupFile /etc/httpd/conf/.htgroup # 組文件的路徑,自己手動建立
Require group GROUP_NAME
</Directory>
組文件格式:
組名:user1 user2 user3
11、虛擬主機
虛擬主機:使用不同訪問路徑
基於埠:通過不同的埠來提供不同的訪問站點
基於IP:基於不同的 ip 地址來訪問不同的站點
基於主機名:相同的 IP 地址通過不同的主機名來實現訪問不同的站點
(1) 使用虛擬的前提:取消主伺服器
注釋主伺服器的站點根路徑指定:DocumentRoot
(2) 定義虛擬主機
NameVirtualHost IP:PORT # 指定監聽的地址和埠
<VirtualHost IP:PORT>
ServerName # 主機名
ServerAlias # 定義多個主機名,此時 ServerName 的名稱應該是 UR
DocumentRoot # 根站定目錄
ServerAlias # 主機別名
ErrorLog # 錯誤日誌的定義
CustomLog #訪問日誌的定義
</VirtualHost>
配置文件語法檢查:
httpd -t
service httpd configtest
配置完成虛擬主機後,可使用 httpd -S 顯示配置的虛擬主機
測試:crul URL
12、https協議
由於http 協議在傳輸過程中使用的是明文傳輸。所以就出現了 https 協議來實現加密的 https 協議。ssl會話基於IP地址創建,所以,每一個IP僅創建一個SSL會話。https協議:是基於SSL二進制編碼, 監聽於443/tcp。
ssl握手要完成的工作:
交換協議版本號
選擇雙方都支持的加密方式
客戶端對伺服器端實現身份驗正
密鑰交換
客戶端驗正伺服器端證書:
有效性檢測:證書是否仍然在有效期內
CA的可信度檢測
證書的完整性檢測
持有者的身份檢測
配置httpd工作於https:
(1) 安裝mod_ssl模塊
# yum install mod_ssl
(2) 為服務端生成私鑰,並為其提供證書;
在服務端(172.16.10.9):
# (umask 077;openssl genrsa -out /etc/pki/CA/private/cacert.key 2048)
# openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/cacert.pem -days 1000
# touch index.txt
# echo "01" > serial
在客戶端:
#(umask 077;openssl genrsa -out /etc/httpd/httpd.key 2048)
#openssl req -new -key /etc/httpd/httpd.key -out /etc/httpd/httpd.csr
將 httpd.csr 傳到服務端簽名:
在服務端:
# openssl ca -in /root/httpd.csr -out /root/httpd.crt -days 1000
將簽好的證書,httpd.crt 傳回到客戶端,放到 /etc/httpd/ 目錄下
(3) 配置使用https的虛擬主機
<VirtualHost IP:443>
SSLCertificateFile # 證書路徑
SSLCertificateKeyFile # 證書私鑰文件
DocumentRoot # 虛擬主機的根站點
ServerName # 虛擬主機的主機名
</VirtualHost>
(4) 重新裝載配置
httpd reload
(5) 測試
# openssl s_client -connect IP:PORT -CAfile /path/to/ca_certificate
13、status頁面
httpd內嵌有handler,其中有一個handler用於輸出當前httpd服務相關狀態信息handler: server-status
啟用handler要使用SetHandler指令
handler: 當文件被調用時,apache內部表示形式;一般每種文件類型都有其隱式處理器
示例:基於 10、11、12、13
建立httpd伺服器(基於編譯的方式進行),要求:
提供兩個基於名稱的虛擬主機:
a www1.stu10.com,頁面文件目錄為/web/vhosts/www1;錯誤日誌為/var/log/httpd/www1.err,訪問日誌為/var/log/httpd/www1.access;
(b)www2.stu10.com,頁面文件目錄為/web/vhosts/www2;錯誤日誌為/var/log/httpd/www2.err,訪問日誌為/var/log/httpd/www2.access;
(c)為兩個虛擬主機建立各自的主頁文件index.html,內容分別為其對應的主機名;
(d)通過www1.stu10.com/server-status輸出httpd工作狀態相關信息,且只允許提供帳號密碼才能訪問(status:status);

1、配置文件的的編輯,vim /etc/httpd/httd.conf
還的注釋主配置下的 DocumentRoot "/var/www/html"
2、 創建對應的站點和提供密碼文件
# 創建對應的站點目錄並提供默認的頁面
mkdir /web/vhosts/www1/ -p
mkdir /web/vhosts/www2/ -p
echo "<h1>welcom www1.guotig.com<h1>" > /web/vhosts/www1/index.html
echo "<h1>welcom www2.guotig.com<h1>" > /web/vhosts/www2/index.html
# 提供用戶認證文件
htpasswd -cm /etc/httpd/conf/.htpasswd status
mkdir /web/hosts/www1/server-status
chowm apache.apache /web/hosts/www1/server-status

3、提供主機名解析文件 在/etc/hosts中添加:(在測試客戶端)

172.16.10.9 www1.stu10.com www2.stu10.com

4、測試結果如下:
為上面的第2個虛擬主機提供https服務,使得用戶可以通過https安全的訪問此web站點;
(1)要求使用證書認證,證書中要求使用的國家(CN)、州(Henan)、城市(Zhengzhou)和組織(MageE)
(2)設置部門為Ops,主機名為web.mage.com,郵件為[email protected]

1、編輯 vim /etc/httpd/conf.d/ssl.conf 添加以下內容
當然在 /etc/httpd/conf/httpd.conf,要載入 mod_ssl 模塊

使用 httpd -S 來查看已經配置好的虛擬機
2、提供證書
mkdir /etc/httpd/ssl && cd /etc/httpd/ssl
(umask 077; openssl genrsa -out httpd.key 1024)
openssl req -new -key httpd.key -out httpd.csr
去服務端簽署證書:
openssl ca -in httpd.csr -out /httpd.crt -days 300
簽署後的證書存放到:/etc/httpd/ssl/httpd.crt

3、驗證結果
首次訪問時會出現導入證書的問題,導入證書就可訪問。

導入證書就可以訪問了。

14、httpd程序包自帶的工具介紹
httpd: apache伺服器程序
-t: 測試配置文件
-l: 列表靜態模塊
-D DUMP_MODULES:列出DSO模塊
-M:等價於 -t -D DUMP_MODULES
-D DUMP_VHOSTS: 列出所有虛擬主機
htpasswd: 為基於文件的basic認證創建和更新用戶認證文件
apachectl: 腳本,httpd服務控制工具,可啟動,關閉,重新載入配置文件。
ab: (apache benchmark)httpd的基準性能測試工具;
apxs: httpd得以擴展使用第三方模塊的工具;
htcacheclean: 磁碟緩存清理工具;
htdigest: 為digest認證創建和更新用戶認證文件
httxt2dbm: 為rewrite map創建dbm格式的文件
rotatelogs: 日誌滾動,不關閉httpd而切換其使用日誌文件的工具
suexec: 當httpd進程需要以另外的用戶的身份去訪問某些資源時,可以以suexec作臨時切換;
15、ab工具的初步使用
同類工具:http_load, webbench, seige
Usage: ab [options] [http[s]://]hostname[:port]/path
常用的參數:
-c #: 模擬的並發數;
-n #: 總的請求數,-n的值一定要大於等於-c的值;
使用 ab -c 100 -n 5000 http://www.stu10.com/index.html測試的結果如下:

但是把並發量提高到2000的時候,就會出現以下的錯誤。

這是由於資源限定的問題,一般情況下,Linux默認打開的文件數是1024。

⑦ Linux怎麼搭建Web伺服器

1.開始說明
本教程中使用的IP地址是192.168.0.100,主機名稱為Server1.example.com 這些設置可能會有所不同,你需要根據不同情況進行修改。

CentOS 6.2下安裝MySQL
2.開始安裝MySQL5
首先我們應該先用下面的命令安裝MySQL:
yum install mysql mysql-server
然後我們需要創建MySQL系統的啟動鍵鏈接啟動MySQL伺服器,這樣以便於MySQL在系統啟動時自動啟動
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
為MySQL root帳戶設置密碼
mysql_secure_installation
會出現下面的一系列提示:
root@server1 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] <-- ENTER
New password: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
proction environment.
Remove anonymous users? [Y/n] <-- ENTER
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <-- ENTER
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a proction environment.
Remove test database and access to it? [Y/n] <-- ENTER
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <-- ENTER
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@server1 ~]#

CentOS 6.2下安裝Apache
3.安裝阿帕奇2
Apache2的是作為一個CentOS的軟體包,因此我們可以直接用下面命令安裝它:
yum install httpd
現在配置系統在引導時啟動Apache
chkconfig --levels 235 httpd on
並啟動Apache
/etc/init.d/httpd start
現在,您的瀏覽器到http://192.168.0.100,你應該看到Apache2的測試頁:

Apache 2測試網頁
Apache的默認文檔根目錄是在CentOS上的/var/www/html 目錄 ,配置文件是/etc/httpd/conf/httpd.conf。配置存儲在的/etc/httpd/conf.d/目錄。
4.安裝PHP5
我們可以用下面的命令來安裝PHP5
yum install php
安裝完需要重啟
/etc/init.d/httpd restart

CentOS 6.2下安裝PHP5
5.我們可以安裝PHP5和Apache的PHP5的模塊如下:
默認網站的文件根目錄是在/srv/www/html中。現在我們將在該目錄中創建一個小型PHP文件(info.php的)在瀏覽器中調用它。該文件將顯示很多關於我們的PHP安裝,如安裝的PHP版本和有用的一些細節。
vi /var/www/html/info.php

修改細節
現在,我們可以用瀏覽器訪問例如http://192.168.0.100/info.php文件

PHP頁面
正如你所看到的,PHP5的工作,它通過Apache 2.0的處理程序,在伺服器API線。如果你繼續向下滾動,你會看到所有在PHP5中已經啟用的模塊。MySQL是沒有列出,這意味著我們沒有在PHP5支持MySQL。
6.PHP5獲得MySOL的支持
讓PHP在MySQL中獲得支持,我們可以安裝的php-mysql軟體包。安裝一些其他的PHP5模塊,以及您可能需要的應用程序,這是一個好主意:
yum search php
還安裝需要安裝的
yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc
現在重新啟動Apache2的:
/etc/init.d/httpd restart
現在,重載http://192.168.0.100/info.php在您的瀏覽器,並再次向下滾動到模塊部分。現在,你應該找到許多新的模塊,包括MySQL模塊:

MySQL頁面

CentOS 6.2下安裝phpMyAdmin
7.安裝phpMyAdmin
phpMyAdmin是一個網路介面,通過它可以管理你的MySQL資料庫。
首先,我們使CentOS系統RPMForge軟體庫的phpMyAdmin,而不是官方的CentOS 6.2庫:
所以需要導入RPMForge的GPG密鑰:
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
x86_64系統:
yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
在i386系統:
yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
安裝phpmyadmin
yum install phpmyadmin
現在我們可以設置phpMyAdmin,了我們可以改變Apache的配置來讓phpMyAdmin不僅僅只能從localhost登錄。
vi /etc/httpd/conf.d/phpmyadmin.conf

配置
下一步,我們從HTTP改變的phpMyAdmin的cookie來身份驗證:
vi /usr/share/phpmyadmin/config.inc.php

修改身份驗證
重啟阿帕奇
/etc/init.d/httpd restart
在地址欄輸入http://192.168.0.100/phpMyAdmin/:你就可以訪問phpMyAdmin了。

phpmyadmin頁面
CentOS可以得到RHEL的所有功能,甚至是更好的軟體。但CentOS並不向用戶提供商業支持,當然也不負上任何商業責任。
如果你要將你的RHEL轉到CentOS上,因為不希望為RHEL升級而付費。當然,你必須有豐富linux使用經驗,因此RHEL的商業技術支持對你來說並不重要。但如果你是單純的業務型企業,那麼還是建議你選購RHEL軟體並購買相應服務。這樣可以節省你的IT管理費用,並可得到專業服務。

⑧ linux centos怎麼搭建http文件伺服器

centos如果是建立文件伺服器一般使用ftp,安裝vsftp服務即可。
如果使用http的文件伺服器,可以使用apache的目錄瀏覽功能。

⑨ centos6.3 怎麼搭建代理服務

實驗環境:
系統 centos6.3
內網 eth0:192.168.223.163
外網 eth1:192.168.22.78
Squid Cache: Version squid-3.1.10
網卡配置如下:
內網:
centos6.3(x64) squid透明代理伺服器(詳細安裝步驟) - Only - Only
外網:
centos6.3(x64) squid透明代理伺服器(詳細安裝步驟) - Only - Only
安裝
[root@only ~]# yum -y install squid
Installing : 7:squid-3.1.10-18.el6_4.x86_64
Verifying : 7:squid-3.1.10-18.el6_4.x86_64
Installed:
squid.x86_64 7:3.1.10-18.el6_4
Complete!
配置文件如下(更改地方用紅色)
[root@only ~]# vim /etc/squid/squid.conf
#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
#acl worktime time 8:00-23:59 //定義工作時間
#acl worktime time 00:00-5:59
#http_access allow mynetwork !worktime //只允許非工作時間上網

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access allow all

# Squid normally listens to port 3128
http_port 192.168.223.163:3128 transparent

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 2000 16 256

# Leave coremps in the first cache dir
coremp_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
visible_hostname 192.168.223.163
cache_mem 256 MB //squid伺服器佔用內存大小
forwarded_for off //不傳遞被代理地址
via off //不傳遞代理伺服器信息
初始化squid代理伺服器
[root@only ~]# squid -z
2013/08/14 10:06:24| Creating Swap Directories
2013/08/14 10:06:24| /var/spool/squid exists
2013/08/14 10:06:24| Making directories in /var/spool/squid/00
2013/08/14 10:06:24| Making directories in /var/spool/squid/01
2013/08/14 10:06:24| Making directories in /var/spool/squid/02
2013/08/14 10:06:24| Making directories in /var/spool/squid/03
2013/08/14 10:06:24| Making directories in /var/spool/squid/04
2013/08/14 10:06:24| Making directories in /var/spool/squid/05
2013/08/14 10:06:24| Making directories in /var/spool/squid/06
2013/08/14 10:06:24| Making directories in /var/spool/squid/07
2013/08/14 10:06:24| Making directories in /var/spool/squid/08
2013/08/14 10:06:24| Making directories in /var/spool/squid/09
2013/08/14 10:06:24| Making directories in /var/spool/squid/0A
2013/08/14 10:06:24| Making directories in /var/spool/squid/0B
2013/08/14 10:06:24| Making directories in /var/spool/squid/0C
2013/08/14 10:06:24| Making directories in /var/spool/squid/0D
2013/08/14 10:06:24| Making directories in /var/spool/squid/0E
2013/08/14 10:06:24| Making directories in /var/spool/squid/0F
開啟路由功能,並將下面的命令寫入/etc/rc.d/rc.local 文件,使其開機自動開啟路由功能
[root@only ~]# echo '1'>/proc/sys/net/ipv4/ip_forward
或者如下 vi /etc/sysctl.conf文件 將 net.ipv4.ip_forward = 0 改成 =1
[root@only ~]# sysctl -p
net.ipv4.ip_forward = 1
配置iptables防火牆
自動將http請求轉發到代理伺服器上
[root@only ~]# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 3128
設置源地址映射
[root@only ~]# iptables -t nat -A POSTROUTING -j SNAT --to-source 192.168.22.78
[root@only ~]# iptables -P INPUT ACCEPT
啟動squid代理服務
[root@only ~]# service squid restart
Stopping squid: [FAILED]
Starting squid: . [ OK ]
查看squid代理伺服器緩存日誌
[root@only ~]# tail -f /var/log/squid/access.log
將squid加入開機啟動項
[root@only ~]# chkconfig squid --level 235 on
搞定。

⑩ 求centos6.5 郵件伺服器搭建詳細文檔

這個沒有相關的搭建資料,不過你可以看看u-mail郵件系統的一體盤安裝方法,就是使用的centos來搭建郵件伺服器。http://jingyan..com/article/a948d6514bdbbb0a2dcd2e81.html

熱點內容
手機如何解壓百度雲文件 發布:2024-05-19 00:32:24 瀏覽:904
centos使用python 發布:2024-05-18 23:39:48 瀏覽:867
幻影天龍腳本 發布:2024-05-18 23:38:17 瀏覽:712
編程的py 發布:2024-05-18 23:36:22 瀏覽:74
安卓系統怎麼改序列號 發布:2024-05-18 23:28:16 瀏覽:783
c語言中實數 發布:2024-05-18 23:21:03 瀏覽:895
伺服器搭建題目 發布:2024-05-18 23:01:29 瀏覽:28
下載武裝突襲後怎麼進伺服器 發布:2024-05-18 22:56:17 瀏覽:825
c語言字元串大寫變小寫 發布:2024-05-18 22:56:16 瀏覽:438
重啟刪除的文件夾 發布:2024-05-18 22:34:11 瀏覽:638