怎么在CentOS 8上安裝與配置Apache虛擬主機(jī),很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。
成都創(chuàng)新互聯(lián)公司是專(zhuān)業(yè)的奉新網(wǎng)站建設(shè)公司,奉新接單;提供網(wǎng)站制作、成都網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專(zhuān)業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行奉新網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專(zhuān)業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專(zhuān)業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
Apache服務(wù)器是現(xiàn)代操作系統(tǒng)包括UNIX和Windows等開(kāi)發(fā)和維護(hù)開(kāi)源的HTTP服務(wù)器,apache提供一個(gè)安全、高效、可擴(kuò)展的服務(wù)器,提供與當(dāng)前HTTP標(biāo)準(zhǔn)同步的HTTP服務(wù)。 |
實(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
以root或具有sudo權(quán)限的用戶身份登錄執(zhí)行如下操作。
安裝httpd服務(wù)
[root@linuxcool ~]# yum install httpd-devel.x86_64 httpd.x86_64 httpd-tools.x86_64
驗(yàn)證httpd是否安裝成功
[root@linuxcool ~]# httpd -v Server 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/
安裝成功!
配置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.htmlWelcome to Web1 Success! Web1 home page!
web2添加index.html
[root@linuxcool ~]# vim /var/www/web2/index.htmlWelcome to Web1 Success! Web1 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.com ServerAlias www.web1.com ServerAdmin webmaster@example.com DocumentRoot /var/www/web1 Options -Indexes +FollowSymLinks AllowOverride All ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/example.com-access.log combined
#web2
[root@linuxcool ~]# vim /etc/httpd/conf.d/web2.confServerName web2.com ServerAlias www.web2.com ServerAdmin webmaster@example.com DocumentRoot /var/www/web2 Options -Indexes +FollowSymLinks AllowOverride All ErrorLog /var/log/httpd/example.com-error.log CustomLog /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
http://www.web2.com
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。