Ninjakreborn Posted May 17, 2007 Share Posted May 17, 2007 Server Info Linux PHP Version 5+ & 4.4.4 Both on the server Problem - I have added something into htaccess that forces all files to run in the php 5 parser when going through the browser. However now when I try running the PHP files through Shell it is telling me I have an improper version of PHP (so basically the script I am using requires PHP 5, and because of that, I can tell it's still trying to read it as PHP 4, is there a way to run it through php 5 parser specifically. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/ Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 This really depends. Just because you have php4 and 5 running as an apache mod, does not mean the cli will run both 4 and 5. Is this your own machine / server? Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255445 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 www.1and1.com Developer Package I have tried everything. I tried even temporarily changing the file to .php5 and it didn't run that way either. I even tried finding commands for shell that will specifically "force" it to parse them AS php5. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255457 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 I tried even temporarily changing the file to .php5 Linux doesn't use (or care about) file extensions. From the shell.... what does this output? $ php --version Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255460 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 I am assuming that $ is basically symbollic for (that is where you put the command), because I see nothing like that, and it works when I don't put it (unless it has a use I am unaware of.) When I put that in I get the following output PHP 4.4.4 (cgi - I hate php running as a cgi module) (built: Nov 14 2006 12:40:26) Copyright © 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright © 1998-2004 Zend Technologies I understand it is "by default" running off of PHP 4, but it's the same thing. When I called the host and spoke with them about it, they had originally told me to add something in htaccess to get php 5 working through the browser, which was. AddType x-mapp-php5 .php Now when I called they told me to add this to get it working in command line. AddHandler x-mapp-php5 .php I tried that and it didn't work, so I even tried to change the filename to php5. I have nothing else to try, I even found another tutorial on it, about adding something at the top of the php file in the form of a bash command, but I don't know how to do that. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255470 Share on other sites More sharing options...
Nameless12 Posted May 17, 2007 Share Posted May 17, 2007 .htaccess will only affect files opened through the webserver, because you are running the CLI it will not be affected .htaccess. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255504 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Now that sucks. How do I go about getting access to them through command line, or is this something that won't be happening. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255506 Share on other sites More sharing options...
Nameless12 Posted May 17, 2007 Share Posted May 17, 2007 you know how you type #!/usr/bin/php If this worked on windows it might look like #!C:/usr/bin/php.exe And as you can see with #!C:/usr/bin/php.exe there is really nothing you can do unless you get a copy of php5 cli on the server. Things like this are why I will always hate 3rd party hosts. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255521 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 Ok... chances are there is a seperate php executable for php5 cli. can I see the output of (from the command line) the following. $ ls -l /usr/bin | grep php And yes, the $ just represents the prompt, do not type it. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255528 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Not only am I doing this but I am trying to learn from it as much as possible. First $ ls -l /usr/bin | grep php Ok, I understand what ls is, (it shows the directory). What is -l I don't understand that, or anything after that. (Just for learning purposes). Second The output that the command you gave me outputs is. -rwxr-xr-x 1 root root 473352 Mar 20 2002 php3 -rwxr-xr-x 1 root root 5083 Mar 31 2002 phptar That is what shows up. After speaking with the host a few time's, they have mentioned they have support for php 3, 4, and 5. after htaccess editing I can change them around in there, but they keep saying I can do it through command line on either php3, php4, php5, python, or perl. So I know there has to be a way, they are just dumb. They keep telling me htaccess should do that, so they are dumb. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255551 Share on other sites More sharing options...
roopurt18 Posted May 17, 2007 Share Posted May 17, 2007 The PHP5 executable resides somewhere on the host. If you are able to find it, you could just use the direct path to execute your scripts. For instance, say the executable was in /usr/bin/php5/, you could do: /usr/bin/php5/php my_script.php Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255568 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 Firstly. -l is an option for ls that list the details of the file. eg; permission, owner, fielsize etc etc. The bit after that pipes the output to the grep program. grep is a meens of filtering output based on regex. If you just ran... $ ls -l /usr/bin You would get alot of un wanted output (Every program installed in /usr/bin). Because we only wanted things related to php I piped the command to grep. Next. .htaccess has nothing to do with the command line in php. It is an apache configuration file and is of no use to us. The setup on this system does appear a little strange though. Do us a favour. I now need the output of... $ whereis php Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255570 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 First So "whereis" is another command. It's basically whereis filename.ext and it will basically report where the file is located... Second When I run "whereis" on any filename other than the php that you showed me, all it does it redisplay the name of what I just added. However this is something I Can find out by google, so in essence just thanks for telling me about this. Third The output of the command you told me to execute was php: /usr/local/bin/php /usr/local/lib/php3.ini /usr/local/lib/php5.old /usr/local/lib/php /usr/local/lib/php.ini /usr/local/lib/php.ini-nourl Again, thank you so much for walking me through parts of this. This is something I was doing partially for a personal project, and partially to learn, and I have learnt a lot during this process, so thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255587 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 It seems to me the server does not support php5 through the cli. Just because they support it on the web, does not meen they do via cli. Give this one last try though. Whats the output of... $ /usr/local/lib/php --version Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255597 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 I tried entering it exactly as you mentioned, as well off numerous various. IN the end I get the same messages about directory not existing, and when I type it "word-for-word" like you said it returns. bash: /usr/local/lib/php: is a directory Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255599 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 Yeah... sorry, that makes sense. I get the same messages about directory not existing When else did you get this message? What is the exact error your getting that makes you believe the script requires php5 ? Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255613 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Oh. I installed a wiki (www.mediawiki.com or google "Media Wiki".) I have gotten the whole thing installed and running and it requires php5. Through the browser everything worked out. However for some reason it didn't create my actual admin account. It created my user, but not my admin, so I saw on the site where it says it sometimes doesn't do this for unknown reasons and provided a manuial fix. So I took AdminSettings.php and recreate it as they listed in the manual. Then I went to run /wiki/maintenance/createAndPromote.php which requires php5 and it requires being run on the command line as well. It has an include for something called commandline.inc Either way that's the reason I was trying to do something. In the end I have learnt a lot but it's starting to look like I won't accomplish my initial goal. I don't have admin access to any of the "maintenance" tasks in the wiki because of this. The reason I know it's a PHP 5 issue is because there is a piece of code within the commandline.inc for that file that reads <?php /** * @todo document * @addtogroup Maintenance */ $wgRequestTime = microtime(true); /** */ # Abort if called from a web server if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) { print "This script must be run from the command line\n"; exit(); } if( version_compare( PHP_VERSION, '5.0.0' ) < 0 ) { print "Sorry! This version of MediaWiki requires PHP 5; you are running " . PHP_VERSION . ".\n\n" . "If you are sure you already have PHP 5 installed, it may be " . "installed\n" . "in a different path from PHP 4. Check with your system administrator.\n"; die( -1 ); } (it's an inc file without <?php tags hence the no syntax highlighting) That check there tests to see if it's command line, then checks the version. I keep getting returned that error message. Telling me I am trying to use php version 4.4.4. and it requires 5. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255631 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Another thing is they claim I can use php3, php4, php5, python and perl. Lately I have been learning python, and I am about to start playing with perl in my spare time. I tried a line of code they showed as http://faq.1and1.com/scripting_languages_supported/cgi/1.html Right there, basically. So I ended up trying: #! /usr/bin/php5 and still nothing. I tried making this a comment, and echoing it both within the createAndPromote.php but it still returns the same error, and just executes that command as text. I will be trying to get .py and .perl files to work after that, but I cant' do that if I can't even get it to use the php5 files. They kept telling me to name my files .php5 and it would work through command line, they also told me that bullshit about htaccess. After wasting hours this morning I realized how stupid they really where. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255636 Share on other sites More sharing options...
Nameless12 Posted May 17, 2007 Share Posted May 17, 2007 They kept telling me to name my files .php5 and it would work through command line LOL, gotta love the idiots at help desks. but I cant' do that if I can't even get it to use the php5 files. Php5's problems shouldnt affect python\perl Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255641 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 I know, I meant I am trying to get this thing down so I can get this script installed (hopefully gaining the knowledge on how to switch between php versions for command line), before I start trying to setup where it can run python and perl files on the web. i want to get where I can easily change between php 3,4, and 5. I am trying to get this one thing working, then I was going to perform some personal analysis tests on the differences between 3, 4, and 5 (which is why I was hoping I could change through them in the Command line like I could through the browser), but I am starting to wonder that won't happen because of there stupid setup. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255643 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Wait, yeah maybe that will help. WHen I am trying to run the file, I get into the directory and run. php -f createAndPromote.php When I do that, I am getting this message. Sorry! This version of MediaWiki requires PHP 5; you are running 4.4.4. If you are sure you already have PHP 5 installed, it may be installed in a different path from PHP 4. Check with your system administrator. Does that mean there is someway for me to change the path. I could call them again, but it sounds like I know more about what I am doing now than they do. They have non-technical people in tech support. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255646 Share on other sites More sharing options...
trq Posted May 17, 2007 Share Posted May 17, 2007 So I ended up trying: #! /usr/bin/php5 /usr/bin/php5 does not exist, we allready checked that. I'll explain some stuff. This line... #!/usr/bin/php Is what is known as a shebang. Remember how I said Linux does not use file extensions? Scripts need a shebang line to let the shell know which program to use to execute them. Hence, bash programs always start with... #!/bin/bash If we could find where the php5 executable resides, you could point your shabang at it. Lets try one more thing, whats the output of... $ which php PS: On Linux, most commands have a man page. For instance, earlier you asked about the -l option to the ls command. You can find out infomation like this yourself by typing... $ man ls Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255649 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 First I really want to thank you for filling me in on this man command. This seems very helpful, I also learnt that q backs out of something (like when your in the man command). Another thing I was wondering, when I try to do something like man -f which "-f" being what I used to try to run the file in the first place, it doesn't work. It works with ls though, which was VERY informational, thanks again. Second Based on what you said, I ran a little test. I was told there server supports php 3, 4, and 5. I also know 6 doesn't exist. So I ran the following commands (in code) and got there output (in quotes) PHP which php /usr/local/bin/php PHP3 which php3 /usr/local/bin/php3 php4 which php4 /usr/local/bin/php4 php5 which php5 /usr/local/bin/php5 php6 (testing to see if it would come up with an error if something didn't exist) which php6 Nothing, returns blank (because it can't be there since they don't have it on the server); This tells me for a fact they have the php3, 4, and 5. So what can I do "with" this information to get it to do what I need. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255667 Share on other sites More sharing options...
Nameless12 Posted May 17, 2007 Share Posted May 17, 2007 //save as php5test #!/usr/local/bin/php5 <?php echo 'php5'; ?> //make it executable chmod +x phptest //execute it ./php5test Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255687 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 I now understand that the top part is a shebang as "thorpe" told me. But I don't understand how to use it. I also understand the hello world (I guess to test it). Make executable I have no idea. I know chmod but never saw +x The way you showed me to execute doesn't execute. Do I run these through command line, I was able to follow so far, but now I am complete lost, and I saw that same thing to within the 1and1.com faq but it made no sense to me. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/#findComment-255692 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.