Why can't I access to my localhost website after setuping apache webserver on ubuntu?

Viewed 89

I want to setup a local apache server with a lamp stack. I am using Ubuntu ( I use the last released version ). I followed a tutorial that I found on the french documentation so here is what I did :

I entered the following command in the terminal to install the essentials tools : sudo apt install apache2 php libapache2-mod-php mysql-server php-mysql Then I installed and setup phmyadmin ,it seems to work and I can access it via localhost/phpmyadmin so I think I have done it correctly ( localhost works, I land on the apache welcome page ).

The issue is to access to my project via the browser. As the tutorial said it, I created a configuration file to give the information to apache about my project location, the tutorial said to create the configuration file in /etc/apache2/sites-available/ my file is named location.com.conf ( the tutorial file is named example.com.conf )

Here is the content of this file that I filled following the tutorial :

<VirtualHost *:80>
    ServerName location.com
    ServerAlias www.location.com
    DocumentRoot "/var/www/location/"
    <Directory "/var/www/location/">
        Options FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/error.location.com.log
    CustomLog /var/log/apache2/access.location.com.log combined
</VirtualHost>

I put my project folder in /var/www/ ( and the project name is "location" so the full path of my project files is /var/www/location/ ) Here is a screenshoot if it can help :

enter image description here

I also ran the following commands after that : ( Because they said to do it in the tutorial, I figured out that it is used to activate the website project on apache after a little bit of research ) :

sudo a2ensite location.com sudo systemctl reload apache2

It seems to recnogize what location.com means because if I try to do it several times it tells me that it is already activated ( and if I try for instance sudo a2ensite thrkrthrth.com it tells me that he doesn't know what thrkrtf.. is )

The problem is that when I try to go on localhost/location or localhost/location.com or 127.0.0.1/location or 127.0.0.1/location.com it just does not works, here is a screenshoot if it can help :

enter image description here I get this result everytime ( I also tried just location.com or www.location.com, I know it is dumb but maybe it could have work, I obviously just arrive on a random website named location.com )

Can you help me please ? Thank you EDIT : I just found out, by accident that if I go in the file called "000-default.conf" in apache2/sites-available there is a line that was : "DocumentRoot /var/www/html/" I changed it to "DocumentRoot /var/www/" just to try and now I can access to localhost/location but I have to type localhost/www/phpmyadmin, I guess it is a dirty way to do so I just add this as a new hint that may help to know where does the issue come from and how to solve it, I still need help please. I would like to be able to access to phpmyadmin by just typing localhost/phpmyadmin as usual and to access to my website using localhost/location

1 Answers

The correct path is /var/www/html/myweb/ not /var/www/myweb/ . Change DocumentRoot "/var/www/html/myweb/" and <Directory "/var/www/html/myweb/"> . Also o must have a file index.html there . On the browser write http://localhost and the apache server will run the index.html . But if you want o can run http://localhost/myweb/myfile.html if you have myfile.html there. Also, you can run http://localhost/location , but you must have a index.html on the location directory. For exemple http://localhost/myweb/myfile.php will run the that php myfile.php . You can have a index.php and write on the browser http://localhost/myweb

Related