Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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
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:
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
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.
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:
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.
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"
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.