PHP installed--code not working in browser - php

I have installed PHP and its not working in the Apache Webserver.
Steps followed
Installed Apache and tested a sample html file and it worked fine.
Installed PHP and configured in apache.
Created a new php file under httd folder and tried running through the browser but it just opens with the code.
PHP code:
<?php
phpinfo();
?>
There were many recomendations to install WAMP Server. My next step would be that but I just want to fix it.:)

RECOMENDED IS XAMPP http://www.apachefriends.org/en/xampp-windows.html
for your problem if your are running SKYPE On windows make sure you sign out cause they share the same port 80
or any other program that might do the same

Related

How do I use Xampp to localhost after installing apache?

So I want to use Xampp to control my servers. I already installed Apache2 and now it orverrides localhost.
Whenever i put localhost/xampp/index.php it says OBJECT NOT FOUND.
How would I delete this Apache program, and strictly use Xampp on localhost?
I already tried to change the .conf file to Listen 8000 and when to http://localhost:8000/xampp/index.php
Steps:
Open "XAMPP controll panel and run Apache and MySQL"
create folder www inside xampp\htdocs, if you are on win propably C:\xampp\htdocs, so now you have C:\xampp\htdocs\www\
Create test.php inside C:\xampp\htdocs\www\, now you have C:\xampp\htdocs\www\test.php
Put inside test this: <?php echo 'php works fine.'; ?>
Run this script in browser on link "http://localhost/www/test.php" you will see "php works fine.".
DONE.
Have you started apache by opening up Xampp control panel? If you didn't then it won't work. So open up Xampp control panel from the start menu and click on start where it says apache and then run http://localhost to see whether it works.
Have a look at the :
\xampp\apache\logs\error.log
This might give you an idea, why the XAMPP splash screen cannot be found.
Also, make sure you do not have any IIS or similar programs running, as they might have a conflict with the XAMPP.
You can also check if the port is open or not using the instructions given here..
Cheers.
I might be wrong, but it seems to me that everything on localhost is coming from htdocs, but you don't call it from htdocs in the URL.

call to undefined function curl_init() in .bat file

