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!

Recommended Answers

All 7 Replies

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"; ?>

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/.

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.

OK, I suspect it's because I used a custom port that happens to be the default port (8080) used by tomcat6:
http://www.ubuntugeek.com/how-to-install-tomcat-6-on-ubuntu-9-04-jaunty.html

I just tried to forward different ports to the server, but they don't work. I wonder why port 8080 is accessible but other ports are not, is there a configuration file on the server that is responsible?

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.