2016-07-27 4 views
0

私のubuntuバージョンは15.04です。 は、私は、サーバーを構成するための手順に従っ:ブラウザは.plファイルを実行する代わりにダウンロードしようとしています - apache2、perl cgi scripts、ubuntu

  1. 須藤はapt-getをapache2のインストール
  2. 須藤はapt-getをインストールとlibapache2-MOD-perl2
  3. 須藤はapt-getをperlのデバッグに
  4. sudoをインストールapt-getのインストールとlibapache2-MOD-perl2-devの
  5. 須藤はapt-getをインストールとlibapache2-要求-perlのlibdatetime-perlの
  6. ます。mkdirは/ var/www /のCGI-binに
  7. <VirtualHost *:80> 
    # The ServerName directive sets the request scheme, hostname and port that 
    # the server uses to identify itself. This is used when creating 
    # redirection URLs. In the context of virtual hosts, the ServerName 
    # specifies what hostname must appear in the request's Host: header to 
    # match this virtual host. For the default virtual host (this file) this 
    # value is not decisive as it is used as a last resort host regardless. 
    # However, you must set it for any further virtual host explicitly. 
    #ServerName www.example.com 
    
    ServerAdmin [email protected] 
    DocumentRoot /var/www/ 
    
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
    # error, crit, alert, emerg. 
    # It is also possible to configure the loglevel for particular 
    # modules, e.g. 
    #LogLevel info ssl:warn 
    
    
    < Files ~ "\.(pl|cgi)$"> 
    SetHandler perl-script 
    PerlResponseHandler ModPerl::PerlRun 
    Options +ExecCGI 
    PerlSendHeader On 
    < /Files> 
    
    
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/ 
    
    < Directory /var/www/cgi-bin/> 
    AllowOverride None 
    Options ExecCGI -MultiViews +SymLinksIfOwnerMatch 
    AddHandler cgi-script cgi pl 
    Order allow,deny 
    allow from all 
    </Directory> 
    
    
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
    
    # For most configuration files from conf-available/, which are 
    # enabled or disabled at a global level, it is possible to 
    # include a line for only one particular virtual host. For example the 
    # following line enables the CGI configuration for this host only 
    # after it has been globally disabled with "a2disconf". 
    #Include conf-available/serve-cgi-bin.conf 
    </VirtualHost> 
    
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 
    
  8. /etc/apache2/sites-available/000-default.conf

    #!/usr/bin/perl -w 
    print "Content-type: test/html\r\n\r\n"; 
    print "Hello there!<br/>\nJust Testing. <br/>\n"; 
    
    for ($i=0; $i<10;$i++) 
    { 
    print $i."<br/>"; 
    } 
    
  9. のchmod A + X perltest.pl

  10. 編集perltest.pl

    ナノ/ etc/apache2/sites-available/default-ssl.confファイルはhere(行5-11)です。

  11. /etc/apache2/sites-enabled/000-default.confファイルはです(ライン12-37)
  12. ファイル/etc/apache2/apache2.conf nanoに行を追加しますが、here(ライン - (54から78))であるブラウザで
  13. は、http://127.0.0.1/cgi-bin/perltest.pl

を襲った。しかし、ブラウザがファイルをダウンロードします。 問題を理解できません。助けてください。

答えて

0
print "Content-type: test/html\r\n\r\n"; 
         ^
         Here is your problem 

print "Content-type: text/html\r\n\r\n";

後藤のルートで、次のコマンド

/etc/init.d/apache2 restart

であなたのマシンでApacheサーバを再起動する必要があります
関連する問題