#安裝apache、MySQL、PHP
yum -y install httpd php mysql mysql-server php-mysql

#安裝apache擴充套件
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

#安裝php擴充套件
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

#安裝mysql擴充套件
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

#設定apache開機時啓動
chkconfig httpd on 

#在服務清單中加入MySQL服務
chkconfig --add mysqld

#設定MySQL服務開機時啓動
chkconfig mysqld on

#啟動apache,網頁根目錄為:/var/www/html
service httpd start

#啟動MySQL
service mysqld start

更改Apache設定,啟用ExecCGI

vim /etc/httpd/conf/httpd.conf

#將Options Indexes FollowSymLinks
#改成Options Includes ExecCGI FollowSymLinks

#將#AddHandler cgi-script .cgi 註解拿掉並加入.pl
#改成AddHandler cgi-script .cgi .pl

#將AllowOverride None
#改成AllowOverride All (允許.htaccess)

重啟apache

service httpd start

#測試cgi是否啟動

vim /var/www/html/test.cgi
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "<html><body>";
print "Hello,World!CGI is working!<br/>";
print "</body></html>";

使用瀏覽器開啟,如有成功顯示Hello,World!CGI is working!(非完整程式碼)即表示成功!

Categories: Linux