RHCE試題EX300詳解(十六)實現動態 web 內容

題目要求:在 server0 上實現動態 web 內容

  • l 動態內容由名為 webapp0.example.com 的虛擬主機提供
  • l 虛擬主機偵聽端口為 8909
  • l 從 http://classroom.example.com/content/webapp.wsgi 下載一個腳本,然後放在適當的位置,不要修改文件內容
  • l 客戶端訪問 http://webapp0.example.com:8909 時,應該接收到動態生成的 web 頁面
  • l 此 http://webapp0.example.com:8909 必須能被 example.com 內所有的系統訪問

知識點小貼士:

重要配置選項:

ServerRoot 服務器運行的根目錄

MaxClients 能同時訪問服務器的客戶機數量

DocumentRoot 服務器共享文件的起始位置

listen 服務器監聽的端口

ServerAdmin 管理員的信箱

User&Group 服務器運行者的身份

ErrorLog 出錯日誌文件

DirectoryIndex 默認文件夾索引文件

AddDefaultCharset 默認返回頁面的編碼

Alias 為目錄設置訪問別名

解題步驟:

(1)準備目錄和文件:

<code>[root@server0 ~]# mkdir /var/www/webapp/<code>
<code>[root@server0 ~]# wget -O /var/www/webapp/webinfo.wsgi http://classroom.example.com/content/webapp.wsgi
--2020-03-26 09:18:04--  http://classroom.example.com/content/webapp.wsgi
Resolving classroom.example.com (classroom.example.com)... 172.25.254.254
Connecting to classroom.example.com (classroom.example.com)|172.25.254.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 396
Saving to: ‘/var/www/webapp/webinfo.wsgi’
 
100%[=====================>] 396         --.-K/s   in 0s     
2020-03-26 09:18:04 (45.5 MB/s) - ‘/var/www/webapp/webinfo.wsgi’ saved [396/396]
[root@server0 ~]# semanage port -a -t http_port_t -p tcp 8909/<code>

(2)防火牆放行8909端口

<code>[root@server0 ~]# firewall-cmd --add-port=8909/tcp
success
[root@server0 ~]# firewall-cmd --add-port=8909/tcp --permanent
success/<code>

(3)在/etc/httpd/conf.d中添加一個文件:webapp.conf

<code>[root@server0 ~]# vim /etc/httpd/conf.d/webapp.conf/<code>


RHCE試題EX300詳解(十六)實現動態 web 內容

註釋:添加內容如下

<code>Listen 8909
<virtualhost>
  ServerName webapp0.exmaple.com
  WSGIScriptAlias / /var/www/webapp/webinfo.wsgi
/<virtualhost>/<code>

(4)重啟httpd服務

<code>[root@server0 ~]# systemctl restart httpd/<code>

(5)驗證:

<code>[root@server0 ~]# vim /etc/httpd/conf.d/webapp.conf
[root@server0 ~]# curl http://webapp0.example.com:8909
UNIX EPOCH time is now: 1585186407.08
[root@server0 ~]# firefox http://webapp0.example.com:8909/<code>


RHCE試題EX300詳解(十六)實現動態 web 內容

在Desktop0上驗證:

<code>[root@desktop0 ~]# curl http://webapp0.example.com:8909
UNIX EPOCH time is now: 1585186486.72
[root@desktop0 ~]# firefox http://webapp0.example.com:8909/<code>


RHCE試題EX300詳解(十六)實現動態 web 內容


分享到:


相關文章: