You are not logged in.

#1 2004-01-30 21:35:48

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

PHP configuration

I've got Apache installed and working, and I've got PHP and MySQL installed. I've scoured httpd.conf, but I don't know what I need to do to get apache to pick up my PHP files.

What I want is to have the public_html file in the home directories serve php pages. I've got it serving pages, but not php yet... I tried fiddling with some extensions and the ExecCGI option, but I can't figure it out...

Thanks,

Dusty

Offline

#2 2004-01-31 04:19:22

rasat
Forum Fellow
From: Finland, working in Romania
Registered: 2002-12-27
Posts: 2,293
Website

Re: PHP configuration

Is the php module untaged in /etc/httpd/conf/httpd.conf

LoadModule php4_module        lib/apache/libphp4.so

If you plan to run php and mysql, did you untag the mysql extension in /usr/etc/php.ini

extension=mysql.so

Markku

Offline

#3 2004-01-31 10:39:04

Bobonov
Member
From: Roma - Italy
Registered: 2003-05-07
Posts: 295

Re: PHP configuration

If you do not have this in your httpd.conf you should add it.

<IfModule sapi_apache2.c>
  DirectoryIndex index.php index.html
  AddType application/x-httpd-php .php .php
  AddType application/x-httpd-php-source .phps
</IfModule>

This tell to the server that if the module is loaded to use index.php as first answer as index of a dir and add the mime type of the php pages.

Offline

#4 2004-01-31 16:14:46

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: PHP configuration

Somebody would tell me why I put this in the networking forum instead of Server?? So tired last night...

I already had those lines and had restarted apache, but it wouldn't work. After rebooting today, PHP was working fine... don't kwnow what I forgot to reinit before.

Now I'm having trouble with MySQL. I ran /etc/rc.d/mysqld start, but when I try to connect, I get:

ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

The daemon isn't running, according to ps -A|grep mysqld. When I run mysqld start, it says done, but if I subsequently run stop, it fails. I don't know how te find out what is wrong. /var/log/mysqld.log is empty.

Oh, also, the first time I tried to run it, it said it that /usr/bin/resolveip couldn't resolve my host name or localhost. It's resolving localhost all right; I tried it, but it isn't resolving my host name. Is that causing the error? Why did that error message stop coming up when I run mysqld  start?

I've never had trouble with MySQL before. I assume it's because I'm not to bright when it comes to finding and reading configuration files...

Thanks,
Dusty

Offline

#5 2004-01-31 16:34:29

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: PHP configuration

I forgot to search the forum but... I did just try everything at this thread:

http://bbs.archlinux.org/viewtopic.php?t=1361

And It's still not working. sad

Sarah was right. I've never had a distro make such a fool of me before. :-D

Dusty

Offline

#6 2004-01-31 16:51:04

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: PHP configuration

Had to run mysql_install_db AND chmod mysql.mysql the files that it created. It's working now, Sarah was only part right and I'm only a little slow. *sigh*

Dusty

Offline

#7 2004-01-31 22:49:09

Moo-Crumpus
Member
From: Hessen / Germany
Registered: 2003-12-01
Posts: 1,487

Re: PHP configuration

Could you express it more precise? What did you do? Php mysql and apache is one of the things I have to do, 2.


