溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

Centos8中如何部署Apache虛擬機(jī)

發(fā)布時(shí)間:2022-02-17 10:20:25 來(lái)源:億速云 閱讀:334 作者:iii 欄目:開(kāi)發(fā)技術(shù)

這篇文章主要介紹了Centos8中如何部署Apache虛擬機(jī)的相關(guān)知識(shí),內(nèi)容詳細(xì)易懂,操作簡(jiǎn)單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇Centos8中如何部署Apache虛擬機(jī)文章都會(huì)有所收獲,下面我們一起來(lái)看看吧。

實(shí)驗(yàn)環(huán)境

操作系統(tǒng):Centos 8

web應(yīng)用:apache

內(nèi)網(wǎng)IP:192.168.3.21

shell執(zhí)行:root

Centos8中如何部署Apache虛擬機(jī)

以root或具有sudo權(quán)限的用戶(hù)身份登錄執(zhí)行如下操作。

安裝httpd服務(wù)

[root@linuxcool ~]# yum install httpd-devel.x86_64 httpd.x86_64 httpd-tools.x86_64

驗(yàn)證httpd是否安裝成功

[root@linuxcool ~]# httpd -vServer version: Apache/2.4.6 (CentOS)
Server built:   Apr  2 2020 13:13:23

啟動(dòng)httpd服務(wù)

[root@linuxcool ~]# systemctl start httpd.service     
[root@linuxcool ~]# systemctl status httpd.service● httpd.service - The Apache HTTP Server
  Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  Active: active (running) since Fri 2020-05-22 12:23:03 CST; 25s ago
    Docs: man:httpd(8)
          man:apachectl(8)
Main PID: 952 (httpd)
  Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"   Tasks: 6
  Memory: 3.6M
  CGroup: /system.slice/httpd.service
          ├─952 /usr/sbin/httpd -DFOREGROUND
          ├─953 /usr/sbin/httpd -DFOREGROUND
          ├─954 /usr/sbin/httpd -DFOREGROUND
          ├─955 /usr/sbin/httpd -DFOREGROUND
          ├─956 /usr/sbin/httpd -DFOREGROUND
          └─957 /usr/sbin/httpd -DFOREGROUND

May 22 12:23:03 linuxcool systemd[1]: Starting The Apache HTTP Server...
May 22 12:23:03 linuxcool httpd[952]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, u...message
May 22 12:23:03 linuxcool systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

apache安裝成功,默認(rèn)web目錄/var/www/

測(cè)試

http://192.168.3.21/
Centos8中如何部署Apache虛擬機(jī)

安裝成功!

配置apache虛擬主機(jī)

創(chuàng)建網(wǎng)站目錄

[root@linuxcool ~]# mkdir -p /var/www/web1[root@linuxcool ~]# mkdir -p /var/www/web2

web1添加index.html

[root@linuxcool ~]# vim /var/www/web1/index.htmlnbsp;html>
"ltr">
 
   "utf-8">
   Welcome to Web1 
 
   Success! Web1 home page!

web2添加index.html

[root@linuxcool ~]# vim /var/www/web2/index.htmlnbsp;html>
"ltr">
 
   "utf-8">
   Welcome to Web2 
 
   Success! Web2 home page!

授權(quán)web目錄權(quán)限

[root@linuxcool ~]# chown -R apache: /var/www/web1/[root@linuxcool ~]# chown -R apache: /var/www/web2/

創(chuàng)建虛擬主機(jī)文件

#web1

[root@linuxcool ~]# vim /etc/httpd/conf.d/web1.confServerName web1.comServerAlias www.web1.comServerAdmin webmaster@example.comDocumentRoot /var/www/web1Options -Indexes +FollowSymLinksAllowOverride AllErrorLog /var/log/httpd/example.com-error.logCustomLog /var/log/httpd/example.com-access.log combined

#web2

[root@linuxcool ~]# vim /etc/httpd/conf.d/web2.confServerName web2.comServerAlias www.web2.comServerAdmin webmaster@example.comDocumentRoot /var/www/web2Options -Indexes +FollowSymLinksAllowOverride AllErrorLog /var/log/httpd/example.com-error.logCustomLog /var/log/httpd/example.com-access.log combined

重啟httpd服務(wù)

[root@linuxcool ~]# systemctl restart httpd.service

驗(yàn)證httpd虛擬主機(jī)結(jié)果

http://www.web1.com

Centos8中如何部署Apache虛擬機(jī)

http://www.web2.com

Centos8中如何部署Apache虛擬機(jī)

關(guān)于“Centos8中如何部署Apache虛擬機(jī)”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對(duì)“Centos8中如何部署Apache虛擬機(jī)”知識(shí)都有一定的了解,大家如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI