Results 1 to 10 of 10
Learning PHP and after uploading my files to a webserver, I can see my efforts OK.
I've installed PHPMyAdmin, signed in as 'root' (localhost, etc...)
All seems to be running ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-11-2013 #1Just Joined!
- Join Date
- Jan 2012
- Posts
- 15
Can't Run a PHP File Locally
Learning PHP and after uploading my files to a webserver, I can see my efforts OK.
I've installed PHPMyAdmin, signed in as 'root' (localhost, etc...)
All seems to be running OK.
In the same browser, Firefox, file>open file...I choose my php file and get the 'open with' box.
How do I associate my php file with the already up and running myPHPAdmin?
Using Ubuntu 12.04 in KDE mode.
- 03-11-2013 #2Just Joined!
- Join Date
- Sep 2012
- Location
- Nashville, TN
- Posts
- 67
Not sure I really understand what is being asked, but I am going to give it a shot. You can't open up your php file directly from a browser. The php page need to go through the php engine in order for it to do the tag replacement.
If you are running a web server on your local machine you would type in Open Source and Linux Forums to access the webpage. When doing that you still get the open page then you will need to tell the apache file that index.php is a DocumentType.
- 03-11-2013 #3Just Joined!
- Join Date
- Jan 2012
- Posts
- 15
Thanks for that. I understand now.
UPDATE!!!
Just read that you can set up a web server. I've edited http.conf and added 'ServerName localhost', restarted but still can't run the file locally.Last edited by chome4; 03-11-2013 at 07:00 PM.
- 03-11-2013 #4Linux Enthusiast
- Join Date
- Apr 2012
- Location
- Virginia, USA
- Posts
- 561
You don't 'open' the file with file open. You enter the url in the address bar like any other website:
http://localhost/somedirectory/myfile.php
- 03-11-2013 #5Just Joined!
- Join Date
- Sep 2012
- Location
- Nashville, TN
- Posts
- 67
Ok I think I see what the problem is. Yes you need to have a web server in order to run PHP scripts that are web based. If you want to use php on the command line you will need to install the php-cli extension.
Here is a link: ( https://help.ubuntu.com/community/ApacheMySQLPHP ) that will give you more information to get you up and going. You can skip the mysql part but I recommend it as you get further along and you start creating more and more projects you will start to introduce dynamic content and this is where mysql will come into play.Last edited by bsdtux; 03-11-2013 at 07:39 PM. Reason: Forgot to include link.
- 03-11-2013 #6Just Joined!
- Join Date
- Jan 2012
- Posts
- 15
I can see the 'it works!' page, which is /var/www/index.html
Using sudo gedit, I can edit the above file. When change it to be a 'hello world' php file and save it as index.php, I get lost.
/var/www/index.html is arrived at by simply entering localhost
If I type localhost/var/www/index.php, I get:
Not Found
The requested URL /var/www/index.php was not found on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
My syntax is now the issue!
How do I display any php file in place of index.html?
- 03-12-2013 #7Linux Enthusiast
- Join Date
- Apr 2012
- Location
- Virginia, USA
- Posts
- 561
The webserver software is Apache.
PHPMyAdmin is a tool to configure MySQL.
Anyway, you should consult a tutorial, such as this one: Ubuntu 12.04 Web Server
- 03-12-2013 #8Linux Guru
- Join Date
- Oct 2007
- Location
- Tucson AZ
- Posts
- 2,514
If you change the index.html file in /var/www/ to index.php, you need to open a web browser (firefox?) and just enter in the browser: h.t.t.p://localhost/index.php]]Using sudo gedit, I can edit the above file. When change it to be a 'hello world' php file and save it as index.php, I get lost.
You do not put the file path "/var/www/index.php". If you do that, it won't work.
- 03-12-2013 #9Just Joined!
- Join Date
- Jan 2012
- Posts
- 15
Finally got it!
Thanks.
- 03-12-2013 #10




