LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need direction for PHP & mySQL (https://www.linuxquestions.org/questions/linux-newbie-8/need-direction-for-php-and-mysql-133877/)

absolut 01-12-2004 12:01 AM

Need direction for PHP & mySQL
 
Hi everybody, I have just installed Mandrake 9.1, and this is the first time I've ever dealt with linux. I got a project involving PHP & mySQL. When I installed Mandrake, there the option for installing Apache and mySQL (I chose those options), however, there's nothing about PHP.

I just need some guidance regarding these following questions:

1. Do we have to install something like a PHP editor/compiler?
2. How to access mySQL? i.e. create tables, query
3. As a windows user, usually we have a virtual directory (under inetpub\wwwroot). Does that concept also apply to linux? If yes, where is the location of the virtual directory?

Thanks a lot for your helps! :)

alar 01-12-2004 12:48 AM

http://www.php.net/downloads.php

also see--
http://ca3.php.net/manual/en/ref.mysql.php
My MySQL references... (I used Oracle..)

Apache is installed, so you can now install PHP. You will uncompress the PHP package, giving you a directory named "php-4.3.2". You must change into this directory. Use the standard UNIX/Linux way of building and installing software from source; configure, make, and then make install.


To add PHP to Apache:
You must also edit the httpd.conf file which is usually located in /where/ever/apache/conf. You must add the following lines:

#
# This will load the PHP module into Apache. Put this line
# with other LoadModule lines.
#
LoadModule php4_module
libexec/libphp4.so
#
# This next section will add a handler for .php files, put it with other
# IfModule lines.
#
<IfModule mod_php4.c>
AddType application/x-httpd-php .php

</IfModule>


Oooops. If you are totally new then I guess you don't know how to untar a file yet either?
tar zxvf filename.gz

Here's the steps I followed for an oracle database.

# tar zxvf php-4.3.3.tar.gz
# cd php-4.3.3
# ./configure --with-oci8=$ORACLE_HOME \
--with-apxs=/usr/local/apache1.3.28/sbin/apxs \
--enable-sigchild
# make
# make install
# cp php.ini-dist /usr/local/lib/php.ini

Hopefully you will find the proper config method for MySQL
on PHP-MySQL

Have Fun,
alar


absolut 01-12-2004 02:18 AM

Thanks alar for your information. However, I'm still struggling with the basic stuffs.
Here are some of them:

1. I can't access my cdrom and floppy disk. I go to /mnt, and there are /cdrom & /floppy, however, when I access it, it's empty (I have CDrom/floppy in their respective drive). Even the LED doesn't light when I access the cdrom/floppy, i.e. it deosn't seem that the system is accessing it.

2. How to check that the apache has already running properly?

3. How to access mySQL? Does it have a GUI like Microsoft SQL Server 2000?

Thanks!

alar 01-12-2004 02:28 AM

Looks like first you must mount the cd or floppy

#mount /dev/cdrom
#cd /mnt/cdrom

apache
navigate to apache directory
/usr/local/apache
or
/your/path/to/apache
cd to the bin directory (or sbin sometimes)
run
./apachectl start
./apachectl stop

Don't know SQL Server. You can use apache to access the database.

hypexr 01-12-2004 02:41 AM

Quote:

Originally posted by absolut

2. How to check that the apache has already running properly?

3. How to access mySQL? Does it have a GUI like Microsoft SQL Server 2000?

Thanks!

One way to check if apache is is up and running properly is to do a
Code:

ps aux | grep httpd
This will show if any instances of apache are running.
Also try pointing your browser your web server
Code:

http://localhost
And see if the test page opens up.

There are GUI's available for mySQL. Check MYSQLGUI, which is in beta testing.http://www.mysql.com/downloads/gui-mysqlgui.html
Also check out phpMyAdmin http://www.phpmyadmin.net/home_page/
It is php software for managing mySQL.

Accessing mySQL via the command prompt is also an option. After you have mySQL set up with a password for root and everything you can look to here some basics.

absolut 01-12-2004 01:06 PM

Thanks hypexr! I got the Apache running already. I got mySQL installed from the Mandrake 9.1 Installation package. However, when I tried the following command:

# mysql
It says: "ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

# mysqladmin -uroot create testDB
It says: "mysqladmin: connect to server at 'localhost' failed
error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Actually, the file '/var/lib/mysql/mysql.sock' doesn't exist in my machine.

Any help/suggestion?

Thanks!

absolut 01-12-2004 02:26 PM

Fixed that. I haven't start MySQL on the service (Stupid!)

Anyway, I installed MySQL, PHP and Apache all from Mandrake 9.1 packages. Now I need to set some configuration which involves the knowledge of the directories in which they are installed. Can anyone help me with the default directory which MYSQL, PHP and Apache are usually installed?

One more thing, http://localhost actually points to which directory?

Thanks guys! Your help is greatly appreciated :)

hypexr 01-12-2004 03:16 PM

If a Mandrake user does not respond with the directories that these are installed in, you can use find to see where they might be:
Code:

find / -name 'apache*' -type d -print 2>/dev/null
Hope this helps. :)

Edit: The directory where your html documents are usually at is www or html. You can search for one of these or search for index.html and find the correct result.

alar 01-12-2004 04:27 PM

Quote:

If a Mandrake user does not respond with the directories that these are installed in, you can use find to see where they might be:
If you are totally new to Linux you may not know the which command

It will find a program in your path. Especially to find something like apache
which is typically in an /sbin (only visible to root)
you should probably execute as root.

su - root
which httpd

I think it's called apache on windows, but on (Li)nux it is httpd
The su with a '-' is to inherit the variables (.profile) of the user u wish to become

Have Fun,
alar

BTW- http://localhost points to the directory defined in your httpd.conf as DocumentRoot

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/alar/Gonna_be_Web_Stuff/htdocs"



absolut 01-13-2004 02:06 AM

Thanks guys! Now I can display a PHP page. However, there's 1 problem:

If I used the default localhost as defined in httpd.conf which is "/var/www/html/", my test page (which is test.php) will be displayed correctly in the browser (http://localhost/test.php)

But when I changed the DocumentRoot into any other path (let's say "/var/www/HR/", test.php won't be displayed. Instead, it gives me error 403 Forbidden. I figured that in the default localhost there's a directory called "addon-modules" which contains ".htaccess". My guess is that ".htaccess" is the one that is controlling the permission. Well, I have tried duplicating that file into the "/var/www/HR/addon-modules", restarting apache, but I still got the same error (Forbidden).

Any suggestion? Thanks!

hypexr 01-13-2004 02:47 AM

Have you checked that the directory permissions are the same in the new directory as they are in the old?

absolut 01-13-2004 12:26 PM

yeap.. I have double checked to make sure that all the permission for the directories to the path are both the same.

absolut 01-13-2004 02:04 PM

Ugh, I didn't change the directory path for permission in the commonhttpd.conf... Now I got it working!
I tried phpMyAdmin for mySQL and it also works fine!

Thanks a lot for your help guys! I really appreciate it!

absolut 01-15-2004 12:06 PM

Hi, I have a simple PHP question here:
Is there any Session Object in PHP (just like in ASP)? I want to make a site that requires user login.

Thanks! :)

duerra 01-15-2004 12:49 PM

session_start();
Then you have your session superglobals that you can use anywhere in your PHP script. Assign and call:

$_SESSION['varName'] = "value";
$someVar = $_SESSION['varName'];

Just make sure you run session_start() on every page that you use a session, otherwise it won't work.


All times are GMT -5. The time now is 06:14 PM.