Apache downloading php file - php

I think I'm having the same issue as this link: Apache is downloading php files instead of displaying them
I'm trying to install Roundcube on my Linode server but when I go to www.myurl.com/roundcube it downloads the php files.
I read through that link and I see people saying to add things to different files, but I don't know where to look.
I'm new to Linode, I'm used to hosts with cPanels and such. So, I need a bit of a point in the right direction.

With linode you have the raw server ie you need to ssh into it and configure it. Start with this guide.
https://www.linode.com/docs/websites/hosting-a-website
Once you have a basic site running then configure apache to use PHP.

Related

My .php files not running on WAMP Server, it is trying to save the file instead

I have just cloned a project, so it works perfectly fine when i load it e.g: "localhost/example/contact.html", but when i click to homepage which the endpoint is "localhost/example/index.php" it asks me to save the file like that:
Asking to save the php file
I have checked everything in files such as php.ini, httpd.conf but still cant find a solution, I also reinstalled wamp 2 times.
Also the php error log gives me this error: The file C:/WINDOWS/system32/drivers/etc/hosts does not exists
Any help would be appreciated!
You need to load and enable mod_php or set up php-fpm. Afaik Wamp uses mod_php which is simpler. The reason your web browser asks you to download the php files is because you have not told the web server to treat .php files differently that .txt files.
There are plenty of resources on the interwebs about setting up php and apache:
https://cwiki.apache.org/confluence/display/HTTPD/PHP
Given that you are using Wamp, which should work out of the box, I'd say reinstall one more time and run the installer as an admin. If the issue about the etc/hosts file persists, you can create the file yourself.
However, I don't think the hosts file is necessary to run wamp or to render / run .php files.
PS: Your question is not about programming or code, so it's going to be closed because it fits better on the superuser website. Welcome to SO!

Phpinfo.php browser trying to download instead of running

HI I am trying to configure IIS7 to run PHP on a windows 2008 server machine.
I have followed this guide, php running on IIS7
Everything went well and I am sure it was working!!
However now when I try and run phpinfo.php the browser wants to download the page rather than running the script.
The handler mapper is configured the same as the the example. fastCGI/CGI is installed and enabled.
a normal index.html open no problem.
I have checked permissions, created a new empty site apart from phpinfo.php
I developed the site on my pc in a xampp environment where everything work great. First time I have tried to convert a site from xampp to IIS.
Their is no entry in the MIME Types, I am wondering if the WEB.CONFIG file is the issue but I don't know enough about what the file should/shouldn't contain.
thanks for any help
you can use http://php.iis.net/ to install php into your IIS setup. It comes with a manager to help you easily implement php in to your iis server and is way easier then trying to configure it manually. Hope this helps.

Running PHP on my machine locally?

I download xampp 1.7.7 and it has PHP and MySQL. I bought a book named HeadFirst PHP MySQL. My problem is that I can't run the examples from the book.
The example files consist of 2 files: one HTML, and one PHP file. The example is like this you fill the form from HTML file then send it to a web server then the php will handle the HTML file then return it to you.
When I filled the form then I click the submit button, it didn't return what it was supposed to return. What it returns is the actual PHP code.
Do I need to transfer all the files from the book to a webhost so that I cant try the examples I said? How can I run it locally?
UPDATE!!
I tried what anselm said now it says OBJECT not found... url not found then the 404 error.
Ensure that you're accessing the html file through http://localhost/file.html instead of c:\etc etc.html
if you are developing on windows i really recommend using wamp it really easy to use and include the main stuck which is php, mysql, apache it really easy to install and automatically configures everything you then can find www folder in wamp folder on your c drive where you have to drop you php files
http://www.wampserver.com/en/
Your PHP code isn't being parsed by PHP. Either the Apache config is wrong (unlikely since you installed XAMPP, but you can check by following the steps at http://www.php.net/manual/en/install.windows.apache2.php), or your files aren't really named .php.
In Windows, make sure you have file extension viewing turned on, and ensure the file extensions really are .php.
In your XAMPP Control Panel, make sure that Apache started.

How to get started with sql and php?

