# request: Dummy guide on how to get Apache and MySQL to work

## maxmc

I've been trying for 3 days now to get Apache and MySQL to work together with the phpWebsite. All it says is that it can't connect to the database, I've made a phpwebsite user that is a member of both apache and mysql groups. It's also added to the mysql user table with all rights.

What am I doing wrong, it took me like 5 reinstalls of MySQL to get that to work. A step by step from emerging to fully functional apache/mysql communication document would be preferable.

Thanks

----------

## pjp

Moved from Other Things Gentoo.

----------

## darktux

 *maxmc wrote:*   

> I've been trying for 3 days now to get Apache and MySQL to work together with the phpWebsite. All it says is that it can't connect to the database, I've made a phpwebsite user that is a member of both apache and mysql groups. It's also added to the mysql user table with all rights.
> 
> What am I doing wrong, it took me like 5 reinstalls of MySQL to get that to work. A step by step from emerging to fully functional apache/mysql communication document would be preferable.
> 
> Thanks

 

Post the error you get, that would help. Also, keep in mind that the users on mysql aren't the same as the ones on MySQL.

----------

## rizzo

Most people will tell you to do this:

```
emerge apache mysql mod_php
```

However at the end of mysql and mod_php there are instructions you need to perform.  So do this:

```
# emerge apache mysql (then do mysql instructions)

# emerge mod_php (then do mod_php instructions)

# /etc/init.d/mysql start

# /etc/init.d/apache start
```

Note that you may need to specify if you want apache 1.x or 2.x.  If you are doing 2.x, you need to have "apache2" in your USE flag.  You'll also need "mysql" in your USE flag.

So once you have apache and mysql running, you'll want to create mysql users for phpwebsite:

```
# mysql -uroot mysql

mysql> create database phpws;

mysql> grant all privileges on phpws.* to phpwsuser@localhost identified by 'password_here';

```

Now download and untar phpwebsite into your /home/httpd/htdocs dir (unless you changed DocumentRoot) and point your browser to that webserver dir to begin setup.  I've made an ebuild for phpwebsite 0.9.1 to do that download and untarring but it is held up in committee.

For reference I'm on the phpWebSite dev team and am on #phpwebsite on freenode as rizzo.

----------

## maxmc

 *rizzo wrote:*   

> Most people will tell you to do this:
> 
> So once you have apache and mysql running, you'll want to create mysql users for phpwebsite:
> 
> ```
> ...

 

Ok that was what I was missing. As I understood it phpWebsite would create it's own database if it had the sufficient rights to do so.

Now I got it working, thanks everyone!

----------

## rizzo

 *maxmc wrote:*   

> As I understood it phpWebsite would create it's own database if it had the sufficient rights to do so.

 

Perhaps it will, but to have sufficient rights to create a new database that doesn't already exist means being the root mysql user, and you definitely don't want a web app running around as the root user for anything.   :Wink: 

----------

## spbecker

 *rizzo wrote:*   

> Most people will tell you to do this:
> 
> ```
> emerge apache mysql mod_php
> ```
> ...

 

I've been trying to get this to work lately too, and I just can't figure it out.  I followed the instructions for making a phpwebsite user that you posted above, but I still get "Unable to connect to your server's database.

Please reenter your settings." every time I try to run the install for it.  I'm using mysql 4.0.13 on an SGI Indy (Gentoo/mips).  I've almost come to the conclusion that it may be an issue with mysql...perhaps it doesn't work properly on mips.  Is there a specific version of mysql that phpwebsite works with?

On a side note...I got phpBB to work just fine, but I had to use the root mysql user to do it.  Anything else wouldn't work.

----------

## rizzo

I'm using phpwebsite with mysql 4.0.12 so I don't think 4.0.13 would be a problem.  Were you able to log into mysql as the mysql root user and create the phpws database and user?

----------

## spbecker

 *rizzo wrote:*   

> I'm using phpwebsite with mysql 4.0.12 so I don't think 4.0.13 would be a problem.  Were you able to log into mysql as the mysql root user and create the phpws database and user?

 

Yes, I was able to do this with no problems other than having to add the -p switch to the line you posted above.

----------

## rizzo

Can you paste the contents of your config.php in a code block here?

----------

## spbecker

Hmm, that's interesting...seems it may not even be writing to config.php when I click submit.  It looks default to me:

```
<?php

