LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Thread Tools
Old 09-05-2006, 05:53 PM   #1
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1
running test scripts with php


[Log in to get rid of this advertisement]
I've been playing with php and myql for about three months. I created a form, INSERT'd its contents using POST, SELECT'd it and even used strtotime() function to take select a date of the format yyyy,mm,dd hh:min:sec and convert it to a unix timestamp and then inserted that into my database, selected the aformentioned and displayed such to the screen. About this time I'm somewhat full of myself.

Now i want to create a directory, hopefully in "/var/www/html" or even in "/var/www/html/plm" or anywhere for that matter. Now I've also discovered that I'm not such a hot shot.

I'm running Fedora Core 4 with apache (httpd) v2.0.54-10.4 and mysql v4.1.20.-1.FC4.1.

I've tried the following script (named "plmNewDir1.php":

<?php

$path="/var/www/html";
$newDir="bliss";

//create a directory as part of registration
function FtpMkdir($path, $newDir) {
$server='ftp.localhost'; //local ftp server (server not named yet, also tried "ftp//localhost")
$connection=ftp_connect($server); //connect

//login to ftp server
$user="root"; //also tried my username and pwd
$password="********";
$result=ftp_login($connection, $user, $pass);

//check if connection was made
if ((!$connection) || (!$result)) {
return false;
exit();
} else {
if (!ftp_chdir($connection, $path)) { //go to destination dir
$r=false;
} else if (!ftp_mkdir($connection, $newDir)) { //create dir
$r=false;
} else if (!ftp_site($connectin, "CHMOD 0777 $newDir") { //change attributes
$r=false;
} else {
$r=$newDir;
}
}
ftp_close($connection); //close the connection
return $r;
}

?>

I placed this script in both "/var/www/" and "/var/www/html". Not even a GTH error message when i went to the browser and typed in "http//localhost/plmNewDir1.php". Past history with php and mysql tells me that when they're really fed up with me I get the "blank screen" stare. If it's playing nice and I'm close I'll get error messages usually courtesy of mysql. Please help. Thanks in advance. phil
PhilTR is offline     Reply With Quote
Old 09-06-2006, 03:40 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: FC11 2.6.29.4-167.fc11.i686.PAE
Posts: 1,217
Thanked: 26
Well, on FC3 with a AMP install, I just copy my .PHP scripts into

/usr/local/apache2/htdocs

and they run fine...

I compiled Apache, and PHP myself, and I use a binary MySQL install.

Aren't you just maybe placing the .PHP files into the wrong directory?
rylan76 is offline     Reply With Quote
Old 09-06-2006, 07:31 AM   #3
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1

Original Poster
I used an rpm install (with rpm updates) for each, PHP, Apache and MySql, and I don't have a "/usr/local/apache2/" directory. I've seen reference to such a directory but when I went looking for it never found it. I just chalked it up to the pequliarities of my FC4 OS. As a rule I don't have any problems running .php scripts and that is what has me puzzled. BTW mysql installed itself in "/var/lib/mysql" To be exact I get the following:

[philtr@localhost ~]$ whereis php
php: /usr/bin/php /etc/php.d /etc/php.ini /usr/lib/php /usr/share/man/man1/php.1.gz

[philtr@localhost ~]$ whereis mysql
mysql: /usr/bin/mysql /usr/lib/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

[philtr@localhost ~]$ whereis httpd
httpd: /usr/sbin/httpd /usr/sbin/httpd.worker /etc/httpd /usr/lib/httpd /usr/share/man/man8/httpd.8.gz

An odd install but, it seemed to work to this point. Permission of all .php files have been "664" with owner being changed from "philtr, philtr" to "root, root" by the system when I copy files from "/philtr/plm/php/plm" to /var/www/html/plm". I'd be happy to provide any other details. phil
PhilTR is offline     Reply With Quote
Old 09-06-2006, 08:32 AM   #4
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1

Original Poster
To add a bit more to the above. Whereis for vsftpd is:

[philtr@localhost ~]$ whereis vsftpd
vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz

Ownership of "/var/lib/mysql" is: mysql MySQL server, mysql
of "/var/lib/php" is: root, root
of "/ect/vsftpd" is: root, root

Hope this helps. phil
PhilTR is offline     Reply With Quote
Old 09-07-2006, 05:57 AM   #5
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: FC11 2.6.29.4-167.fc11.i686.PAE
Posts: 1,217
Thanked: 26
There's your problem right off - you used RPMs... I had much the same trouble with RPMs in the past - i. e. stuff not going where its supposed to, me not having any idea what went where, or why something is not working. I try to avoid rpm like a pestilent disease.

I'd seriously advise you to get recent source versions of Apache and PHP, and compile them yourself on your system. It does require a bit more effort and knowhow, but it really works best in the end. MySQL is OK to get a binary distribution for, since it is a bit complicated (IMHO) to compile it yourself, and there are quite a few performance tuning settings that I have found a "stock" binary distribution more than adequate for.

So the sequence would then be:

1. Get Apache in source form.
2. Get PHP in source form.
3. Compile Apahce.
4. Compile PHP.
5. Install MySQL.

This should leave you at the end of the day with a working -standard- installation that is where you want it to be, configure like you need it to be. Compared to the mess of -ivh'ing an RPM that just messes everything up.
rylan76 is offline     Reply With Quote
Old 09-07-2006, 07:29 AM   #6
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1

Original Poster
running test scripts with php

Well, as I am rather new to Linux in general I've taken the RPM route to get familiar with Linux and because I was having a good deal of difficulty with compiling from source with some programs. RPMs always seem to interact well with each other and locating needed libraries is not difficult. I'm trying to get a good feel for Linux before heading off into the wild blue yonder and of couse I'm trying to get some work done too as I'm under some pressure to complete this current project by Oct 1.

My current problem seems to be either a permission issue (not likely as root is owner of all files in "/var/www/html/") or a context issue in that I'm trying to run a code snippit improperly (the more likely). All scripts ran with out problems until when I tried to run the above script.

My files are in the right place as when I move them, say to "/var/www/temp/", PHP complains that it can't find them. In an attemp to simplify matters I tried to run the following:

<?php

$result = mkdir("/html/bliss", 0777);
if(!$result) {
echo "Error: Couldn't create the directory!<BR>";
}
?>

I got the error message which suggests to me that I'm missing somethin rather basic. I've changed the path string around a bit to see if that was the problem to no effect.

I was even able to run:

<?php
$timestamp=strtotime("now");
return $timestamp;
?>

as an include in another script inserting the Unix time stamp into mysql then retrieving it with SELECT and displaying it with and "echo" statement.

All this leads me to believe it not the OS or PHP but, rather, it's me. I seem to be overlooking something rather basic here. Please help. phil
PhilTR is offline     Reply With Quote
Old 09-07-2006, 08:48 AM   #7
rupertwh
Member
 
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 246
Thanked: 3
Quote:
Originally Posted by PhilTR
$server='ftp.localhost'; //local ftp server (server not named yet, also tried "ftp//localhost")
$connection=ftp_connect($server); //connect
Hi Phil,

not sure if this has to do with your problem, but:
ftp.localhost is not a host name and ftp//localhost is not a URL.

The host name would be simply "localhost", the URL "ftp://localhost" (or "ftp://localhost/").

And using RPMs is quite allright.

Cheers

Rupert
rupertwh is offline     Reply With Quote
Old 09-07-2006, 03:05 PM   #8
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1

Original Poster
running test scripts with php

hi Rupert:

I think my problem is more basic than the host/url matter. I'm not even able to create a directory with:

<?php
$result = mkdir("/html/bliss", 0777);
if(!$result) {
echo "Error: Couldn't create the directory!<BR>";
}
?>

This script shouldn't even involve the login issue, only permissions and possibly configuration settings. I've tried every combination of path string I could think of w/o success. I even went through the "php.ini" file looking for "bad-guys". I do have SELinux but, it's in permissive mode. So, theory goes, SELinux shouldn't be involved. Maybe, possible, hopefully.

I'm running PHP v5.0.4 ta'boot! I really want to get a handle on the stuff I got before moving to newer versions of stuff with all their quirks.

Anyway, thanks for the moral support re: "rpm's". I kind'a like them seein' as how I'm still pretty wet behind the ears "code-wise"

phil
PhilTR is offline     Reply With Quote
Old 09-07-2006, 10:32 PM   #9
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1

Original Poster
running test scripts with php

Just a note. Since I have PHP v5.0.6 installed I discovered that the command line prompt is supported which allows me to run most of my .php scripts (those that don't require input from a html file) while in my home directory. I do have to be in the directory where the .php script is located.

I can also run scripts from the command line while in "/var/www/html/". So the environment allows me to run scripts. It's just that my coding sucks.

http://www.sitepoint.com/article/php-command-line-1 provides a lot of help.

Now to figure out why I can't execute the same script from the browser. phil
PhilTR is offline     Reply With Quote
Old 09-09-2006, 12:31 AM   #10
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1

Original Poster
Well I figured out what my problem was in getting php to create directories. html is owned by root with "apache" having group ownership. It helps to have the permissions of directory "html" in "/var/www/html" set to '775' instead of '755' so apache can write to the directory, html. My bad! So obvious.
PhilTR is offline     Reply With Quote
Old 09-09-2006, 12:35 AM   #11
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1

Original Poster
Make that "so apache will allow a write to the html dir in "/var/www/html/" phil
PhilTR is offline     Reply With Quote
Old 09-12-2006, 02:13 PM   #12
PhilTR
Member
 
Registered: Jun 2004
Location: Birmingham, AL
Distribution: FC6, FC8, FC11
Posts: 102
Thanked: 1

Original Poster
test scripts with php

I've discovered several more things regarding the behavior of PHP when uploading files.

In the "Resource Limit" section up the "max_execution_time" from the default (30 secs. in my sys) to some duration that allows the job to finish (I set mine to 300 secs. or five min. as files can be slow to upload).

In the "Data Handling" section also set "post_max_size" (8M in my sys) high enough to handle the job. I now have mine set at 100M. This value sets the limit on the amount of data that can be handled by "$_POST". Large files, naturally, would require much larger values.

This goes along with setting "max_file_size" (in the "File Upload" section) to something that will handle the job. I've set mine to 100M and may increase it to 1G (or more) if handling large .mov, .avi or .mpg files.

Happy hacking all! phil
PhilTR is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
LXer: Adodb Multiple Test Scripts Remote Command Execution ... LXer Syndicated Linux News 0 01-09-2006 07:01 PM
Running PHP Scripts in SuSe Linux 9.3 w/o a server. elliotfuller Linux - Software 3 06-18-2005 07:27 PM
scripts - test with if meDream Linux - Newbie 2 05-31-2005 03:13 PM
Need help running scripts from scripts sdouble Linux - Newbie 3 05-31-2004 01:56 PM
Apache not running php scripts Seventh Linux - Newbie 3 01-08-2004 09:35 PM


All times are GMT -5. The time now is 01:37 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration