# Installing Apache, PHP, and Perl

## supster

I'de like to install Apache with support for PHP and Perl

I notice whith

```
emerge --pretend apache mod_php mod_perl mod_ssl
```

It will try to install both Apache2 and Apache 1.3.

Whats the problem and how can I fix it? Through searching the forums I heard that mod_perl doesn't work with Apache2, so I suppose 1.3 is the path I need to go down, right?

----------

## jmusits

You will need to mask Apache 2

```
# echo '>=net-www/apache-2.0' >> /etc/portage/package.mask
```

should do it.

Jason

----------

## jabber

Sure you can install Apache2 without installing Apache 1.3.  For mod_perl you need the 1.99.x version instead of the 1.29 version.

You may need to do this in multiple steps so you only emerge what you need.

Try:

```
 emerge -pv =apache-2.0.49 
```

For the mod_perl you will need to use the development version:

```
 ACCEPT_KEYWORDS="~x86" emerge -pv =mod_perl-1.99.11 
```

Then add in the other modules you want to emerge.

I suspect that you will have some trouble with mod_perl working the way you want -- seems like most people do.  I've been working for a few days getting mod_perl-1.99.11 to work the way I need it to (I needed to add an additional flag within the ebuild to keep backwards compatibility with my mod_perl 1 system).

----------

## supster

Thanks for the help, I don't really care for Apache2 so I'll just follow jmusits's suggestion, it seems like I'll have a greater chance of getting Perl to work that way.

Is there anything else I need to do to get Apache to load the Perl module or to know to parse .cgi files with Perl?

edit: /etc/portage/ doesn't seem to exist, I did find /usr/portage/profiles/package.mask though, is that what you were refering to?

----------

## jmusits

You will just need to tell apache to load mod_php, mod_ssl, and mod_perl when it starts up.  Do this by changing this line in /etc/conf.d/apache

```
APACHE_OPTS="-D SSL -D PHP4 -D PERL"
```

and adding these lines to /etc/apache/conf/apache.conf

```

<IfDefine PHP4>

LoadModule php4_module    extramodules/libphp4.so

</IfDefine>

<IfDefine PERL>

LoadModule perl_module          extramodules/libperl.so

</IfDefine>

<IfDefine PHP4>

AddModule mod_php4.c

</IfDefine>

<IfDefine PERL>

AddModule mod_perl.c

</IfDefine>

Include  conf/addon-modules/mod_php.conf

```

and these lines in /etc/apache/conf/commonapache.conf

```

<IfModule mod_perl.c>

    PerlModule Apache::Registry

    

    #set Apache::Registry Mode for /perl Alias

    <Location /perl/*.pl>

        SetHandler perl-script

        PerlHandler Apache::Registry

        Options -Indexes ExecCGI

        PerlSendHeader On

    </Location>

    

    #set Apache::PerlRun Mode for /cgi-perl Alias

    <Location /cgi-perl/*.pl>

        SetHandler perl-script

        PerlHandler Apache::PerlRun

        Options -Indexes ExecCGI

        PerlSendHeader On

    </Location>

</IfModule>

<IfModule mod_php4.c>

AddType  application/x-httpd-php         .php .php4 .php3 .phtml

AddType  application/x-httpd-php-source  .phps

</IfModule>

```

You might not have to make all these changes some might already be there, I not sure, so I just included everything.  Also I remember there being some scripts to automate this, but they did not work for me.  

Hope this helps.

Jason

----------

## jmusits

Sorry I forgot this in my previous post, you will need to create /etc/portage

Jason

----------

## supster

Hey thanks, I really aprecieate you trying to help me get this setup.

I added what you said but get this when trying to start Apache:

```

 * Starting apache...

[Fri Apr  2 09:17:52 2004] [warn] module mod_php4.c is already added, skipping

[Fri Apr  2 09:17:52 2004] [warn] module mod_perl.c is already added, skipping

Syntax error on line 3 of /etc/apache/conf/addon-modules/mod_php.conf:

Invalid command 'AddType', perhaps mis-spelled or defined by a module not included in the server configuration                                            [ !! ]

```

I can start Apache using the default config files, and PHP works then, but Perl doesn't. I get a 403 Forbidden error when trying to access a .cgi file. Any idea whats going on? I thought something along the lines of the perl and php modules are already being called somewhere else before what I added is ran, searching for php and perl in the config files shows up this in commonapache.conf:

```

<IfModule mod_perl.c>

    <Location /perl-status>

   SetHandler perl-script

   PerlHandler Apache::Status

   Order deny,allow

   Deny from all

   Allow from 127.0.0.1

   #Allow from .your_domain.com

    </Location>

</IfModule>

... and ...

<IfModule mod_perl.c>

    <Directory /home/*/public_html/perl>

   SetHandler perl-script

   PerlHandler Apache::PerlRun

   Options -Indexes ExecCGI

   PerlSendHeader On

    </Directory>

</IfModule>

```

Oh, and my perl scripts are pointing to /usr/bin/perl, I'm pretty sure thats right.

edit: I tried putting the script in the /cgi-bin directory rather than just htdocs, now I get a 500 Internal Server Error while calling the "test-cgi" script from the /cgi-bin folder (or any perl script) rather than the 403 error.

----------

