LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-12-2004, 01:01 AM   #1
absolut
LQ Newbie
 
Registered: Jan 2004
Posts: 16

Rep: Reputation: 0
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!
 
Old 01-12-2004, 01:48 AM   #2
alar
Member
 
Registered: Sep 2003
Location: Canada
Distribution: CentOS 5.5, Ubuntu 10.04, Linux Mint 11 gnome 64 bit
Posts: 336

Rep: Reputation: 36
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


Last edited by alar; 01-12-2004 at 02:03 AM.
 
Old 01-12-2004, 03:18 AM   #3
absolut
LQ Newbie
 
Registered: Jan 2004
Posts: 16

Original Poster
Rep: Reputation: 0
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!
 
Old 01-12-2004, 03:28 AM   #4
alar
Member
 
Registered: Sep 2003
Location: Canada
Distribution: CentOS 5.5, Ubuntu 10.04, Linux Mint 11 gnome 64 bit
Posts: 336

Rep: Reputation: 36
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.
 
Old 01-12-2004, 03:41 AM   #5
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Rep: Reputation: 16
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.
 
Old 01-12-2004, 02:06 PM   #6
absolut
LQ Newbie
 
Registered: Jan 2004
Posts: 16

Original Poster
Rep: Reputation: 0
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!
 
Old 01-12-2004, 03:26 PM   #7
absolut
LQ Newbie
 
Registered: Jan 2004
Posts: 16

Original Poster
Rep: Reputation: 0
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
 
Old 01-12-2004, 04:16 PM   #8
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Rep: Reputation: 16
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.

Last edited by hypexr; 01-12-2004 at 04:19 PM.
 
Old 01-12-2004, 05:27 PM   #9
alar
Member
 
Registered: Sep 2003
Location: Canada
Distribution: CentOS 5.5, Ubuntu 10.04, Linux Mint 11 gnome 64 bit
Posts: 336

Rep: Reputation: 36
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"



Last edited by alar; 01-12-2004 at 05:30 PM.
 
Old 01-13-2004, 03:06 AM   #10
absolut
LQ Newbie
 
Registered: Jan 2004
Posts: 16

Original Poster
Rep: Reputation: 0
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!
 
Old 01-13-2004, 03:47 AM   #11
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Rep: Reputation: 16
Have you checked that the directory permissions are the same in the new directory as they are in the old?
 
Old 01-13-2004, 01:26 PM   #12
absolut
LQ Newbie
 
Registered: Jan 2004
Posts: 16

Original Poster
Rep: Reputation: 0
yeap.. I have double checked to make sure that all the permission for the directories to the path are both the same.
 
Old 01-13-2004, 03:04 PM   #13
absolut
LQ Newbie
 
Registered: Jan 2004
Posts: 16

Original Poster
Rep: Reputation: 0
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!
 
Old 01-15-2004, 01:06 PM   #14
absolut
LQ Newbie
 
Registered: Jan 2004
Posts: 16

Original Poster
Rep: Reputation: 0
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!
 
Old 01-15-2004, 01:49 PM   #15
duerra
Member
 
Registered: Oct 2003
Location: Where No One's Been... Spiral Out!
Distribution: FreeBSD
Posts: 201

Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware guide for AMP Apache MySQL & PHP xushi Slackware 35 05-11-2006 12:18 PM
PHP & MySQL Count on PHP Gerardoj Programming 1 06-01-2004 11:43 AM
From RedHat9 to FreeBSD (Apache 2 & Mysql & PHP 4) guardian653 *BSD 5 12-11-2003 06:31 PM
Apache & PHP & Mysql thomas050682 Linux - Networking 5 03-03-2003 04:21 PM
Apache & Php & MySql te_conway Linux - Software 2 12-21-2001 05:06 PM


All times are GMT -5. The time now is 06:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration