centos訪問apache
㈠ 虛擬機centos下apache開啟但是主機輸入ip無法訪問
apache的方法為:
1.停止apche的服務
2.備份apche當前的配置文件/<apche_Home>/conf/httpd.conf,注意<apche_Home>代表了apche的安裝目錄
3.用文本編輯器打開文件/<apche_Home>/conf/httpd.conf,查找如下的內容:
order
allow,deny
allow
from
all
4.在「allow
from
all」後面添加一行「deny
from
<IP_WantToDeny>」,其中<IP_WantToDeny>表示要屏蔽的IP地址,比如:要屏蔽163.236.54.30那麼應該寫成:
order
allow,deny
allow
from
all
deny
from
163.236.54.30
㈡ Centos虛擬機搭建的apache無法使用
Apache htdocs目錄下放好網頁文件
如果不是使用Apache預設訪問目錄,需要禁用selinux
啟動Apache服務
本機Firefox瀏覽器地址欄輸入http://localhost
Windows瀏覽器輸入IP地址即可,不用後面的localhost
㈢ Centos 下Apache(httpd) 安裝過程
其實,網上這塊的部署文章非常多 。隨便搜索,都有 。
這篇文章,老徐幫大家挑選幾個比較重點的過程 & 命令 。
1. 有些 linux 版本中已經預置了有Apache,並且已經是服務了,所有首先檢查系統中是否已經存在httpd的服務
1)先檢查 伺服器 上是否已經啟動了此服務 。
命令如下
ps -ef|grep httpd
2)查看linux系統服務中有沒有httpd
chkconfig --list | grep httpd
3)如果有服務存在,那麼需要先關閉httpd服務自啟動
命令 chkconfig httpd off
4)停止httpd服務
命令 service httpd stop
5)再次查看,是否有進程存在
命令 ps -ef|grep httpd
6)如果有進程存在,關閉進程
命令 kill -9 pid
1)先檢查 安裝包 的名字
命令 rpm -qa|grep httpd
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester]~# rpm -qa|grep httpd
httpd-2.2.15-69.el6.centos.x86_64
httpd-tools-2.2.15-69.el6.centos.x86_64</pre>
2)根據安裝包名字刪除包
rpm -e httpd-tools-2.2.15-69.el6.centos.x86_64
rpm -e httpd-2.2.15-69.el6.centos.x86_64
3)刪除httpd.conf文件
<pre class="prettyprint" style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">#先檢查文件在哪
find / -name httpd.conf
rm /xxx/xxx/httpd.conf</pre>
3. 准備事項已完成,剩下的就是常規安裝了 。
註:我們通過yum的方式,在線安裝,非常簡單 。
1)檢查是否存在httpd包
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[www@istester ~]$ yum list httpd
Loaded plugins: security
base | 3.7 kB 00:00
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 28 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 3.2 MB 00:00
Available Packages
httpd.x86_64 2.2.15-69.el6.centos base</pre>
2、安裝Apache
yum install httpd
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Total 20 MB/s | 932 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 1/4
Updating : httpd-tools-2.2.15-69.el6.centos.x86_64 2/4
Installing : httpd-2.2.15-69.el6.centos.x86_64 3/4
Cleanup : httpd-tools-2.2.15-53.el6.centos.x86_64 4/4
Verifying : httpd-tools-2.2.15-69.el6.centos.x86_64 1/4
Verifying : httpd-2.2.15-69.el6.centos.x86_64 2/4
Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/4
Verifying : httpd-tools-2.2.15-53.el6.centos.x86_64 4/4
Installed:
httpd.x86_64 0:2.2.15-69.el6.centos
Dependency Installed:
apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1
Dependency Updated:
httpd-tools.x86_64 0:2.2.15-69.el6.centos
Complete!</pre>
安裝過程,不用理會,如果看到如上提示,說明安裝成功了。
3、設置Apache服務的啟動級別
chkconfig --levels 235 httpd on
Apache是一個服務,所以,可以通過設置服務的啟動級別來讓它啟動。
4、啟動服務
兩種方式,
1)如下 /etc/init.d/httpd start
2)如下
service httpd start
5、查看服務是否正常啟動
兩種方式,
1)查看服務狀態
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester www]# service httpd status
httpd (pid 10339) is running...</pre>
2)查看進程
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester www]# ps -ef|grep httpd | grep -v grep
root 10339 1 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10341 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10342 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10343 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10344 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10345 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10346 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10347 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10348 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd</pre>
補充,
1)停止服務
service httpd stop
2)重啟服務
service httpd restart
6、安裝之後的說明:
1)驗證是否安裝成功
現在打開 http://ip 地址,看看有沒有Apache的默認頁面出來了?如果有就對了。
2)安裝目錄說明
Apache默認將網站的根目錄指向 /var/www/html
默認的主配置文件是 /etc/httpd/conf/httpd.conf
配置存儲在的/etc/httpd/conf.d/目錄
End
文 / IDO老徐
㈣ 怎麼訪問centos下的apache伺服器
你所指的訪問, 是指類似於 在win下的瀏覽器下輸入www..com 嗎? 還是是想進入apache所在的伺服器? 前者的話, 在linux 命令行下 輸入 curl 你的url
後者的話,你有許可權, 就可以直接訪問的撒。
㈤ centos 配置apache和tomcat共同使用https
版本:
apache 2.4.6
tomcat 8.5.27
架構:
1、apache自帶的mod_proxy架構代理轉發請求到tomcat,由tomcat解析jsp(apache2.4.6的版本默認已經載入了mod_proxy,留意:Include conf.moles.d/*.conf)
2、在apache中配置https的ssl證書(證書文件是阿里雲的證書,放置在目錄httpd根目錄下面)
3、由於是多虛擬主機架構,故不使用conf.d/ssl.conf文件,直接在httpd.conf中配置ssl站點(所以我把conf.d/ssl.conf文件清空了,否則老是報錯:Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:443)
如下:
修改文件:conf/httpd.conf增加虛擬主機站點
㈥ 怎麼訪問centos下的apache伺服器
servername:80記得做dns域名指向。---------------------修改apache配置文件里的servernamedns域名指向設置,請向域名供應商咨詢
㈦ 虛擬機centos下apache開啟但是主機輸入ip無法訪問
apache的方法為:
1.停止apche的服務
2.備份apche當前的配置文件/<apche_Home>/conf/httpd.conf,注意<apche_Home>代表了apche的安裝目錄
3.用文本編輯器打開文件/<apche_Home>/conf/httpd.conf,查找如下的內容:
order allow,deny
allow from all
4.在「allow from all」後面添加一行「deny from <IP_WantToDeny>」,其中<IP_WantToDeny>表示要屏蔽的IP地址,比如:要屏蔽163.236.54.30那麼應該寫成:
order allow,deny
allow from all
deny from 163.236.54.30