LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2011, 02:01 PM   #1
geomcd1949
LQ Newbie
 
Registered: Oct 2011
Location: North carolina
Distribution: Ubuntu
Posts: 10

Rep: Reputation: Disabled
how to save a file so that it can be opened in localhost


Am trying to rewire my brain circuits to use Linux instead of Windows. I installed a LAMP server (on Ubuntu 11.04) I get the "It works!" file from http://localhost/

I see the file path that leads to the default page: (index.html) in File System/var/www/index.html

When, using gedit, I attempt to save another file (test.php) in .../var/www/ , the system tells me it could not save the file, and that I don't have the required permissions.

It doesn't ask me for a password to allow me to save the file there.

I am the only user of the computer.

Assistance would be greatly appreciated!

Thanks.

~George
 
Old 10-04-2011, 02:06 PM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You'll need to use sudo to get the required privileges. See this and this for more info.
 
1 members found this post helpful.
Old 10-04-2011, 02:09 PM   #3
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

How did you run gedit to edit that file.

Run as follows:

Code:
sudo gedit /var/www/test.php
 
1 members found this post helpful.
Old 10-04-2011, 02:49 PM   #4
geomcd1949
LQ Newbie
 
Registered: Oct 2011
Location: North carolina
Distribution: Ubuntu
Posts: 10

Original Poster
Rep: Reputation: Disabled
Dear Nylex and Terminator,

Thanks for your kind replies. Please know that you are writing to a new Linux user. Let me explain my problem in a different way. Using Windows, any .html file can be opened in a browser. To open a .php file however, that file must be in the htdocs file in a XAMPP server, and the browser must access it through http://localhost

I am assuming the Linux var/www folder is like the Windows htdocs folder.

My question is, how do I, using Ubuntu, save a file (be it made in gedit or an IDE such as Quanta Plus) named test.php to the var/www folder [so that it can be opened using localhost]?

Thanks very much!

~George
 
Old 10-04-2011, 03:08 PM   #5
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Quote:
I am assuming the Linux var/www folder is like the Windows htdocs folder.
Yes, that is correct.

Here are the steps that I can suggest.

Code:
sudo vi test.php
By default when you open up the terminal your present working directory is /home/user/desktop

Copy the file from your desktop to /var/www

Code:
sudo cp /home/user/desktop/test.php /var/www/
Open up the browser and type:
Code:
http://localhost/test.php
 
1 members found this post helpful.
Old 10-04-2011, 04:54 PM   #6
geomcd1949
LQ Newbie
 
Registered: Oct 2011
Location: North carolina
Distribution: Ubuntu
Posts: 10

Original Poster
Rep: Reputation: Disabled
sudo cp /home/george/Desktop/test.php /var/www/

When I use the above command, it moves the file (test.php) to the /var/www/ folder. I can see that it is in that folder, and not corrupt. When I use localhost to open the .html file, it displays properly in the browser ("It works"). However, when I change the address to http://localhost/test.php, I get a popup that asks "What should Firefox do with this file?" I tried a second .php file, and it was moved to the /var/www/ folder, but again, the same popup appears instead of the web page.

Sadly, the sarcastic response you'd expect from a frustrated rookie is not given as an option in the popup.

My guess is that PHP is not installed/activated/working in LAMP. Is this a reasonable assumption, and if it is, should I start over and re-install LAMP?

Thanks!

~George
 
Old 10-04-2011, 05:24 PM   #7
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,504

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
I don't have LAMP installed on Ubuntu but the other Linux systems I have used always had these file in either /var/www/htdocs or /var/www/html. I guess that's not the case with Ubuntu?

Quote:
My guess is that PHP is not installed/activated/working in LAMP
I would guess that your guess is correct. There is something wrong with the php configuration but the problem is it could be any number of things. Wrong Document Root in php.ini, needed php modules not loaded as well as others.

What method did you use to install LAMP. The link below gives what looks like the simplest way?

http://www.multimediaboom.com/how-to...-0410-1010-04/
 
1 members found this post helpful.
Old 10-04-2011, 05:38 PM   #8
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Here is a link which explains similar issue: http://ubuntuforums.org/showthread.php?t=943570
 
1 members found this post helpful.
Old 10-04-2011, 06:16 PM   #9
geomcd1949
LQ Newbie
 
Registered: Oct 2011
Location: North carolina
Distribution: Ubuntu
Posts: 10

Original Poster
Rep: Reputation: Disabled
I followed the instructions in an article similar to this: http://ubuntuforums.org/showthread.php?t=943570

Neither gives an important step; restart the computer after installation.

After a restart, it works perfectly!

I'm wondering if I should have known this?

Thanks very much for the kind and generous assistance.

~George
 
Old 10-04-2011, 11:42 PM   #10
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,504

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
Usually, as indicated in a couple of the posts in your link, restarting Apache works. Any time you modify configuration files you need to restart Apache.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File Cannot be opened error Zssfssz Ubuntu 7 09-24-2011 01:54 AM
[SOLVED] Transferring from save file to save partition hda7 Puppy 2 05-04-2010 08:11 AM
File Opened by some application gaurav84 Linux - General 3 04-18-2008 01:29 AM
How to know whether a particular file is opened or not? kondrara Linux - Software 2 11-22-2007 04:08 AM
How to know whether a dev file has been opened or not? asahlot Linux - Software 2 03-05-2007 11:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration