php语言
[root@westosb ~]# cd /var/www/html/
[root@westosb html]# ls
index.html westos westos.html
[root@westosb html]# vim index.php
[root@westosb html]# dnf install php.x86_64 -y
[root@westosb html]# systemctl restart httpd
访问成功:
perl语言
cgi
[root@westosb html]# mkdir cgi
[root@westosb html]# ls
cgi index.html index.php westos westos.html
[root@westosb html]# cd cgi/
[root@westosb cgi]# vim index.html
[root@westosb cgi]# ls
index.html
[root@westosb cgi]# mv index.html index.cgi
[root@westosb cgi]# ls
index.cgi
[root@westosb cgi]# chmod +x index.cgi
[root@westosb cgi]# ls -Zd /var/www/cgi-bin/
system_u:object_r:httpd_sys_script_exec_t:s0 /var/www/cgi-bin/
[root@westosb cgi]# semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/html/cgi(/.*)?'
[root@westosb cgi]# restorecon -RvvF /var/www/html/cgi/
Relabeled /var/www/html/cgi from unconfined_u:object_r:httpd_sys_content_t:s0 to system_u:object_r:httpd_sys_script_exec_t:s0
Relabeled /var/www/html/cgi/index.cgi from unconfined_u:object_r:httpd_sys_content_t:s0 to system_u:object_r:httpd_sys_script_exec_t:s0
[root@westosb cgi]# systemctl restart httpd
[root@westosb cgi]# cat index.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print `date`;
[root@westosb cgi]# ./index.cgi
Content-type: text/html
Sat Jul 31 15:32:54 CST 2021
[root@westosb cgi]# vim /etc/httpd/conf.d/vhosts.conf
//
[root@westosb cgi]# systemctl restart httpd
访问成功:
python语言
wsgi
[root@westosb cgi]# dnf install python3-mod_wsgi.x86_64 -y
[root@westosb cgi]# cd /etc/httpd/conf.d/
[root@westosb conf.d]# ls
autoindex.conf php.conf userdir.conf welcome.conf
manual.conf README vhosts.conf
[root@westosb conf.d]# vim vhosts.conf
//
//
[root@westosb conf.d]# setenforce 0
[root@westosb ~]# cd /var/www/html/
[root@westosb html]# ls
cgi index.html index.php westos westos.html
[root@westosb html]# vim index.wsgi ##注意目录路径
[root@westosb html]# cat /etc/httpd/conf.d/index.wsgi
def application(env, westos):
westos('200 ok',[('Content-Type', 'text/html')])
return [b'hello westos ahhh!']
[root@westosb html]# systemctl restart httpd
在搜索主机上的操作:
[root@westos_student11 ~]# vim /etc/hosts
//
172.25.254.211 www.westos.org music.westos.org news.westos.org jwh.westos.org wsgi.westos.org
//
访问成功: