Apache服務(wù)的示例分析

本篇文章為大家展示了Apache服務(wù)的示例分析,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

創(chuàng)新互聯(lián)專(zhuān)業(yè)為企業(yè)提供房山網(wǎng)站建設(shè)、房山做網(wǎng)站、房山網(wǎng)站設(shè)計(jì)、房山網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、房山企業(yè)網(wǎng)站模板建站服務(wù),十多年房山做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

Apache HTTP SERVER

Apache軟件基金會(huì)的一個(gè)開(kāi)放源代碼的網(wǎng)頁(yè)服務(wù)器軟件

curl -I 查看網(wǎng)站的網(wǎng)頁(yè)服務(wù)器類(lèi)型

實(shí)驗(yàn)測(cè)試之前注意向發(fā)起訪(fǎng)問(wèn)請(qǐng)求的主機(jī)添加域名解析/etc/host

一、安裝httpd

yum install httpd

systemctl start httpd

systemctl enable httpd #開(kāi)機(jī)啟動(dòng)

firewall-cmd  --permanent --add-service=http #將http服務(wù)添加至防火墻列表中

firewall-cmd  --reload

firewall-cmd  --permanent --add-service=https #將https服務(wù)添加至防火墻列表中

firewall-cmd  --reload

修改http的主配置文件修改默認(rèn)設(shè)置

/etc/httpd/conf/httpd.conf

42 Listen 80#修改http服務(wù)的默認(rèn)網(wǎng)絡(luò)端口

119 DocumentRoot "/www/html"#修改http服務(wù)的默認(rèn)發(fā)布目錄

120 <Directory "/www/html">

121     Require all granted

122 </Directory>

167 <IfModule dir_module>

168     DirectoryIndex webtest index.html#默認(rèn)發(fā)布文件,先讀前者,前者不可用再讀后者#

169 </IfModule>

firewall-cmd --add-port=8080/tcp

systemctl restart httpd

mkdir /www/html/webtest

selinux標(biāo)簽與默認(rèn)發(fā)布目錄一致

ls -Z /var/www/

semanage fcontext -a -t httpd_sys_content_t “/www(/.*)?”

restorecon -vvFR /www

二、虛擬主機(jī)

一臺(tái)主機(jī)為多個(gè)網(wǎng)站提供服務(wù)

vim /etc/httpd/conf.d/default.conf

<Virtualhost _default_:80>

        Documentroot /www/html

        Customlog "logs/default.log" combined#指定日志

</Virtualhost>

vim /etc/httpd/conf.d/news.conf

<Virtualhost *:80>

        Servername news.laosiji.com

        Serveralias news#設(shè)置別稱(chēng)

        Documentroot /www/laosiji.com/news

        Customlog "logs/news.log" combined

</Virtualhost>

<Directory "/www/laosiji.com/news">

        Require all granted

</Directory>

vim /etc/httpd/conf.d/xxx.conf

mkdir -p /www/laosiji.com/news

vim /www/laosiji.com/news/webtest#與前面設(shè)置的文件名稱(chēng)一致

三、授權(quán)指定用戶(hù)訪(fǎng)問(wèn)

首先新建一個(gè)發(fā)布目錄作為測(cè)試目錄

mkdir -p /www/laosiji.com/admin/webtest

htpasswd -cm /etc/httpd/htpasswd admin    #再次添加用戶(hù)時(shí)注意,選項(xiàng)為-m,否則之前的信息會(huì)被覆蓋

New password:

Re-type new password:

會(huì)生成加密密碼文件/etc/httpd/htpasswd

<Directory "/www/laosiji.com/film/admin">

        Authuserfile "/etc/httpd/htpasswd"

        Authtype basic

        Authname "Please input username and password"

        Require user admin#或者設(shè)置為valid-user所有授權(quán)用戶(hù)可登陸

</Directory>

四、自定義自簽名證書(shū)

yum install crypto-utils mod_ssl

genkey laosiji.com #主機(jī)名,生成證書(shū)

Apache服務(wù)的示例分析

選擇next

Apache服務(wù)的示例分析

有幾種密鑰規(guī)格供選擇

Apache服務(wù)的示例分析

生成密鑰中    #生成緩慢時(shí)可以敲擊鍵盤(pán)或移動(dòng)鼠標(biāo)

Apache服務(wù)的示例分析

選擇no不向CA發(fā)送驗(yàn)證請(qǐng)求

Apache服務(wù)的示例分析

選擇next

Apache服務(wù)的示例分析

填寫(xiě)一些信息(注意主機(jī)名不要寫(xiě)錯(cuò))

vim /etc/httpd/conf.d/login.conf#新建login用于測(cè)試

mkdir /www/laosiji.com/login

<Virtualhost *:443>

        Servername login.laosiji.com

        Serveralias login

        Documentroot /www/laosiji.com/login

        Customlog "logs/login.log" combined

        SSLEngine on

        SSLCertificateFile /etc/pki/tls/certs/laosiji.com.crt

        SSLCertificateKeyFile /etc/pki/tls/private/laosiji.com.key

</Virtualhost>

<Directory "/www/laosiji.com/login">

        Require all granted

</Directory>

<VirtualHost *:80>#網(wǎng)頁(yè)重定向

servername login.laosiji.com

rewriteengine on

rewriterule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]

</VirtualHost>

systemctl restart httpd

vim /www/laosiji.com/login/webtest#寫(xiě)一份測(cè)試文本

Welcome log in

打開(kāi)瀏覽器寫(xiě)入login.laosiji.com

Apache服務(wù)的示例分析

Apache服務(wù)的示例分析

選擇Add Excetion

Apache服務(wù)的示例分析

選擇Confirm Security Exception

得到證書(shū)網(wǎng)頁(yè)即可正常顯示

上述內(nèi)容就是Apache服務(wù)的示例分析,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

文章名稱(chēng):Apache服務(wù)的示例分析
標(biāo)題路徑:http://muchs.cn/article36/gdejpg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、品牌網(wǎng)站建設(shè)品牌網(wǎng)站制作Google、做網(wǎng)站外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

營(yíng)銷(xiāo)型網(wǎng)站建設(shè)