# MiniHowto: Hints on Drupal (PHP+MySQL)

## YsndHalf

Hi people,

I want to share with you my experience with Drupal (on Gentoo). By the way, I think that Drupal is an *excellent* CMS (Content Management System), with lots of options and modules.

I have a webserver (Apache2, MySQL, Drupal and PHP) in a Gentoo box on a Pentium-II 450MHz 256MB RAM. I made a clean installation of Gentoo, including the several packages for this server to work OK. I was really, really happy with it (it ran for ~3 months with absolutely no problem and no reboot, with a smooth service).

Then I wanted to update a couple of things, since I had detected some problems in my Drupal web. More specifically, it requested some "iconv", "GNU recode" or "mbstring" in order to correctly convert some RSS feeds (from ISO-8859-15 charcode and so on).

I made an "emerge --sync", and tried "emerge -pvu php". I saw that there were many "USE" options, including "iconv", and I also saw the required updates of MySQL and Apache (among others).

I thought that it could be a good idea to take the chance to include other options as well. More specifically, "threads" (affecting both Apache and PHP) and some XML libraries.

For more details, I updated to MySQL 4.1.20 from 4.1.14, Apache 2.0.58-r2 from 2.0.55-r1, and PHP 5.1.4-r4 from 5.1.2.

My USE flags in /etc/make.conf were:

USE="-gtk -gtk2 -gnome -arts -alsa X qt kde -dvd -cdr -dvdr -3dnow mmx -pcmcia lm_sensors mysql php apache2 maildir spamassassin qmail -ipv6 ipalias fam nls -milter imap session gd ssl"

(I also have a mail server there)

I launched the command, and at the end I preferred rebooting the system (for the first time in 3 months). After reboot, I only found errors and more errors in my Drupal website! Furthermore, other pages (outside Drupal, only requiring Apache) were loading extremely slow.

And these are the reasons that I finally found:

* After re-emerging MySQL with the USE="latin1" flag activated, Drupal worked again. I guess that it's because I don't have UniCode at all. This flag was added to MySQL somewhere between versions 4.1.14 and 4.1.20. Please be aware!

* Emerging Apache (and PHP) with the USE="threads" option leads to a much slower load of the webpages. I guess that in an Hyperthreading computer it may run fine, but in that Pentium-II not. Maybe I should tune the servers and threads in /etc/apache2/httpd.conf, but even testing a couple of different values the system didn't go fine. Re-emerging Apache+PHP without "threads" it was fast again.

[EDIT: Sorry! I've just realized that I had written USE="flags" instead of USE="threads". Corrected...]

* It seems that Drupal (at least in 4.6.8 ) has a slow Locale table. You can really speedup the system by creating an index there, issuing the following command in MySQL: 

```
ALTER TABLE `locales_source` ADD INDEX `idx_source`(`source`(20));
```

* You can also check the optimization of the Drupal DB with "mysqloptimize".

* I have "dev-php5/eaccelerator" emerged in my system, for speeding up Drupal. After updating (or re-emerging) PHP, you *must* re-emerge eaccelerator as well.

If you wish you can check the final result in http://www.seti.cat. Please remember that this website runs in a Pentium-II 450MHz 256MB RAM, and that the webpages are dynamically generated by Drupal. It doesn't look bad, isn't it?  :Wink: 

I hope that you find useful these few hints.

Regards,

              Jordi    :Cool: 

----------

## frostschutz

How do you install Drupal in the first place?

----------

## YsndHalf

Hi frostschutz,

...you simply have to type

```
emerge drupal
```

...and that's it!  :Wink: 

Well, actually it's a bit mor complex than this:

Drupal is a "masked" package (BTW, I don't know why... Maybe some security issue?). Hence, you have to "unmask" it.

One way to do it is typing the following before you emerge drupal: 

```
export ACCEPT_KEYWORDS="~x86"
```

Or even doing 

```
ACCEPT_KEYWORDS="~x86" emerge drupal
```

But as correctly indicated in this post, this would lead to the installation of *all* the unstable versions of the dependencies (not only drupal). Therefore, it's better to include the following line to /etc/portage/package.keywords (if you don't have this file you can create it): 

```
www-apps/drupal ~x86
```

This will be specially useful if you wish to update drupal some time later. This is obviously applicable to any other unstable packages as well.

Ah, and you also have to follow some additional configuration options at the end! I think that when Drupal gets emerged you see some messages explaining this. You'll have to create a MySQL DB, access some PHP configuration file of Drupal, etc. Are you familiar with MySQL?

Let me recommend you to save all of the Portage messages, since maybe you'll have to do some operations with MySQL, etc. as well. I.e., you can do 

```
emerge --quiet drupal >out.txt 2>err.txt &
```

 and you can even keep working. When the system finishes you can check for all the relevant messages in the output files (be patient, they can be huge despite of the "--quiet" switch).

I still have the relevant messages appeared in my Drupal installation. I post them here for your information:

 *Quote:*   

> 
> 
> ***** AFTER EMERGING MYSQL: *****
> 
>  * Using default DATADIR
> ...

 

Finally, remember to check http://www.drupal.org for additional configuration steps (they could have changed since my installation).

Kind regards,

              Jordi    :Cool: 

----------

## frostschutz

I use Drupal on my webhost for a small site, but couldn't get it to run locally in Gentoo, which would allow me to worry less about experimenting with it. Let's see if I can make it work with your description. Thank you very much for the verbose description in any case.  :Smile: 

EDIT: Thanks again, Drupal is up and running now (with the help of your description and a little Gentoo Wiki Voodoo)

----------