I created my php file as .bat file using
#ECHO OFF
php -f D:\wamp\www\scrapper\scrapper5.php
I used cURL in scrapper5.php, when i run .bet file manually i got and error
call to undefined function curl_init() in your file
I researched and i got cURL is not working in CLI mode.
I just follow below step but can't get success.
Run a php script as a background process in wamp server
How can i run batch file with cURL?
Can anybody give me solution?
From the error you have posted, it looks like you do not have cURL installed. Perhaps look at you CLI config for PHP and see if the curl module is active
Wamp may not have cURL installed by default - have a look at options for installing it on your system.
If i remember correctly, you should have a menu (right click on the wamp icon) for enabling/disabling apache modules. Have a look there for cURL and enable it. (sorry if this is a bit vague, I'm on a mac at the moment and on Windows it has been several years since I moved form WAMP to XAMPP)
If that doesn't work, some forums seem to mention downloading the cURL extension (on windows this is a .dll file) from here: http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/ and putting that in your ext folder under the WAMP instal directory. Just make sure to get your versions correct to ensure stability.
I think you have to enable cUrl feature in wamp server. Follow those steps may it will help you:
1. Go to wamp Server Tray icon which is placed in the task bar.
2.Open PHP Tab.
3.PHP Extensions.
4.Then make sure PHP_CURL is selected.
5.Then restart wamp server.
I hope it will help you!!!!

iis7 serving .php file

I have a old php applications which was earlier hosted on Apache 2.2. Now I am trying to host it on IIS 7.5. I installed php with WebPlatform installer. Then copied directory to inetpub\wwwroot folder. Added this directory as application in IIS. But when I browse search.php, it pops up save as file dialog in the browser - asking to save the file. Instead should return the html response which browser can show.
If put sample index.php with phpInfo() in it. It works properly but not the acutal PHP files. Have I missed any steps?
Any php guys out there? I tried reinstalling, even with xampp, but no luck :(
You have installed it but might not be configured properly. You should follow instructions over here

No www folder is found in apache 2.2

I want to start learning php, I install apache 2.2 and I want to run my first.php file, I look for www folder in the installation folder of ApacheSoftwareFoundation but I couldn't find it.
here's the files in the apache
I tried to put my php file in htdocs but it doesn't work , can some one help ?
Edit
Doesn't work means when I make http:localhost/first.php , returns Unable to connect
Now the apache is running, when I open htt'://localhost/
returns "it works"
but when I open any php file, it opens as-is ?!
You'll need to check a couple of things...
Make sure the Web Server is running ,either the service
or the program, is running and that you have the correctly configured the Virtual Directories.
If the web server just outputs the
content of the .php file, it could
mean that you don't have mod_php
installed. Meaning the server does
not have the Mime type registered so
it will just try to treat it as a
text file ...
And as your on windows you might consider using something like XAMPP. It gives you a Full Working AMP (Apache Mysql Php) Stack with one install and a easy control manager to start/stop the servers. Other wise do a couple of Google searches on how to install the php module for your Web Server on Windows
Update
To start the server try executing the executable bin/httpd.exe .
Now the apache is running, when I open
http://localhost/ returns "it works"
but when I open any php file, it opens
as-is ?!
A default installation of Apache on windows does not include the necessary modules to run PHP. After installing Apache, you must either:
Install PHP separately and follow the instructions described here to configure Apache to use the installed version of PHP to serve .php files. I've been through this and took me hours to get every thing to work.
Recommended for you: uninstall Apache; install WAMP instead.
if you look in your httpd.conf file you will find the default root directory, it doesnt have to be called www. It is the htdocs by default.
error 500 covers a whole host of things. from compile error, to permissions.
Have you put a simple file of
<?php
echo "test";
?>
As your test php page to rule out other issues?
You need to:
Construct your URI correctly: http://localhost/first.php (with the //)
Ensure that Apache is running
all files in htdocs can be referenced from outside
Just put a basic file named index.php
and visit site http://localhost/
In general type in http://localhost/filename
You say that you get a connection error when you try to go to your webpage. Since it looks like you're using Windows Vista or 7, make sure you're running Apache as an administrator; it can't bind to port 80 otherwise. Also check that other programs like Skype aren't binding to port 80. If you still can't find the problem, check the error log. (logs/error.log by default I think)
The problem is that Apache was installed but not started
If you are using xampp start it and then start apache through control panel
for others look for similar instruction

Can't view XAMPP localhost Page except Apache "It Works!"

I am currently using Windows XP SP3 with Apache 2.2, PHP 5.3, MySQL 5.1 and XAMPP 1.7.3 installed.
However after installing everything including XAMPP, I could not see the "XAMPP Welcome Page" at all! I only see the Apache default Page "It Works!!" on http://localhost/ . I also tried http://127.0.0.1/ but it gives back the same Apache results. My Apache and MySQL service seems to be running fine on the XAMPP console.
I have also placed a php file under C:\program files\apache\htdocs\test.php and access the page via http://localhost/test.php which works fine! I really can't guess why isn't the XAMPP installed over the Apache.
Can anyone please give some advice on the problem? Thanks.
XAMPP is a standalone AMP solution, so you don't need to install Apache or anything else with it. And if you do, both servers will probably conflict.
You need to either uninstall XAMPP, or uninstall Apache, PHP, and MySQL.
Note that XAMPP needs to be started up through its control panel, accessible from whatever start menu folder it will have created.
EDIT: Also, XAMPP has its own htdocs folder, located in C:\xampp\htdocs
Alternatively you can switch the port of the Apache server that came with your XAMPP installation via httpd.conf. and as it is described here for example:
Just remember to address the corresponding pages via http://localhost:XXXX
XXXX being the new portnummer you picked (for example 8080).
check the port from xampp control panel >config > Apache httpd.conf
then

Categories