# How do I add mysql to php? [SOLVED]

## cwc

Edited after we solved the problem.

The key was to add mysl and mysqli (refer to this post) in the /etc/make.conf and 

add:

dev-lang/php mysql mysqli

dev-lang/php apache2

dev-db/mysql -berkdb innodb other_use_flags

in /etc/portage/package.use

********************************************************************

I've installed apache 2 php and mysql on a testing box. 

Now I'm trying to load the mysql modules with apache with no luck.

Any hints out there?

Here is my make.conf for apache.

APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias proxy"

Here is my php infro dump"

```

Configure Command     './configure' '--prefix=/usr/lib/php5' '--host=i686-pc-linux-gnu' '--mandir=/usr/lib/php5/man' '--infodir=/usr/lib/php5/info' '--sysconfdir=/etc' '--cache-file=./config.cache' '--disable-cli' '--with-apxs2=/usr/sbin/apxs2' '--with-config-file-path=/etc/php/apache2-php5' '--with-config-file-scan-dir=/etc/php/apache2-php5/ext-active' '--without-pear' '--disable-bcmath' '--without-bz2' '--disable-calendar' '--disable-ctype' '--without-curl' '--without-curlwrappers' '--disable-dbase' '--disable-exif' '--without-fbsql' '--without-fdftk' '--disable-filter' '--disable-ftp' '--with-gettext' '--without-gmp' '--disable-hash' '--disable-json' '--with-kerberos=/usr' '--enable-mbstring' '--with-mcrypt' '--without-mhash' '--without-msql' '--without-mssql' '--with-ncurses' '--with-openssl' '--with-openssl-dir=/usr' '--disable-pcntl' '--disable-pdo' '--without-pgsql' '--disable-posix' '--with-pspell' '--without-recode' '--disable-simplexml' '--disable-shmop' '--without-snmp' '--disable-soap' '--disable-sockets' '--without-sybase' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--without-tidy' '--disable-tokenizer' '--disable-wddx' '--disable-xmlreader' '--disable-xmlwriter' '--without-xmlrpc' '--without-xsl' '--disable-zip' '--with-zlib' '--disable-debug' '--enable-dba' '--without-cdb' '--without-db4' '--disable-flatfile' '--with-gdbm' '--disable-inifile' '--without-qdbm' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--disable-gd-jis-conv' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--without-xpm-dir' '--with-gd' '--with-ldap' '--without-ldap-sasl' '--without-mysqli' '--with-readline' '--without-libedit' '--without-mm' '--without-sqlite'

```

----------

## makism

as ./configure indicates, you have no support for mysql in php...

try, emerging php again, with USE="mysql mysqli"

----------

## cwc

No luck.

I emerged apache again with

APACHE2_MODULES="actions alias auth_basic mysql mysqli authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias proxy"

I'm not sure what to do now.  I might have to emerge php again so I get the mysql.so rather than the mysql.dll.

Hmmmm.  Any other ideas?

----------

## tgR10

```
equery u php|grep mysql 
```

if it show somethink like

```
-mysql

-mysqli
```

then you need to reemerge PHP with mysql flag

as he wrote

 *makism wrote:*   

> as ./configure indicates, you have no support for mysql in php...
> 
> try, emerging php again, with USE="mysql mysqli"

 

----------

## xtz

mysql.dll  :Question:   :Exclamation:   :Question: 

----------

## kashani

I would emerge -pv php and make sure that you see mysql and mysqli USE flags are turned on. Then emerge php. Emerging apache again does not affect PHP at all.

kashani

----------

## cwc

 *xtz wrote:*   

> mysql.dll   

 

/etc/php/apache2-php5

;extension=php_ming.dll

;extension=php_msql.dll

;extension=php_mssql.dll

;extension=php_mysql.dll

;extension=php_mysqli.dll

----------

## cwc

 *kashani wrote:*   

> I would emerge -pv php and make sure that you see mysql and mysqli USE flags are turned on. Then emerge php. Emerging apache again does not affect PHP at all.
> 
> kashani

 

I set the flags and emerged php

No luck. I might have to config something.

part of my /etc/make.conf

```

APACHE2_MODULES="actions alias auth_basic mysql mysqli authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias proxy"

USE="apache2 cli crypt gdbm iconv ipv6 kerberos ldap ncurses nls pcre readline reflection session spell spl ssl truetype unicode xml zlib -adabas -bcmath -berkdb -birdstep -bzip2 -calendar -cdb -cgi -cjk -concurrentmodphp -ctype -curl -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -exif -fastbuild -fdftk -filter -firebird -flatfile -force-cgi-redirect -frontbase -ftp -gd -gd-external -gmp -hash -imap -inifile -interbase -iodbc (-java-external) -json -kolab -ldap-sasl -libedit -mcve -mhash -msql -mssql -mysql -mysqli -oci8 -oci8-instant-client -odbc -pcntl -pdo -pic -posix -postgres -qdbm -recode -sapdb -sharedext -sharedmem -simplexml -snmp -soap -sockets -solid -sqlite -suhosin -sybase -sybase-ct -sysvipc -threads -tidy -tokenizer -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -yaz -zip -zip-external tk"

```

----------

## kashani

what is the output of emerge -pv php and have you restarted apache since you rebuilt php?

kashani

----------

## zyko

Is APACHE2_MODULES the same as USE? Make sure to set the right USE flags for dev-lang/php in addition to APACHE2_MODULES.

