Ubhuntu下安装配置Apache2 Perl cgi-bin
来源:互联网 发布:风暴大陆各种进阶数据 编辑:程序博客网 时间:2024/06/16 14:04
首先安装sudo apt-get install libperl-dev
去http://httpd.apache.org/download.cgi#apache22下载httpd
安装方法:./configure make make install
这样你的apache2就安装到了/usr/local/apache2下.
cd /usr/local/apache2/bin
sudo ./apachectl start
在地址栏输入127.0.0.1,发现“It works!",页面的内家取决于htdocs/index.html的内容。
任何地方都可以调用apachectl
sudo vim /root/.bashrc
export PATH="$PATH:/usr/local/apache2/bin"
vim ~/.bashrc
export PATH="$PATH:/usr/local/apache2/bin"
设置开机自动启动Apache
在/etc/init.d下建立一个shell文件apache
#!/bin/bash
/usr/local/apache2/bin/apachectl start
$chmod +x apache
在/etc/rc5.d下建立一个指向apache的软链接
$ln -s /etc/init.d/apache S20apache
因为rc(0--6,S).d下的文件是在系统启动后自动执行的嘛,另外rc(0--6,S).d下文件名的命名规则:以S开头是启动,以K开关不是启动。注意rc.d下建立的软件链接指向的文件必须是/etc/init.d下的文件。
最后执行update-rc.d apache defaults
详细内容参加rc5.d下面的README文件。
实际上开机自动启动还有另外一种简单的方式:System==>Preference==>Startup Applications
在/usr/local/apache2/cgi-bin下已经给了个测试程序test-cgi,我们在地址栏是输入127.0.0.1/cgi-bin/test-cgi发现“Internal Server Error",出现这个问题有三种原因:
- 找不到脚本解释器。shell的话第一行就用#!/bin/sh,Perl的话第一行就用#!/usr/bin/perl
- 脚本语法有误
- 权限问题。从浏览器中访问apache服务器文件的用户默认组别是"Nobody",执行sudo chmod 755 test-cgi就解决问题了。
sudo chmod 777 /usr/local/apache2/cgi-bin
在cgi-bin下新建一个文件hello.pl
#!/usr/bin/perl
print "Content-type: text/html";
print "Hello, World.";
$chmod 755 hello.pl
在浏览器地址栏输入http://localhost/cgi-bin/hello.pl测验一下。
下面给一个正式的CGI代码,也是我做的第一个搜索引擎的demo,具有划时代的意义!
#!/usr/bin/perluse CGI qw(:standard);use Search::Xapian;print header;print start_html(-title=>'ISee Search Engine',-align=>'center');print start_form,textfield('terms'),submit('Search'),p,end_form;print hr;if(param()){my $db = Search::Xapian::Database->new("/home/orisun/master/db2");my $term=param('terms');my $enq = $db->enquire($term);##printf "Running query '%s'\n", $enq->get_query()->get_description();my @matches = $enq->matches(0, 10);print scalar(@matches) . " results found";print br;foreach my $match ( @matches ) { my $doc = $match->get_document(); printf "ID=%d Percent=%d%%<br>%s", $match->get_docid(), $match->get_percent(), $doc->get_data(); print p;}}print end_html;
运行效果:
2、sudo apt-get --purge remove apache2.2-common
3、sudo apt-get autoremove (此命令会自动卸载PHP)
- Ubhuntu下安装配置Apache2 Perl cgi-bin
- Ubhuntu下安装配置Apache2 Perl cgi-bin
- Ubuntu下配置apache2和perl cgi
- Howto:Ubuntu下配置apache2和perl cgi
- apache2.2+perl/cgi的正确配置
- ubuntu下apache2 安装 配置 卸载 CGI设置 SSL设置
- ubuntu下apache2 安装 配置 卸载 CGI设置 SSL设置
- Tomcat下配置Perl CGI
- Ubuntu下Apache2的CGI简单配置
- ubuntu16.04下apache2如何配置CGI
- Ubuntu下Apache2的CGI简单配置
- linux+apache2.52+cgi(perl)
- Apache2.2配置CGI
- apache2 配置cgi
- 配置安装转载网上的 Apache2 + Gitweb+CGI配置
- Ubuntu 14.02下编译及配置apache2.4(python CGI)
- Tomcat 配置CGI perl
- ubuntu14.04 apache2+python cgi安装与配置
- 重装ubuntu后要做的几件事情
- nothing to be done for all
- libmmseg
- Omega Overview
- Ubuntu11.04上LAMP的安装
- Ubhuntu下安装配置Apache2 Perl cgi-bin
- 微软学术搜索新特征暴光
- Linux上安装使用boost入门指导
- Perl类、CGI和DBI编程
- ISee搜索引擎
- Perl HTML::TreeBuilder模块讲解
- Perl解析当当网图书信息页面
- Perl爬虫--爬特定内容的网页
- Can't locate Tk.pm