if ($_GET["print_config"]){

  echo nl2br(htmlspecialchars(config_maker($_GET)));

  exit();

}elseif($_GET["save_config"]){

  echo config_maker($_GET);

  exit();

}

function config_maker($data){

return "<?php

\$dbversion = \"".$data["dbversion"]."\";\n

\$dbhost = \"".$data["hostname"]."\";\n

\$dbuser = \"".$data["username"]."\";\n

\$dbpass = \"".$data["password"]."\";\n

\$dbname = \"".$data["database"]."\";\n

\$table_prefix = \"".$data["tbl_prefix"]."\";\n

\$source_http = \"".$data["http_src"]."\";\n

\$source_dir = \"".$data["filepath"]."\";\n

\$hub_hash = \"".$data["hubhash"]."\";\n

\$install_pw = \"".$data["install_pass"]."\";\n

?>";

}

?>
```

----------

## spbecker

Hmm, I suppose I could just try editing config.php by hand to enter the proper information.  Is that all it takes to get phpwebsite working properly?

----------

## rizzo

That code is what is stored in conf/config.php?  That looks like the function that would print the code to conf/config.php, so if that is what is in conf/config.php that would be an issue.

I assume you are trying with phpWebSite 0.9.1.  Perhaps try the 0.9.2-RC1 that was released last week:

http://prdownloads.sourceforge.net/phpwebsite/phpwebsite-0.9.2-rc1-full.tar.gz?download

----------

## spbecker

 *rizzo wrote:*   

> That code is what is stored in conf/config.php?  That looks like the function that would print the code to conf/config.php, so if that is what is in conf/config.php that would be an issue.
> 
> I assume you are trying with phpWebSite 0.9.1.  Perhaps try the 0.9.2-RC1 that was released last week:
> 
> http://prdownloads.sourceforge.net/phpwebsite/phpwebsite-0.9.2-rc1-full.tar.gz?download

 

Ahh...no...it seems there *is* no conf/config.php at all.  By the way I did try 0.9.2-RC1 and it did the same thing.

----------

## rizzo

So you enter your database/login info and hit submit and it tells you that it created the config.php?  If it can't create the config.php for various reasons it will present you with other options to either cut and paste or save and upload the file.

----------

## spbecker

Actually it says nothing about having created the config.php file.  It just gives an error about not being able to connect the the mysql server (which is up and running btw).   Something I should have mentioned probably is the version of mod_php I'm using.  I don't know if it would affect anything, but I'm using 4.2.3 at the moment.

----------

## rizzo

If you don't have a config.php then it shouldn't even be trying to connect to the mysql server.  It would take you through the setup process to get the database and server information.

What hardware are you on?

----------

## spbecker

It goes to the screen where I have to enter the database information with no problems (database name, database username, password, etc...).  It is only after I hit submit there that it tries to connect to mysql.  The hardware is an SGI Indy (R5000 mips processor, 160mb of ram).

I was thinking of trying a different sql server to see if perhaps mysql is definitely the problem.  I did have to compile mysql with -berkdb use flag because when I used berkdb, it complained something about that arch not supporting fast mutexes whenever I tried to start mysql (don't remember exactly what the error was, but that sounds right).

----------

## rizzo

Oh yeah then it tries to make a test connection to make sure that your login information is correct.

So if I were a betting man I'd say that either:

1. mysql isn't running properly or at all

2. php isn't compiled with mysql support (probably would get a different error first though)

Do you have a phpinfo page that shows that mysql support is enabled?  Should I assume you followed the directions specified earlier in this thread?

----------

## spbecker

 *rizzo wrote:*   

> Oh yeah then it tries to make a test connection to make sure that your login information is correct.
> 
> So if I were a betting man I'd say that either:
> 
> 1. mysql isn't running properly or at all
> ...

 

I do have mysql in my use flags, and I'm pretty sure mysql+php works because I was able to get phpBB working properly with what I currently have installed.  Right now I'm trying to compile mod_php 4.3.1 and see what that does.  Previously I couldn't get anything higher that 4.2.3 to produce a libphp4.so (was a mips issue...but I think that's fixed now).

----------

## spbecker

In an attempt to make sure I didn't do anything stupid, I found out I had done something stupid.  I made a typo when I created the phpwebsite user privileges in mysql, and didn't realize what I had done.  So, in entering the info for the phpwebsite setup, I was typing the username without making the mistake, screwing everything up.

I think it's all working now....thanks for the help  :Very Happy: 

----------

