Techno Z
Posts: 1
Joined: Tue Aug 29, 2017 11:14 pm

Apache 2 not working??

Tue Aug 29, 2017 11:39 pm

Hi there,
I am trying to build a web server with Apache 2. It seems to work fine, but I can't figure out how to edit the server contents. :roll:

When I installed everything I needed to and tested the server out, (It worked. :D ) I was told that to edit it, I needed to go to the terminal and type:

Code: Select all

sudo rm /var/www/index.html
It didn't work, ( :cry: ). It said that it couldn't find the file, even though I looked through the File Manger and found it myself. What this line of code does is deletes the server contents from the raspberry pi entirely, and I was supposed to type in this next:

Code: Select all

nano /var/www/index/php
This should replace the contents with a clean PHP file for me to edit. That didn't work either.
I tried this next:

Code: Select all

sudo nano /var/www/index.html
That will allow me to edit the server contents. That one worked :D .What I am trying to do is to display the date and time. I put this into the terminal to place into the server:

Code: Select all

<h1>The date and time</h1> 
<?php echo date ('Y-m-d H:i:s');
Okay. Now what? Is there a button to save the file?? I was told to refresh the page and then my results would show. They didn't! :evil: I followed exactly what my guide told me to do and it didn't work.

Does anyone know how to use Apache 2 correctly?

Thx,
Techno Z :P

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Apache 2 not working??

Wed Aug 30, 2017 10:47 am

The correct directory is
/var/www/html/
The correct default file is
index.html
The correct file for using PHP on the default page is
index.php
But you must remove index.html to use it.

edit: Insure you have installed php, then

Code: Select all

<?php echo date('Y-m-d H:i:s') ?>

Canedje
Posts: 263
Joined: Thu Mar 26, 2015 7:18 am

Re: Apache 2 not working??

Wed Aug 30, 2017 11:16 am

The directory changed indeed at Apache2 to: /var/www/html/
I had some troubles in the beginning recognizing the change.
By the way it is possible to change the standard html directory back to /var/www in an apache setup file. (I don't remember which setup file anymore)

User avatar
DougieLawson
Posts: 36316
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Apache 2 not working??

Wed Aug 30, 2017 10:23 pm

Edit /etc/apache2/sites-enabled/000-default.conf change

Code: Select all

DocumentRoot /var/www/html
to

Code: Select all

DocumentRoot /var/www
. Restart apache2 and it will switch from /var/www/html to /var/www.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Troubleshooting”