0

Hi all, I installed Ubuntu Server with the LAMP package and there is behavior I don't understand. If I access the web server by its local IP, my browser will display the index.html file located at /var/www/index.html, and PHP apparently works. But if I try to access it over the internet (using my cellphone's connection), the browser loads the index.html file located at /var/lib/tomcat6/webapps/ROOT/index.html (I have no idea why), and PHP does not work properly -- for example if I enter

<?php echo '<p>Hello World</p>'; ?>

the browser displays

Hello World
'; ?>

Which seems like PHP is not being interpreted correctly, even though the same code works when being loaded locally under /var/www/.

I'm not sure if it's related but I'm using a non-standard port for website because of ISP port blocking. I just configured my router to forwrad that non-standard port to the Ubuntu server's private IP.

Hopefully someone will be able to recognize some basic configuration issue here. Thanks!

2
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by fobos
0

if your getting Hello World '; ?> it means that its echoing part of of the string.
if it wasnt working, 1) would be able to view the php page, 2) it would write it just as you have it <?php... ?>.

just write it, but try phpinfo() first

<?php phpinfo(); ?>
<?php echo "hello world"; ?>
<? echo "hello world"; ?>

Edited by fobos: n/a

0

Thanks for the reply. phpinfo() does not work in that directory, it just return a blank page. Even

<?php echo "hello world"; ?>

returns a blank page. For some reason only

<?php echo '<p>Hello World</p>'; ?>

is returning any text.

Is it even normal for "tomcat6" to be used in default Ubuntu Server LAMP setup? These PHP codes all work when placed in a file under /var/www/.

0

var/www/ is the root folder where all your php documents should go. If it works there, that means that its the root directory. Trying running phpinfo in that folder.

0

var/www/ is the root folder where all your php documents should go. If it works there, that means that its the root directory. Trying running phpinfo in that folder.

Yes but the problem now is not running php locally but accessing the server remotely. I can't use port 80 due to blocking by the ISP. I can't or shouldn't use port 8080 that seems to be forwarded to a different service. I haven't figured out how to use the other ports, which is the question.

0

Oh ok. Im glad you found the issue and it is working. Please mark the thread solved.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.