What's the output of "emerge -pvt php"?

----------

## cwc

 *kashani wrote:*   

> what is the output of emerge -pv php and have you restarted apache since you rebuilt php?
> 
> kashani

 

Yes I've restart Apache. Here's my

# emerge -pvt php

```

These are the packages that would be merged, in reverse order:

Calculating dependencies... done!

[ebuild   R   ] dev-lang/php-5.2.6-r1  USE="apache2 cli crypt gdbm iconv ipv6 kerberos ldap ncurses nls pcre readline reflection session spell spl ssl truetype unicode xml zlib -adabas -bcmath -berkdb -birdstep -bzip2 -calendar -cdb -cgi -cjk -concurrentmodphp -ctype -curl -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -exif -fastbuild -fdftk -filter -firebird -flatfile -force-cgi-redirect -frontbase -ftp -gd -gd-external -gmp -hash -imap -inifile -interbase -iodbc (-java-external) -json -kolab -ldap-sasl -libedit -mcve -mhash -msql -mssql -mysql -mysqli -oci8 -oci8-instant-client -odbc -pcntl -pdo -pic -posix -postgres -qdbm -recode -sapdb -sharedext -sharedmem -simplexml -snmp -soap -sockets -solid -sqlite -suhosin -sybase -sybase-ct -sysvipc -threads -tidy -tokenizer -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -yaz -zip -zip-external" 0 kB 

Total: 1 package (1 reinstall), Size of downloads: 0 kB

 
```

----------

## cwc

 *zyko wrote:*   

> Is APACHE2_MODULES the same as USE? Make sure to set the right USE flags for dev-lang/php in addition to APACHE2_MODULES.
> 
> What's the output of "emerge -pvt php"?

 

At the top of this page I've posted the Apache settings and my 

I'm not sure if I need to use both.  I was following a gentoo.wiki howto.

APACHE2_MODULES=" . . ."

USE=" . . . "

I also posted the emerge -pvt

Thanks to all of you for the help.  I actually enjoy this.  Especially when I get things to work.

----------

## Mad Merlin

 *cwc wrote:*   

>  *kashani wrote:*   what is the output of emerge -pv php and have you restarted apache since you rebuilt php?
> 
> kashani 
> 
> Yes I've restart Apache. Here's my
> ...

 

You have mysql support disabled.

 *cwc wrote:*   

>  *kashani wrote:*   I would emerge -pv php and make sure that you see mysql and mysqli USE flags are turned on. Then emerge php. Emerging apache again does not affect PHP at all.
> 
> kashani 
> 
> I set the flags and emerged php
> ...

 

...and that's why.

Remove the - before mysql on the USE= line in your /etc/make.conf, then emerge php again.

----------

## zyko

There you go, you have "-mysql -mysqli" in your use flags.

Edit your /etc/portage/package.use to use those two flags. You need a line like this in there:

```
dev-lang/php mysql mysqli
```

Then issue emerge -avt php. Notice that your new use flags show up in red now. Then hit y to re-compile php with support for mysql.

----------

## cwc

 *zyko wrote:*   

> There you go, you have "-mysql -mysqli" in your use flags.
> 
> Edit your /etc/portage/package.use to use those two flags. You need a line like this in there:
> 
> ```
> ...

 

Right on!  It worked!

Thanks for the help. Using dev-lang/php mysql mysqli was the key.

*********************************************

I thought using thew following in make.conf would work.  I guess I'm not sure what make.conf does along with package.use.

APACHE2_MODULES = ""

USE =""

----------

## cwc

 *zyko wrote:*   

> There you go, you have "-mysql -mysqli" in your use flags.
> 
> Edit your /etc/portage/package.use to use those two flags. You need a line like this in there:
> 
> ```
> ...

 

I did a man emerge and did not find "-avt".

I also wonder if setting flags in make.conf and including including :

```
dev-lang/php mysql mysqli in /etc/portage/package.use

```

Needed to booth be done.

Thanks again!

----------

## Mad Merlin

make.conf is global (it applies to all packages), while package.use only applies to individual packages ('dev-lang/php mysql mysqli' for example adds the mysql and mysqli USE flags to dev-lang/php only). package.use takes precedence over make.conf, but you only need to set a USE flag once. package.use comes in handy when you want a specific package's USE flags to differ from the global USE flags.

emerge -avt is short for emerge -a -v -t, you should be able to find -a -v and -t in the emerge man page.

----------

## zyko

I would recommend that you always use -avt when you emerge something. 

-v (--verbose) makes emerge print more information.

-t (--tree) arranges items according to dependency structures. Useful to quickly spot which package depends on what.

-a (--ask) shows you what emerge would like to do and then asks if you agree (y/n). This way you can quickly examine use flags etc. before you actually do stuff.

Blindly emerging (without -a or -p) isn't a very smart thing to do. Portage offers you total control, so go ahead and use it. That's what it's all about.

There's more info here: http://gentoo-wiki.com/HOWTO_Use_Portage_Correctly and in the official documentation over at http://gentoo.org/doc/en/ .

----------

## cwc

Thanks to all that helped on this one! This was a big help.  In the past I've used Fedora and Redhat and all the work was done for you which made installation easy but you did not have the speed or control as with Gentoo. With all the help I've got since I started this install in late March (slow learner here) I should be able to start setting up Gentoo boxes in out off line lab at the school I teach at.

This is one of the best Linux Forum in the world!

----------