I was wondering how to link a SQL database on my PHP code.
I am using a database on my local server that I set up and I have already created a database, I tried writing a PHP script with ++notepad, but when I clicked on the script, it opened the browser and displayed a blank page. What am I doing wrong? I created my databases using phpMyAdmin.
You need to be running a web server locally which supports PHP (like Apache). It it the web server which does the PHP processing. At the same time you will have to run a MySQL (or any other) database engine too, so your PHP code can connect and query it. (I'm assuming you've already installed PHP.)
I would recommend you install XAMPP which includes Apache, PHP, MySQL and a bunch of other stuff. It one of "Apache friends". Once you install XAMPP you would have a folder htdocs in the xampp folder. Create a folder for you project myproject and place your PHP script script.php in there. Now if MySQL and Apache are running following should behave as you expect.
http://127.0.0.1/myproject/script.php
For the tutorial, to begin with you can use W3Schools. Brief and to the point. They have both a PHP tutorial and a SQL tutorial.
This is a very good book to start with:
PHP and MySQL
Web Development
Luke Welling and Laura Thomson
You have to play with php/sql code practically. Only reading cant help!
go for w3shools as mentioned above :)
start with simple code and then go to the complexity. all the best.. :)
There are multiple ways on how to do that.
One of the most modern ways to do that, is to use PDO to connect to the DB with PHP.
To run PHP on your PC(which i assume is your workstation), you need the supporting software for it, for php to run you need the PHP software installed, and likewise if you want to run the server software you need apache, however you can go for a single install package which will install almost everything for you to run your php script, download and install the wamp.
to install wamp which stands for (windows, apache, mysql, PHP) if you are running windows, and lamp for linux or mamp for mac, all of which are free softwares, you can download wamp from the following link. http://www.wampserver.com/en/download.php that is the first step which you need to do.
step 2: once wamp is installed the default directory of installation is C:/wamp (i reccomend do not change the location of the installation), you need to start the wamp server by just opening or double clicking the software which you just installed.
step3: navigate to the default directory where you should be storing your PHP files and that is C:/wamp/www note that you should be keeping all your PHP files here apart from this location if you store it anywhere else it wont simply run at all, and that it should and must have the .php extension.
step4: create or save the php files in this location(c:/wamp/www) i for example will assume you have created a file test.php in the www folder. now to access this file open your web browser and type http://localhost/test.php there you go, you will have the access to your PHP file (Note: PHP files cannot be run by simply double clicking the file, you have to follow this procedure in order to run the PHP files)
step5: open the test.php in any of your text editor like notepad, or i recommend use an IDE (Netbeans is free and worth a try), and write your code in the following format.
<?php
your PHP code should go here.
?>
when i started writing the code i started by following a nice tutorial which i found in zend.com, it has one of the best examples, and moreover the tutorial is meant for the beginners. hope this helps you..
http://devzone.zend.com/tag/PHP101

Best PHP download to keep all my options open?

In the past, I used WAMPserver on windows to parse PHP for me. This is a pre-configured package, focussed on working with MySQL.
When I tried to run PostgreSQL, I got error messages that said that my version of PHP wasn't compiled to work with PostgreSQL.
So, I've recently uninstalled WAMP and every associated with it. I've downloaded Apache 2.2.11 with openSSL, installed as admin(you know, run the command prompt as administrator, cd to the directory where the download was done and have it executed, so the install was done as admin).
That's that. I now have Apache installed, "it works" shows up, so I'm that far.
Now I'm wondering, do I download the exe and install, or the zip, or something else.
What is the best thing to do to make sure that the PHP on my system can handle everything I can ever throw at it?
Also, PHP first, or MySQL/Postgre first.
And lastly, what about PEAR? I need PEAR installed, which isn't standard on Windows. I'm guessing the pear.bat file in the PHP downloads will do that for me?
EDIT: I see one close vote, yet no comment as to why. It makes me wonder how people who are so lazy and rude got to have somany points.
I would recommend downloading the zip package, as configuring php is not really that difficult, and it allows you to add features as needed.
As for whether first to install php or MySQL/PostgreSQL, - it does not really matter. You can install them in any order.
Your guess regarding PEAR is quite correct
i haven't used wamp before, so i can't comment on that
i do however use xampp which sounds very similar
in xampp if i want to enable postgres support i edit the php.ini file and uncomment the postgres section of the ini file, same with any of the extensions that i need
perhaps this might be an alternative you can try if you get stuck
There are many ways to setup a HTTP server/PHP/database machine. Sometimes the behaviour of your development setup will differ from the live server's.
I would recommend finding out the setup your web host is using, then getting a vmware appliance image that fits that as close as possible and get any additional software using it's package manager (which is easier that installing stuff on Windows).
Setup a file sharing link between the VM and the host, make sure you can view the VM's port 80 in a browser running in your host OS and you're set.

Categories