I think I have two PHP installs on my machine. if I run the following command:
which php
my system locates an install at /usr/bin/php. But the php I was using before reconfiguring was running from /usr/local/zend/bin/php
The problem is, I need to run the php in the /usr/local/zend/bin directory, but it looks like the other php is currently running. I tried to find the process and kill it using:
ps -ef | grep php
But it's not listed. My question is how can I specify which version of PHP should be running on my system (CentOS)?
PHP is not a running process, so you won't find it with ps. If you're using it on a web server, it'll usually be loaded as a module within your web server, such as Apache. The binaries you're finding in /usr/bin/php and /usr/local/zend/bin/php are the CLI binaries, so you wouldn't use these with your website anyway.
The version that you're using is going to be the version of the library referenced by your web server. If you're using Apache, you'll want to check Apache's configuration to see which library it points to.
You can also create a small script with <? phpinfo(); ?> in it, then load this from a web page to get detailed information about the version you're running.
Related
i have the following server setup:
a DC with DNS [works perfect]
a webserver with GUI [works perfect]
a webserver Core [stuck at PHP installation]
I'm trying to install PHP on the core server. I have a simple site with a php file that shows the phpinfo();. From the GUI webserver I was able to manage to use the gui to do a lot of stuff, but now i'm stuck.
What did i do:
on the core server, i put a php folder and eddited the ini file
On the IIS of the GUI, i manage the Core server and added the module mapping for php. I could not browse (did not get the button witht the 3 points to browse) because its managing the coreserver so i just added the path manualy c:\php\php-cgi.exe
the next step would be to add that php path to the environment variables (path). I did this with powershell. When showing the $env:path, the path of php is added. Also after a reboot, it's still added
when following guides, now i should be able to let the cmd tool tell me what version of php i'm running. I tried php -v, php -m and php --version in command line and in terminal. What gave no errors, but also no other output.
Can someone help me debug this one? The core makes it harder for me because when i did this on a gui, it worked. But then i changed settings like the path environment in gui screens.
Thank you for your time!
Could anyone please tell me how to run a php file locally on my system.
Currently I am using a server to run files.
I know both php & Apache to be installed.
I need to see out put of this program, for example:
<?php
$a=5;
$b=10;
$c=$a+$b;
print $c;
?>
Can you please tell how I can run these files of if I need anything more.
php have a easy way to run a light server:
first cd into php file directory, then
php -S 127.0.0.1:8000
then you can run php
You have to run a web server (e.g. Apache) and browse to your localhost, mostly likely on port 80.
What you really ought to do is install an all-in-one package like XAMPP, it bundles Apache, MySQL PHP, and Perl (if you were so inclined) as well as a few other tools that work with Apache and MySQL - plus it's cross platform (that's what the 'X' in 'XAMPP' stands for).
Once you install XAMPP (and there is an installer, so it shouldn't be hard) open up the control panel for XAMPP and then click the "Start" button next to Apache - note that on applications that require a database, you'll also need to start MySQL (and you'll be able to interface with it through phpMyAdmin). Once you've started Apache, you can browse to http://localhost.
Again, regardless of whether or not you choose XAMPP (which I would recommend), you should just have to start Apache.
In short:
Install WAMP
Put this file to C:\wamp\www\ProjectName\filename.php
Go to browser: http://localhost/ProjectName/filename.php
I just put the content in the question in a file called test.php and ran php test.php.
(In the folder where the test.php is.)
$ php foo.php
15
If you have apache running, put your file in server folder for html files and then call it from web-browser (Like http://localhost/myfile.php ).
3 easy steps to run your PHP program is:
The easiest way is to install MAMP!
Do a 2-minute setup of MAMP.
Open the localhost server in your browser at the created port to see your program up and runing!
I know this is a newbie question, but i want to study php. i have phpeclipse and its running well, the problem is when i run a simple html file with the default server the page says cant display this page and thats it. i dont know if i need to install a new server or is there something wrong with the server configurations. ive tried installing tomcat on my computer but i cant see it under windows->preferences->server->runtime enviroments->add. iv also tried under the same page to fetch geronimo v2.2 and 3.0 and the dependencies were wernt satisfied. iv also tried the repository for zend debugger. what do i need to do in order to compile and see php and html pages with php eclipse?
You don't need to compile PHP.
Depending on your operating system and PHP version there are a few options.
As of PHP 5.4+ you can run your application using PHP's built in server, on the command line, if you cd into your website root directory (i.e. where the index file is) and then run the following
php -S localhost:8989
Then if you navigate to http://localhost:8989 in your browser you should see your application.
If you are unable to run the inbuilt web server, you need to look at Apache2. Most PHP websites run inside the Apache 2 web server. You will generally need a *AMP (WAMP/LAMP) environment.
L/W (Linux / Windows)
A pache (Web server)
M ySQL (Database)
P HP
Hope this is enough of a pointer ;)
How can i setup my powershell to run php scripts in like a commandcall like this
php test.php
I'm able to do this on a server at work which I connect to by putty, but would be nice if I was able to execute those scripts directly from my own without having some server running.
I also know about Xaml, which I don't like since its require you to refresh some browser.
You can do all the stuff suggested above or ...
Go to php.net and download the php file stack for windows.
Copy the file stack into say c:\php or if you want multiple versions, say c:\php5 or c:\php7 etc.
Open powershell and type c:\php\php.exe -h, you will get the php help output. Yay you are up and running, whoot.
(Note: you may need to rename php.ini.development -> php.ini
Advanced instructions:-
Type env into os search (cortana) and select environmental variables.
Add your php location to path (c:\php) and create a variable php (or php5 etc) pointing to c:\php\php.exe
Now you can run php in powershell with php (php -h to test).
Note: while not the question, this also works in the git bash shell.
I'm assuming windows since you said powershell. You can just install php on windows but that means also installing apache or enabling IIS.
Or there's apparently a built-in webserver for command-line functionality that might minimize the amount of headache involved in configuring that stuff.
This might help get you going also:
http://php.net/manual/en/install.windows.legacy.index.php#install.windows.legacy.commandline
Does apache or nginx must be installed before I can run my PHP files in browser?
Django itself has a run-server for testing python codes.Is there any similar way to test PHP files?
Your options is:
Install web server, as you said.
Use web server, as JohnP suggested.
Install php-cli, run your script from console, save output to html file and open it in a browser.
Actually, you can't normally "run" php files in browser. Browser can only send requests to server and display script's output.
There is a built in web server from php 5.4.
Before PHP 5.4 you must install a web server to execute php files in browser
Yes. You need something like nginx or Apache. Either install one of those (on say your local machine). OR, see JohnP's comment - a new feature released recently.