Frumpus addict
[mu'.krum.pus], [frum.pus]

Offline

#8 2004-02-01 01:39:29

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: PHP configuration

Here's what works for me. Mostly this is shamelessy stolen from rasat's post in the link above, but I made a lot of alterations, removing stuff that isn't necessary with the latest apache, changing some stuff... if there is a problem, try comparing it to that link.

INSTALL:
pacman -S apache
pacman -S php
pacman -S mysql

APACHE:
1. Uncomment the following line in /etc/httpd/conf/httpd.conf :
it[/i]

#LoadModule php4_module /usr/lib/apache/libphp4.so

2. Add line in /etc/host :

127.0.0.1  localhost.localdomain   localhost

Or if you want a different hostname:

127.0.0.1  localhost.localdomain   localhost myhostname

3. Edit /etc/rc.conf :
If you set a hostname in step two, the hostame variable should be the same. otherwise localhost:

#
# Networking
#
HOSTNAME="localhost"

4. Run in terminal (root):

$ /etc/rc.d/httpd start


5.  Apache should now be running. Test by going to http://localhost/ in a web browser.

6. Edit /etc/rc.conf  (to start Apache at boot):

Daemons=(some daemons now add httpd)

OR add this line in rc.local:

/etc/rc.d/httpd start 

7. If you want user directories (ie: ~/public_html on the machine is accessed as http://localhost/~user/) to be available on the web, uncomment the following lines in /etc/httpd/conf/httpd.conf:

UserDir public_html

and

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>

PHP:
1. Edit /usr/etc/php.ini and uncomment the following line:

;extension=mysql.so

2. Uncomment these lines in /etc/httpd/conf/httpd.conf:
(I think they were commented out...)

<IfModule sapi_apache2.c>
  DirectoryIndex index.php index.html
  AddType application/x-httpd-php .php .php
  AddType application/x-httpd-php-source .phps
</IfModule>

3. Test PHP with a simple script:

<html>
This is a test. Say hello to Arch:
<p>
<body>

<?php
$myvar = "Hello Arch Linux";
echo $myvar;
?>

</body>
</html>

Save the file as "test.php" and copy to /home/httpd/html/ or to ~/public_html if you permitted such a configuration.

Test PHP:
http://localhost/test.php
or
http://localhost/~myname/test.php

MySQL:
1. Run in terminal (root)
$ mysql_install_db
$ chown -R mysql.mysql /var/lib/mysql

2. Run in terminal:
$ /etc/rc.d/mysqld start

3. test mysql. as root, login:

$ mysql

4. Create root password for mysql:
mysqladmin -u root password 'roots_password'

5. Add mysqld to the list of daemons in /etc/rc.conf
OR Add this line in /etc/rc.local (to start at boot):

/etc/rc.d/mysqld start

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

Hope it helps and works. smile

Dusty

Offline

#9 2004-02-01 04:41:46

rasat
Forum Fellow
From: Finland, working in Romania
Registered: 2002-12-27
Posts: 2,293
Website

Re: PHP configuration

Dusty wrote:

Hope it helps and works. smile

Nice!! Keep it updated with the "edit" function. There is a link in the FAQ & LP topic:
http://bbs.archlinux.org/viewtopic.php?t=2250


Markku

Offline

#10 2004-02-01 05:38:52

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: PHP configuration

"Nice!"??  The nice part was all your work. the rest was just a hack.

I hadn't seen The Wiki links page... what a good idea!

If anybody has advice or suggestions, PM me and I can edit the post above. Or repost it as Wiki in another topic... (In Server User, rather than networking...)

Dusty

Offline

#11 2004-02-01 08:16:01

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: PHP configuration

Dusty wrote:

2. Add line in /etc/host :

127.0.0.1  localhost.localdomain   localhost

3. Edit /etc/rc.conf :

#
# Networking
#
HOSTNAME="localhost"

If you want, you can change the hostname to whatever you want.  Just make sure you have that whatever listed on the /etc/hosts line.

ex:

2. Add line in /etc/host :

127.0.0.1  localhost.localdomain   localhost googlepoo

3. Edit /etc/rc.conf :

#
# Networking
#
HOSTNAME="googlepoo"

I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#12 2004-02-01 08:50:03

Moo-Crumpus
Member
From: Hessen / Germany
Registered: 2003-12-01
Posts: 1,487

Re: PHP configuration

this is nice. thank you.


Frumpus addict
[mu'.krum.pus], [frum.pus]

Offline

#13 2004-02-01 17:13:56

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Offline

#14 2009-11-07 14:48:23

corstar
Member
From: Perth, Western Australia
Registered: 2008-05-05
Posts: 27
Website

Re: PHP configuration

Thanks so much.

Looked everywhere for a solution to RROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


your solution worked perfectly.

Offline

#15 2009-11-07 14:50:11

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,395
Website

Offline

Board footer

Powered by FluxBB