# HOWTO: phpmyadmin + lighttpd on gentoo

## geta

UPDATE 2006-02-08:

As of sometime between originally writing this documentation and now there have been some changes to the phpmyadmin ebuild. It now installs php version 5 as a dependency. There is a new howto further down. I'll leave the old one in place for reference.

This tutorial is based on http://stateless.geek.nz/2005/06/27/debian-lighttpd-and-phpmyadmin/. It takes you through the gentoo-specific install steps and also tells you something about the configuration needed.

Note on webapps on gentoo

---------------------------------

Note to users - like me - who are not used to the gentoo way of handling webapps (such as phpmyadmin, typo3, mambo etc.): any webapp has two installation steps which are *automatically* handled by the ebuild:

- first install any webapp to /usr/share/webapps

- then use the utility webapp-config to copy the webapp to any virtual hosts on your machine. type "man webapp-config" to get more info on webapp-config. it really looks cool.

1. Installation

---------------

- install mysql if you haven't done so yet (AND set a mysql root password - you're probably planning on running a webserver - if not, do it anyway)

- install lighttpd: "emerge -av lighttpd"

- then install php-cgi: "emerge -av php-cgi". if you try emerging phpmyadmin first, it will install apache along as a dependency, which in this scenario, we want to avoid.

- you can now install phpmyadmin: "emerge -av phpmyadmin". Follow the instructions printed out by "emerge" to add some phpmyadmin-specific information to the mysql-database

2. Configuration

-------------------

Now you have phpmyadmin and lighttpd installed, you will have to configure /etc/lighttpd.conf:

- In the section "server.modules" uncomment "mod_alias" and "mod_fastcgi"

- Then uncomment the section "fastcgi.server". In that section change the path /usr/local/bin/php to /usr/bin/php-cgi

- Then add your own section (anywhere in the file):

```
alias.url =("/phpmyadmin/" => "/var/www/localhost/htdocs/phpmyadmin/")
```

The path in this section might not be the correct path for your machine. To check where phpmyadmin is installed on your machine, run: "webapp-config --list-installs phpmyadmin"

3. Running phpmyadmin

----------------------------

start lighttpd: "/etc/init.d/lighttpd start"

open your favourite browser and type in the url: http://localhost/phpmyadmin

Cheers,

geta

----------

## MikeD

Great tutorial.  I was just looking for something like this the other day.

----------

## COiN3D

Hello,

interesting tutorial. Btw, I've another question. On the lighttpd website is a tutorial how to organize the vhosts with mysql. Have you tried that tutorial out? Unfortunately, lighttpd refused to start after trying out the tutorial.

----------

## geta

 *COiN3D wrote:*   

> On the lighttpd website is a tutorial how to organize the vhosts with mysql. Have you tried that tutorial out? Unfortunately, lighttpd refused to start after trying out the tutorial.

 

Sorry mate, can't help you out on that problem. I've never done this before and I couldn't find the tutorial (the lighttpd website is quite unorganised once you start scratching beneath the surface). Maybe you'll have more luck if you open a new thread about your problem. Please don't forget to include the link to the tutorial and a copy/paste of the error message from lighty (there must be an error message). It's always easier to analyse a problem with more information  :Smile: 

Cheers,

geta

----------

## tunapants

Hi -- Thanks for the tutorial.

I just wanted to add that when I followed it initially, my php-cgi wasn't configured with mysql support. This gave me some grief.

I had to enable the "mysql" USE flag for the php-cgi emerge and all went well after that.

Just in case anyone else is getting any error messages when they attempt to access mysql with php-cgi. Make sure mysql support is actually enabled.

----------

## geta

 *tunapants wrote:*   

> Hi -- Thanks for the tutorial.
> 
> I just wanted to add that when I followed it initially, my php-cgi wasn't configured with mysql support. This gave me some grief.
> 
> I had to enable the "mysql" USE flag for the php-cgi emerge and all went well after that.

 

I've had the same sort of problem again and again. The best solution (without remerging) is to:

emerge mysql

emerge php-cgi

emerge lighttpd

You will then have php with mysql support, lighttpd with php and mysql support, provided you haven't set "-mysql" or "-php" in make.conf. Just using "emerge mysql php-cgi lighttpd" didn't work for me, so there is some dependency information that is updated after an emerge has completed.

