I have a web page that is webpage.php. It shows up fine in localhost (ubuntu) except for the graphics. The header image, which is an img src, shows the alt text and carves out a space for the image. But the image does not show.
If I change the page to .html I can see everything in the browser. But, I cannot execute the .html page on local host at all.
I tried asking in a php group but they said this is really a problem with the html not functioning.
Marty <mart...@aol.com> writes:
> I have a web page that is webpage.php. It shows up fine in localhost > (ubuntu) except for the graphics. The header image, which is an img src, > shows the alt text and carves out a space for the image. But the image > does not show.
> If I change the page to .html I can see everything in the browser. But, I > cannot execute the .html page on local host at all.
> I tried asking in a php group but they said this is really a problem with > the html not functioning.
> Any suggestions?
The src attribute is wrong. Exactly how, it's impossible to say, partly
because your terminology is not clear. Here is my translation which you
can disavow if you like:
"I am running a web server on localhost. When I view webpage.php, the
main image does not appear. If I rename the file to webpage.html and
view it directly in a browser the image appears."
If that's what's happening, post the PHP and there's a change you will
get detailed assistance. The second most important data is the location
of the various files relative to each other.
You might also get fast answers if you uploaded the page and the image
to a publicly available server.
On Wednesday, November 7, 2012 6:00:42 PM UTC-5, Marty wrote:
> If I change the page to .html I can see everything in the browser. But, I > cannot execute the .html page on local host at all.
Do you mean that you can see the .html page when you view it remotely through the browser, but can't see it when you view it locally through the browser?
If so, perhaps there is a problem with the local server that you have running on Ubuntu.
No matter what, if you post your code, it will make things clear.
Marty wrote:
> I have a web page that is webpage.php. It shows up fine in localhost
> (ubuntu) except for the graphics. The header image, which is an img src,
> shows the alt text and carves out a space for the image. But the image
> does not show.
> If I change the page to .html I can see everything in the browser. But, I
> cannot execute the .html page on local host at all.
PHP is server side scripting where it outputs html. It sounds like you have invalid PHP code.
> I tried asking in a php group but they said this is really a problem with
> the html not functioning.
Probably not. If just changing the file extension to .html fixes your problem then what your problem is most likely is that you are not writing PHP code but HTML markup.
On Wed, 07 Nov 2012 20:46:21 -0500, Jonathan N. Little wrote:
> Marty wrote:
>> I have a web page that is webpage.php. It shows up fine in localhost
>> (ubuntu) except for the graphics. The header image, which is an img
>> src, shows the alt text and carves out a space for the image. But the
>> image does not show.
>> If I change the page to .html I can see everything in the browser. But,
>> I cannot execute the .html page on local host at all.
> PHP is server side scripting where it outputs html. It sounds like you
> have invalid PHP code.
>> I tried asking in a php group but they said this is really a problem
>> with the html not functioning.
> Probably not. If just changing the file extension to .html fixes your
> problem then what your problem is most likely is that you are not
> writing PHP code but HTML markup.
>> Any suggestions?
> Post the the source code.
I can save it as .html or .php and the results are the same. I can see everything formatted perfectly and I can see the alt text as well as the placeholder for the image. But the image does not display.
To simplify troubleshooting, I put the image and the source file in the same folder var/www. I use BlueFish editor and the preview or browser button is set up to display the file in LocalHost.
I edited the source file to get rid of as much crap as possible and still maintain the problem section:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My Title</title>
<meta name="description" content="My Descsription">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="msvalidate.01" content="5D6F360E7CD47C4B14275762DBC20BAA">
<link href="mystyle.php" rel="stylesheet" type="text/css">
Marty wrote:
> On Wed, 07 Nov 2012 20:46:21 -0500, Jonathan N. Little wrote:
>> Marty wrote:
>>> I have a web page that is webpage.php. It shows up fine in localhost
>>> (ubuntu) except for the graphics. The header image, which is an img
>>> src, shows the alt text and carves out a space for the image. But the
>>> image does not show.
>>> If I change the page to .html I can see everything in the browser. But,
>>> I cannot execute the .html page on local host at all.
>> PHP is server side scripting where it outputs html. It sounds like you
>> have invalid PHP code.
>>> I tried asking in a php group but they said this is really a problem
>>> with the html not functioning.
>> Probably not. If just changing the file extension to .html fixes your
>> problem then what your problem is most likely is that you are not
>> writing PHP code but HTML markup.
>>> Any suggestions?
>> Post the the source code.
> I can save it as .html or .php and the results are the same. I can see
> everything formatted perfectly and I can see the alt text as well as the
> placeholder for the image. But the image does not display.
> To simplify troubleshooting, I put the image and the source file in the
> same folder var/www. I use BlueFish editor and the preview or browser
> button is set up to display the file in LocalHost.
> I edited the source file to get rid of as much crap as possible and still
> maintain the problem section:
> On Wed, 07 Nov 2012 20:46:21 -0500, Jonathan N. Little wrote:
>> Marty wrote:
>>> I have a web page that is webpage.php. It shows up fine in localhost
>>> (ubuntu) except for the graphics. The header image, which is an img
>>> src, shows the alt text and carves out a space for the image. But the
>>> image does not show.
>>> If I change the page to .html I can see everything in the browser. But,
>>> I cannot execute the .html page on local host at all.
>> PHP is server side scripting where it outputs html. It sounds like you
>> have invalid PHP code.
>>> I tried asking in a php group but they said this is really a problem
>>> with the html not functioning.
>> Probably not. If just changing the file extension to .html fixes your
>> problem then what your problem is most likely is that you are not
>> writing PHP code but HTML markup.
>>> Any suggestions?
>> Post the the source code.
> I can save it as .html or .php and the results are the same. I can see
> everything formatted perfectly and I can see the alt text as well as the
> placeholder for the image. But the image does not display.
> To simplify troubleshooting, I put the image and the source file in the
> same folder var/www. I use BlueFish editor and the preview or browser
> button is set up to display the file in LocalHost.
> I edited the source file to get rid of as much crap as possible and still
> maintain the problem section:
On Thu, 08 Nov 2012 02:56:17 +0000, Marty wrote:
> I edited the source file to get rid of as much crap as possible and
> still maintain the problem section:
No you didn't. If the problem is displaying the image, then it should be apparent in the following (and arguably the <p> and </p> could be omnitted):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My Title</title>
</head>
<body>
<p>
<img src="problemfile.jpg" alt="problem image" height="220" width="700">
</p>
</body>
</html>
As a general observation, if you use a content-type http pseudo header in the document head, some people suggest that best practice is to place it as the first element in the <head>, as it may require that the document be re-parsed - the sooner the browser can make this decision the less time it wastes parsing stuff that will become redundant when it starts again.
Also - as an aside - in a "normal"[1] apache web server + php configuration, if a file called something.php contains only html markup and no <?php ... ?> code sections, the php processor will pass it unaltered to the web server process for sending to the requesting client.
[1] every configuration is different, but there are some things that most configurations will do the same way.
On Thu, 08 Nov 2012 02:56:17 +0000, Marty wrote:
> On Wed, 07 Nov 2012 20:46:21 -0500, Jonathan N. Little wrote:
>> Marty wrote:
>>> I have a web page that is webpage.php. It shows up fine in localhost
>>> (ubuntu) except for the graphics. The header image, which is an img
>>> src, shows the alt text and carves out a space for the image. But the
>>> image does not show.
>>> If I change the page to .html I can see everything in the browser.
>>> But,
>>> I cannot execute the .html page on local host at all.
>> PHP is server side scripting where it outputs html. It sounds like you
>> have invalid PHP code.
>>> I tried asking in a php group but they said this is really a problem
>>> with the html not functioning.
>> Probably not. If just changing the file extension to .html fixes your
>> problem then what your problem is most likely is that you are not
>> writing PHP code but HTML markup.
>>> Any suggestions?
>> Post the the source code.
> I can save it as .html or .php and the results are the same. I can see
> everything formatted perfectly and I can see the alt text as well as the
> placeholder for the image. But the image does not display.
> To simplify troubleshooting, I put the image and the source file in the
> same folder var/www. I use BlueFish editor and the preview or browser
> button is set up to display the file in LocalHost.
> I edited the source file to get rid of as much crap as possible and
> still maintain the problem section:
Forget the code above. I see it has a lot of distracting elements. Here is an HTML file. The problem is the same. I cannot display the image in LocalHost. By the way, the same code will display properly on a browser. It just will not work with localhost. So, I do not think it is an html problem at all. Know of any newsgroups that could help with a localhost problem?
Could it be the doctype statement?
By the way, you most certainly can have a .php for a css file. Doing so enables you to do lot of other things as well. It works perfectly in a regular browser.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My Title</title>
<meta name="description" content="My Descsription">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> Or are you running apache on your machine, with the image and html files
> in the proper place so that you can put http://localhost/problem.html > into your browser?
That seems to be the natural interpretation. Now, we might conjecture that the server software sends wrong information in HTTP headers. We just need to hack into the OP's system to check that... wait a sec...
Marty wrote:
> Forget the code above. I see it has a lot of distracting elements. Here
> is an HTML file. The problem is the same. I cannot display the image in
> LocalHost. By the way, the same code will display properly on a browser.
> It just will not work with localhost. So, I do not think it is an html
> problem at all. Know of any newsgroups that could help with a localhost
> problem?
Wait a minute, by the above are you saying that it works if your view is using your local filesystem but fails using the server? IOW
Marty wrote:
> On Wed, 07 Nov 2012 20:46:21 -0500, Jonathan N. Little wrote:
>> Marty wrote:
>>> I have a web page that is webpage.php. It shows up fine in localhost
>>> (ubuntu) except for the graphics. The header image, which is an img
>>> src, shows the alt text and carves out a space for the image. But the
>>> image does not show.
>>> If I change the page to .html I can see everything in the browser. But,
>>> I cannot execute the .html page on local host at all.
>> PHP is server side scripting where it outputs html. It sounds like you
>> have invalid PHP code.
>>> I tried asking in a php group but they said this is really a problem
>>> with the html not functioning.
>> Probably not. If just changing the file extension to .html fixes your
>> problem then what your problem is most likely is that you are not
>> writing PHP code but HTML markup.
>>> Any suggestions?
>> Post the the source code.
> I can save it as .html or .php and the results are the same. I can see
> everything formatted perfectly and I can see the alt text as well as the
> placeholder for the image. But the image does not display.
> To simplify troubleshooting, I put the image and the source file in the
> same folder var/www. I use BlueFish editor and the preview or browser
> button is set up to display the file in LocalHost.
> I edited the source file to get rid of as much crap as possible and still
> maintain the problem section:
On Thu, 08 Nov 2012 15:50:51 +0000, Marty wrote:
> Know of any newsgroups that could help with a localhost
> problem?
First of all, there is no such thing as a localhost problem, the problem is either with your local webserver configuration, or with your html. Do you even have a local webserver running?
If that shows several entries, then the webserver seems to be running. Try typing the following 2 lines, both followed by return (note there may be no visible response to the 'nc localhost 80', just type the GET anyway.):
nc localhost 80
GET /webpage.php
This should display the content that your php file generates and delivers via the webserver.
If the 'nc localhost 80' returns a normal (eg name@host$) prompt, then it's possible your webserver, although running, isn't active on the expected port.
Try the following command:
sudo netstat -t -l -p -v | grep http
This should output a line similar to the one below (the 1269 will probably be a different number, and I've trimmed some whitespace):
tcp 0 0 *:http *:* LISTEN 1269/apache2
Finally, try opening the browser and enter the following in the location bar:
Where name.ext is the name and extension of your image file. If the image file is in the root directory of the web server, then it should display in the browser. If it does not display, then either:
a) There's no browser running
b) The file is not where the server is looking for it
On Thu, 08 Nov 2012 22:00:09 +0000, Denis McMahon wrote:
> On Thu, 08 Nov 2012 15:50:51 +0000, Marty wrote:
>> Know of any newsgroups that could help with a localhost problem?
> First of all, there is no such thing as a localhost problem, the problem
> is either with your local webserver configuration, or with your html. Do
> you even have a local webserver running?
> If that shows several entries, then the webserver seems to be running.
> Try typing the following 2 lines, both followed by return (note there
> may be no visible response to the 'nc localhost 80', just type the GET
> anyway.):
> nc localhost 80 GET /webpage.php
> This should display the content that your php file generates and
> delivers via the webserver.
> If the 'nc localhost 80' returns a normal (eg name@host$) prompt, then
> it's possible your webserver, although running, isn't active on the
> expected port.
> Try the following command:
> sudo netstat -t -l -p -v | grep http
> This should output a line similar to the one below (the 1269 will
> probably be a different number, and I've trimmed some whitespace):
> tcp 0 0 *:http *:* LISTEN 1269/apache2
> Finally, try opening the browser and enter the following in the location
> bar:
> Where name.ext is the name and extension of your image file. If the
> image file is in the root directory of the web server, then it should
> display in the browser. If it does not display, then either:
> a) There's no browser running b) The file is not where the server is
> looking for it
> Rgds
> Denis McMahon
I get You don't have permission to access /imagefile.jpg on this server. When I do localhost/imagefile.jpg
Marty wrote:
> I get You don't have permission to access /imagefile.jpg on this server.
> When I do localhost/imagefile.jpg
Your server is not setup properly. This is not an HTML problem this is a Apache server setup problem, (assuming your are using Apache). Or your have a permission problem, for example you put the file with your profile and image is neither wwwdata user or group (marty:marty) OR your file is not world readable (660).
On Thu, 08 Nov 2012 20:25:10 -0500, Jonathan N. Little wrote:
> Marty wrote:
>> I get You don't have permission to access /imagefile.jpg on this
>> server.
>> When I do localhost/imagefile.jpg
> Your server is not setup properly. This is not an HTML problem this is a
> Apache server setup problem, (assuming your are using Apache). Or your
> have a permission problem, for example you put the file with your
> profile and image is neither wwwdata user or group (marty:marty) OR your
> file is not world readable (660).
> sudo chown -R wwwdata:wwwdata /var/www/*
I know next to nothing about linux commands. Is it a chown I need to use or a chmod? Is the syntax you show here correct?
Marty wrote:
> On Thu, 08 Nov 2012 20:25:10 -0500, Jonathan N. Little wrote:
>> Marty wrote:
>>> I get You don't have permission to access /imagefile.jpg on this
>>> server.
>>> When I do localhost/imagefile.jpg
>> Your server is not setup properly. This is not an HTML problem this is a
>> Apache server setup problem, (assuming your are using Apache). Or your
>> have a permission problem, for example you put the file with your
>> profile and image is neither wwwdata user or group (marty:marty) OR your
>> file is not world readable (660).
>> sudo chown -R wwwdata:wwwdata /var/www/*
> I know next to nothing about linux commands. Is it a chown I need to use
> or a chmod? Is the syntax you show here correct?
chown changes the owner and group
chmod change the permission for owner, group, and world.
Depends on what you need to do. I am assuming that your server's document root is /var/www if so then post the output of the following:
ls -lha /var/www
if your document root is different change accordingly
Marty <mart...@aol.com> writes:
> On Thu, 08 Nov 2012 20:25:10 -0500, Jonathan N. Little wrote:
>> Marty wrote:
>>> I get You don't have permission to access /imagefile.jpg on this
>>> server.
>>> When I do localhost/imagefile.jpg
>> Your server is not setup properly. This is not an HTML problem this is a
>> Apache server setup problem, (assuming your are using Apache). Or your
>> have a permission problem, for example you put the file with your
>> profile and image is neither wwwdata user or group (marty:marty) OR your
>> file is not world readable (660).
>> sudo chown -R wwwdata:wwwdata /var/www/*
> I know next to nothing about linux commands. Is it a chown I need to use > or a chmod? Is the syntax you show here correct?
Yes, chown not chmod (though if things are really screwed you might need
that as well) and, yes, the syntax is correct. It's something of a
sledgehammer, but with little information to go on it seems like a good
start. He's assuming that there is some permission problem and the
easiest solution is to make everything owned by the user id that the
apache server uses (that's wwwdata). The ":wwwdata" bit also sets the
group id that owns the files which is probably overkill, but won't do
any harm.
The meta answer is to type man sudo and then man chown. You won't
understand all of what you see but, in general, the basics are up the
top so you can read until you get baffled. Do that enough and you'll
find you don't get baffled so much after a while.
Ben Bacarisse wrote:
> Marty <mart...@aol.com> writes:
>> On Thu, 08 Nov 2012 20:25:10 -0500, Jonathan N. Little wrote:
>>> Marty wrote:
>>>> I get You don't have permission to access /imagefile.jpg on this
>>>> server.
>>>> When I do localhost/imagefile.jpg
>>> Your server is not setup properly. This is not an HTML problem this is a
>>> Apache server setup problem, (assuming your are using Apache). Or your
>>> have a permission problem, for example you put the file with your
>>> profile and image is neither wwwdata user or group (marty:marty) OR your
>>> file is not world readable (660).
>>> sudo chown -R wwwdata:wwwdata /var/www/*
>> I know next to nothing about linux commands. Is it a chown I need to use
>> or a chmod? Is the syntax you show here correct?
> Yes, chown not chmod (though if things are really screwed you might need
> that as well) and, yes, the syntax is correct.
Yes is is possible to have it work with neither the owner or the group set to wwwdata if world is set to read. But
-rw-rw---- marty marty imagefile.jpg
would give him the problem that he is experiencing and simply turning on world read would fix it.
More info would help and that is why I ask for a listing of the dir. For a private server to make thing easier to edit locally there are things you can do to simplify the process. If you access the server from Windows workstations you can make a samba share to the document root and used "force group = wwwdata". Or if you access from Linux on the local machine then edit apache config to set
"export APACHE_RUN_GROUP=marty"
On Thu, 08 Nov 2012 20:25:10 -0500, Jonathan N. Little wrote:
> sudo chown -R wwwdata:wwwdata /var/www/*
Bad advice.
He said he's using Ubuntu. On my Ubuntu server, the web user is www-data, not wwwdata! This was the default user name set up by the installer.
What he could do is either of the following:
Method:
Easy Method A makes all the files in the /var/www tree the property of the apache process.
1) sudo cat /etc/passwd | grep www
Hopefully there's only one line, and it will look something like:
www-user:x:999:999:www-group:/var/www:/bin/sh
The fields are separated by the colon characters.
user name : password : user id : group id : group name : home : shell
A password of "x" means an encrypted password is stored in another file.
2) Get the user name and group name from above line (which in this case is www-user:www-group)
3) sudo chown -R wwwdata:wwwdata /var/www/*
Easy Method B:
Method B allows anyone to read all the files in the /var/www tree, regardless of who actually owns them.
sudo chmod -R w+r /var/www/*
There are other methods, but they all require more knowledge of linux users, groups and permissions than I'm prepared to contemplate getting into with Marty here.
> Ben Bacarisse wrote:
>> Marty <mart...@aol.com> writes:
>>> On Thu, 08 Nov 2012 20:25:10 -0500, Jonathan N. Little wrote:
>>>> Marty wrote:
>>>>> I get You don't have permission to access /imagefile.jpg on this
>>>>> server.
>>>>> When I do localhost/imagefile.jpg
>>>> Your server is not setup properly. This is not an HTML problem this is a
>>>> Apache server setup problem, (assuming your are using Apache). Or your
>>>> have a permission problem, for example you put the file with your
>>>> profile and image is neither wwwdata user or group (marty:marty) OR your
>>>> file is not world readable (660).
>>>> sudo chown -R wwwdata:wwwdata /var/www/*
>>> I know next to nothing about linux commands. Is it a chown I need to use
>>> or a chmod? Is the syntax you show here correct?
>> Yes, chown not chmod (though if things are really screwed you might need
>> that as well) and, yes, the syntax is correct.
> Yes is is possible to have it work with neither the owner or the group
> set to wwwdata if world is set to read. But
> -rw-rw---- marty marty imagefile.jpg
> would give him the problem that he is experiencing and simply turning
> on world read would fix it.
Sure, but (to rather labour this detail) my point about maybe needing
both is just that if user and group read permission are missing,
changing the owner won't do it.
> More info would help and that is why I ask for a listing of the
> dir.
Absolutely. Further hints can also come from the error log.
To the OP: have a look at the error log. On my setup I just do
tail /var/log/apache2/error.log
to see that last few entries. When there is a misconfiguration you
might get lots of errors, in which case viewing the whole file is more
useful.
Denis McMahon <denismfmcma...@gmail.com> writes:
> On Thu, 08 Nov 2012 20:25:10 -0500, Jonathan N. Little wrote:
>> sudo chown -R wwwdata:wwwdata /var/www/*
> Bad advice.
> He said he's using Ubuntu. On my Ubuntu server, the web user is www-data, > not wwwdata!
Well spotted!
> This was the default user name set up by the installer.
> What he could do is either of the following:
> Method:
> Easy Method A makes all the files in the /var/www tree the property of > the apache process.
> 1) sudo cat /etc/passwd | grep www
Or just "sudo grep www /etc/passwd". Indeed, on my default install (and
I think on many) there's no need for the sudo since /etc/passwd is
readable by all.
> Hopefully there's only one line, and it will look something like:
> www-user:x:999:999:www-group:/var/www:/bin/sh
Just to clarify (since the OP is new to this) you are most likely to see
www-data in both places.
> The fields are separated by the colon characters.
> user name : password : user id : group id : group name : home : shell
> A password of "x" means an encrypted password is stored in another file.
> 2) Get the user name and group name from above line (which in this case > is www-user:www-group)
> 3) sudo chown -R wwwdata:wwwdata /var/www/*
I think you meant to edit that!
> Easy Method B:
> Method B allows anyone to read all the files in the /var/www tree, > regardless of who actually owns them.
> sudo chmod -R w+r /var/www/*
I think you meant:
sudo chmod -R o+r /var/www/*
> There are other methods, but they all require more knowledge of linux > users, groups and permissions than I'm prepared to contemplate getting > into with Marty here.
It's a nightmare trying to guess what might or might not be wrong here.
I am still not convinced it's a file permission or ownership thing,
since the defaults work without change (at least on my setup) but
something is wrong so permissions do need to be checked.
On Fri, 09 Nov 2012 13:10:16 +0000, Ben Bacarisse wrote:
> Denis McMahon <denismfmcma...@gmail.com> writes:
>> 2) Get the user name and group name from above line (which in this case
>> is www-user:www-group)
>> 3) sudo chown -R wwwdata:wwwdata /var/www/*
> I think you meant to edit that!
Yes, it should have been something like:
3) Use the following, substituting the user name and group name from step 2 for user and group:
sudo chown -R user:group /var/www/*
>> sudo chmod -R w+r /var/www/*
> I think you meant:
> sudo chmod -R o+r /var/www/*
Damn it, I'm on a roll today. :(
Yes, I did, and in my defence, I still make the w+r (world+read) mistake myself regularly, especially if I haven't had to chmod anything for a few days.
> No, a stylesheet can have any name at all, and any (or no) extension.
> -- > For more than a thousand generations the Jedi were the guardians of
> peace and justice in the galaxy. Before the dark times. Before the
> Empire.