Apache的语言支持

php语言

[root@westosb ~]# cd /var/www/html/  
[root@westosb html]# ls
index.html  westos  westos.html
[root@westosb html]# vim index.php    编写php测试文件
[root@westosb html]# cat index.php
<?php
  phpinfo();
?>
[root@westosb html]# dnf  install php.x86_64 -y   安装php
[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  ##给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(/.*)?'         ##因为在enforcing模式下,需要修改安全上下文
[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  ##看cgi文件是否可以运行
Content-type: text/html

Sat Jul 31 15:32:54 CST 2021    ##正常显示date信息
[root@westosb cgi]# vim /etc/httpd/conf.d/vhosts.conf
//编写内容
44 <Directory "/var/www/html/cgi">
 45  Options +ExecCGI
 46  AddHandler cgi-script .cgi
 47 </Directory>
//
[root@westosb cgi]# systemctl restart httpd

访问成功:

 python语言

wsgi
[root@westosb cgi]# dnf install python3-mod_wsgi.x86_64 -y  ##下载python3-mod_wsgi.x86_64
[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  ##主配置文件
//编写内容
<VirtualHost *:80>
 25 ServerName wsgi.westos.org
 26 WSGIScriptAlias / /var/www/html/index.wsgi
 27 </VirtualHost>
//
[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')])  ##*注意缩进2空格
  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
//

访问成功:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值