Cheers,

geta

----------

## geta

This tutorial is based on http://stateless.geek.nz/2005/06/27/debian-lighttpd-and-phpmyadmin/. It takes you through the gentoo-specific install steps and also tells you something about the configuration needed.

Note on webapps on gentoo

---------------------------------

Note to users - like me - who are not used to the gentoo way of handling webapps (such as phpmyadmin, typo3, mambo etc.): any webapp has two installation steps which are *automatically* handled by the ebuild:

- first install any webapp to /usr/share/webapps

- then use the utility webapp-config to copy the webapp to any virtual hosts on your machine. type "man webapp-config" to get more info on webapp-config. it really looks cool.

---

1. Mysql, PHP5 without apache2 and lighttpd (further notes on the emerge order see section caveats below)

---

- install mysql if you haven't done so yet (AND set a mysql root password - you're probably planning on running a webserver - if not, do it anyway)

- install lighttpd: "emerge -av lighttpd" lighttpd automatically detects mysql and compiles in support for it.

- set use flags to install php5 - avoiding apache2, "useless" db systems and crypto (removing many dependencies):

```
dev-lang/php -apache2 -berkdb cgi -crypt -gdbm session -truetype
```

You can also set USE="-apache2" in /etc/make.conf to avoid apache2 support on the whole system (if you're running lighttpd this is probably what you want anyway)

- install php version 5: "emerge -av dev-lang/php"

---

2. webapp-config for lighttpd and phpmyadmin

---

- webapp-config uses apache2 as the default web server. To change this we have to edit one line in the config file, so we first "emerge -av webapp-config" and then set the following value in /etc/vhosts/webapp-config: 

```
vhost_server="lighttpd"
```

- you can now install phpmyadmin: "emerge -av phpmyadmin". Follow the instructions printed out by "emerge" to add some phpmyadmin-specific information to the mysql-database

---

3. Configuration

---

Now you have phpmyadmin and lighttpd installed, you will have to configure /etc/lighttpd.conf:

- In the section "server.modules" uncomment "mod_alias" and "mod_fastcgi"

- Then uncomment the section "fastcgi.server". In that section change the path /usr/local/bin/php to /usr/lib/php5/bin/php-cgi

---

4. Running phpmyadmin

---

start lighttpd: "/etc/init.d/lighttpd start"

open your favourite browser and type in the url: http://localhost/phpmyadmin

---

5. Caveats

---

Somehow I've discovered a sort of "dependency hell" situation in stable gentoo. Lighttpd has support for php (4), phpmyadmin installs php(5) as a dependency, but because php(4) and php(5) are in different locations in the portage tree this causes hickups, when reinstalling lighttpd: Lighttpd somehow recognises that php is installed (probably through eclasses), and as a consequence sets the php USE flag on lighttpd. Because of different package tree locations it wants to reinstall php(4) which is blocked by php(5). So beware if installing php(5) before lighttpd, set USE="-php" on lighttpd. If you're using php-cgi (which you're doing if you followed my instructions) you can use php without activating support for it directly in lighttpd.

EDIT: This problem is already in bugzilla. See: https://bugs.gentoo.org/show_bug.cgi?id=121653

Cheers,

geta

----------

## Doubleletter

This was most helpful. Thank you

----------

## eyebex

After following geta's tutorial (thanks) I'm having trouble with phpmyadmin's cookie authentication: I'm accessing the server running phpmyadmin over a public Internet IP (http://<IP>/phpmyadmin/), but after pressing OK on the login page, phpmyadmin forwards me to "http://localhost/phpmyadmin/index.php?token=...". I would have expected to be forwarded to "http://<IP>/phpmyadmin/index.php?token=...". "http" authentication works fine, by the way. Any ideas?

----------

## eyebex

Got it, I was missing $cfg['PmaAbsoluteUri'] in my phpMyAdmin config which obviously needs to be set although it's missing in the sample configuration ...

----------

## steveL

Nice post geta; one thing tho: you can just edit the original post to bring it up to date, no need to repost the whole thing with amendments or additions. (It's conventional to put a last modified date in the OP, or a version on the subject.) You can bump the thread at the same time with a small new post.

HTH.

edit: doh didn't realise this was a necrothread ;)

----------

