I just installed apache and php on a windows 7 installation.
in the apache htdocs directory I put a file called "testing.php"
in it I wrote
<?php
echo "Maple|Pine|Oak|Ash";
?>
when I visit the page though it just spits out everything (rather than actually echoing the words) .
this is my first time running a web server or anything so I was wondering what I am doing wrong?
You need to install PHP also. Apache does not come with PHP in it, it has to be installed and properly enabled. Consider WAPM (to learn .htaccess too, for Linux hosting) or IIS Express + Web Platform Installer (+ PHP + PHP Win Cache + URL Rewrite - these are found in WebPI and are easy to install).
Related
I'm an absolute beginner when it comes to PHP. I have a standard html/css/js project that I'm editing with VS code and running a development server with the Live Server extension, which is running on localhost:5500.
I'd like to integrate a single .php file into my project which will handle a form submission.
Will I need xampp running on my local machine in order for the .php file to work?
At the moment the form action is sending a post request to my .php file but I get a 405 error from the browser.
Yes, A PHP processor is needed for the PHP code to work. If you have XAMPP installed (which means you have php), you can run
php -S localhost:5501 (make sure C:/xampp/php is in your PATH environment variable)
in the root directory of your project, this will start a PHP server and you don't have to move everything to the htdocs folder.
You need a server capable of processing PHP.
That doesn't need to be Apache HTTPD. If you do pick Apache HTTPD then you don't need to install it as part of XAMPP.
The Live Server extension is not capable of processing PHP so you need a different server. (I think I saw a PHP capable equivalent in the extensions library in VS Code, but I recall it being quite fiddly to configure.)
Yes, you need a server (apache or nginx) + php.
Xampp include all this in one application: x (SO) A (apache) M(mysql) P(perl) P(php)
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 have designed a PHP based website which needs to run on a local server. Unfortunately I have developed this on a WAMP server using Apache. The machine on which this website will be placed on only supports the IIS server and I am not allowed to install Apache on this this machine.
How do I run PHP code on an IIS server?
See this link: http://php.iis.net/
99% of stuff is compatible. There can be some problems though (for example if you use mod_rewrite, or some file operation functions behave a little differently).
You can get it installed and include the right infrastructure (IIS, WinCache, and FastCGI, and URL Rewrite) with a single click using Web Platform Installer:
To install PHP 5.2 use:
http://www.microsoft.com/web/gallery/install.aspx?appid=PHP52
To install PHP 5.3 use:
http://www.microsoft.com/web/gallery/install.aspx?appid=PHP53
http://php.iis.net/
With IIS 7, a lot of the apache/iis gaps have been closed. Like mod_rewrite is available in IIS 7 (http://www.iis.net/download/urlrewrite)
Here's how I got PHP 5.3 running on IIS 6:
http://www.howtoadvice.com/PHPIIS
I'm starting a new project using Linux and PHP, but for the early dev state i'm now, I'm trying to use XAMPP for now.
I'm Running Ubuntu 10.04 x64 on a laptop, And got everything I need. The site I should build is based upon CodeIgniter and some implementation of smarty, but I think this is not that important because the same site runs pretty well on windows (with XAMPP )
The Problem I have is, if I put some php file on the root (like foo.php) with phpinfo() on it, the server parsed it as it should be, but when I try to get the url for one CodeIgniter app (as http://localhost/site/site.php ), Firefox tries to download the file & Chrome alerts some server error.
Again, the site as it works perfectly on windows (I share code using mercurial, if that's important)
I have around 3 codeigniter apps sharing the same System folder, and those get pickup by the loader (as site.php, admin.php...), but anyone I pick I still getting the same msg.
Also, the server list all the files perfectly, and tried to rename the file and then asked for the same (to see if the problem is cache or something) but I get a 404.
I'm also a newbie on apache and linux in general, I don't know what to do...
Check your apache.conf and httpd.conf. There are configuration entries called AddHandler which assign a module to each file extension which should handle this. If no module is provided the apache will send the file as plain text to the client.
I am trying to get PHP working on my vista home machine but I am getting weird problems. First I had file permission problems for which I disabled Vista's UAC. Now I can't get the PHP interpreter working.
I have made all the necessary changes following some tutorial but I still can't get it working.
Tutorial was located here: http://www.tanguay.info/wamp/installPhp5.php5
Try XAMPP. I use that at home on a Vista machine and it worked nicely after the install.
WAMPServer is also a good option. You can easily enable/disable both PHP extensions and Apache 2 modules. Everything is set up somewhat securely (only local access to the serve), and you get phpMyAdmin already set up.
Only thing I've ever missed is Memcached, but that is fairly easy to set up on your own.
The only problem I have installing PHP and Apache on Vista is that you need to make sure that when you edit the httpd.conf that you are editing it as an admin, otherwise the file is saved in compatibility mode.
To overcome that problem just type notepad++ or whatever in your start menu, right click the item and run as administrator. Then open the file from the app.
You can use FastCGI for IIS 7. I'm using this also and it works perfectly!!
FastCGI
You can try Zend Core
It works on both IIS and Apache (it includes the installation of the Apache)
iis7 is one of the best web servers and especially for php, if you can't get it to work it means you need to google enough, because it isn't logical to blame Vista for php/apache issues