php in os x server 10.1

banzai

Registered
hi
i recently installed os x server 10.1. i did it because i thought it would be easy to test my own php scripts with it. i heard that all the webstuff as php, mysql, ... is included in the os x server and can easy be handled by the admin tool. but when i start the webservice and test a php script nothing happens. why? how can i set up the server to run my php scripts? (i am really a newby so please gimme some advice. i couldn't find anything useful on it elsewhere!)

thanks in advance!
 

iFunk

Registered
Under Mac OS X 10.1 Client version, php is installed but not enabled. I haven't seen the server version but I would assume it could be the same issue.

The solution is this:

Take the hash out of the following lines in the httpd.conf file

LoadModule php4_module libexec/httpd/libphp4.so
AddModule mod_php4.c

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

and that should enable it.
 

banzai

Registered
it works fine now. i did all the stuff long before but in the server admin tool i set the MIME type for .php files to 'server parsed' what seemed suitable to me. now i've changed it again to 'application/x-httpd-php' and that's it (i'd better have changed nothing...).

next step: mysql (i think/hope i'll get along with the manual...!)


thanks anyway, banzai:)
 

banzai

Registered
here the 2 step by step descriptions from the apple knowledge base on php/mysql:



first enabling php:

Important, before you begin:
1. You will edit the "httpd.conf" file to enable PHP service for Apache. Follow these steps carefully, and be sure not to change the file in any other way than specifically described.

2. If Apache does not work as expected or fails to start after you have modified the file, you can delete it and replace it with a duplicate of the "httpd.conf.default" file. After making a duplicate of the default, change its name to "httpd.conf" (to match the one you are replacing). Be sure never to modify the original "httpd.conf.default" file.

3. A pound sign (#) in the front of a line indicates that the line will not be read by Apache when starting. Removing pound signs, as described, will cause Apache to read the configuration from that line.

4. Beyond the Knowledge Base, Apple does not offer technical support for configuring or using PHP. See www.php.net for more PHP information.

How to enable PHP

Follow these steps at the server:
1. Choose Log Out from the Apple menu.
2. Type "root" as the login user name. Enter your Admin user password, and log in.
3. Open TextEdit.
4. Choose Open from the File menu.
5. In the Go To field, type: /etc/httpd/
6. Locate and open the file named "httpd.conf".
7. In this file, find the line that reads:

#LoadModule php_module modules/mod_php.so

8. Remove the pound sign (#) from the start of this line. Do not modify the line in any other way.
9. Scroll down until you find the line that reads:

#AddModule mod_php.c

10. Remove the pound sign (#) from the start of this line. Do not modify the line in any other way.
11. Scroll down until you find the lines that read:

#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

12. Remove the pound signs (#) from these lines. Do not modify the lines in any other way.
13. Choose Save from the File menu.
14. Quit TextEdit.
15. Open Server Admin and log in.
16. Stop and restart the Web Server.


You can verify that PHP is working correctly by connecting to the server and loding the "info.php" file. If you have changed the document root or moved this file you, may not be able to do this.

then starting mysql:

Follow these steps to start MySQL at the server:
1. Open the Terminal (Applications/Utilities/).
2. At the prompt (#), type: sudo -s
3. Press Return.
4. Enter the Admin user password when prompted, and press Return.
5. Type: mysql_install_db
6. Press Return.
7. Type: safe_mysqld --user=root &
8. Press Return.
9. Type: exit
10. Press Return. At this point the database will be running.
11. Type: mysqladmin version
12. Press Return.

If MySQL is running properly, you should see a response like:

mysqladmin Ver 8.21 Distrib 3.23.42, for apple-darwin1.4 on powerpc Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license

Server version 3.23.42
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 1 min 37 sec

Threads: 1 Questions: 3 Slow queries: 0 Opens: 5 Flush tables: 1 Open
tables: 0 Queries per second avg: 0.009


Note: After enabling MySQL, you should change your MySQL root password. Note that Apple does not offer free technical support on starting, configuring, or using MySQL.

i hope it helps...!

banzai
 

Essage

Member
I enabled PHP, and it works fine :D

But I have trouble getting MySQL to work.


When I installed MySQL i got the following text:
------------------------------------------------------------
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
ERROR: 1062 Duplicate entry 'localhost-root' for key 1
ERROR: 1062 Duplicate entry 'localhost-root' for key 1
020612 22:08:00 /usr/libexec/mysqld: Shutdown Complete


To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
This is done with:
/usr/bin/mysqladmin -u root -p password 'new-password'
/usr/bin/mysqladmin -u root -h localhost -p password 'new-password'
See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/safe_mysqld &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; run-all-tests

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

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

It seems like there is some errors. Is MySQL installed, is it partly installed, or is my system untouched?


When i try to set the MySQL root user password (/usr/bin/mysqladmin -u root -p password 'new-password'):
------------------------------------------------------------
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

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

So MySQL doesn't seem to be running?


When I try to start MySQL (cd /usr ; /usr/bin/safe_mysqld &):
------------------------------------------------------------
[1] 528
[localhost:/Applications/Utilities] root# chown: mysql: invalid user name
Starting mysqld daemon with databases from /usr/var
020612 22:37:15 mysqld ended


[1] Done ( cd /usr; /usr/bin/safe_mysqld )

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


And now I'm stuck. I'm a newbie to UNIX, so I'm probably doing something wrong, but is unaware of that. So please, teach me :confused:

When I installed MySQL, I was logged in remotely over ssh, if that could have something to do with it...

The server is running OS X Server 10.1.5
 

Essage

Member
Nevermind my post. It seems like I'm a newbie to manuals/instructions too ;)

I didn't follow all the steps before i tried to change the password :rolleyes:

Now it seems to be working :D

Have to learn all about how MySQL works now. I have no experience so far with SQL databases :(

/Essage
 
Top