
四、支持PHP
配置httpd以使用PHP脚本
[1] 安装PHP.
[root@linuxprobe ~]# yum -y install php php-mbstring php-pear [root@linuxprobe ~]# vi /etc/php.ini # line 878: 取消注释,设置时区 date.timezone = "Asia/Shanghai" [root@linuxprobe ~]# systemctl restart httpd
[2] 创建一个PHP测试页面,并使用Web浏览器从客户端PC访问它。如果显示以下页面,它是确定。
[root@linuxprobe ~]# vi /var/www/html/index.php
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
<?php
print Date("Y/m/d");
?>
</div>
</body>
</html>

[3] 创建phpinfo测试页,确认是都开启php支持
[root@linuxprobe ~]# echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

五、支持Ruby
配置httpd以将Ruby脚本用作CGI
[1] 安装Ruby.
[root@linuxprobe ~]# yum -y install ruby
[2] 默认情况下,在“/var/www/cgi-bin”目录下允许CGI。
可以使用Perl Scripts放在目录下。然而,它下面的所有文件都被处理为CGI。
# 下面的设置是CGI的设置 [root@linuxprobe ~]# grep -n "^ *ScriptAlias" /etc/httpd/conf/httpd.conf 247: ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
[3] 如果你想允许在其他目录中的CGI,配置如下。
例如,在“/var/www/html/cgi-enabled”中允许。
[root@linuxprobe ~]# vi /etc/httpd/conf.d/cgi-enabled.conf # create new # processes .rb as CGI scripts <Directory "/var/www/html/cgi-enabled"> Options +ExecCGI AddHandler cgi-script .rb </Directory> [root@linuxprobe ~]# systemctl restart httpd
[4] 如果SELinux被启用,并且允许CGI在不是像上面[3]的默认目录下,更改规则如下。
[root@linuxprobe ~]# chcon -R -t httpd_sys_script_exec_t /var/www/html/cgi-enabled [root@linuxprobe ~]# semanage fcontext -a -t httpd_sys_script_exec_t /var/www/html/cgi-enabled
[5] Create a CGI test page and access to it from client PC with web browser. It's OK if following page is shown.
[root@linuxprobe ~]# vi /var/www/html/cgi-enabled/index.rb #!/usr/bin/ruby print "Content-type: text/htmlnn" print "<html>n<body>n" print "<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">n" print "Ruby Script Test Page" print "n</div>n" print "</body>n</html>n" [root@linuxprobe ~]# chmod 705 /var/www/html/cgi-enabled/index.rb









