After LAMP stack tutorials, I can't find my site on localhost

Posted October 7, 2019 9.3k views

I’m a student trying to figure out how to get LAMP stack working on my laptop for Ubuntu 18.04. I need it for a project I’m working on at school and out of school.

I followed a few tutorials,


to make a long story short, I set my domain as abc and this is me looking at it in terminal

Skynet:/var/www/abc$ ls
index.html websitedirectory

index.html is from the second tutorial and displays:
“Success! The your_domain virtual host is working!”
The index.html works fine and displays when I go to url localhost in firefox. If I try to do localhost/websitedirectory I get a blank page and if I try to do (I added login.php into /etc/apache2/mods-enabled/dir.conf to prioritize it) I also get a blank page. I’m not really sure what I’m doing wrong and how I can get my actual site to display using the LAMP stack. I was using the lampp package from and I had my site working with that, but I’m trying to figure out how to use it with LAMP stack instead and to apply it to real world situations.

Would anyone be able to clarify this for me and explain what I’m doing wrong. Thank you in advance.

Big thank you to the tutorial authors:
Justin Ellingwood, Kathleen Juell, and Mark Drake

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

What happens if you enter the full path in your browser - localhost/abc/subdirectory/index.php

Also are you using an .htaccess file and if so can you place the content of it here?

  • for localhost/abc/subdirectory/index.php i get the same Not Found The requested URL was not found on this server.

    yes, I’m using .htaccess

    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile /etc/phpmyadmin/.htpasswd
    Require valid-user
  • I got it working. I was doing 2 things wrong. #1 I had a missing database connection which was causing the blank white screen to load. After adding the db the page loaded. Also when using localhost/ one doesn’t need to provide the full path like localhost/abc/index.php instead use localhost/index.php and that will display the site (at least on a linux machine.) The full path /var/www/your_domain I guess is included when using localhost/ in the URL so using localhost/your_domain/index.php is redundant and results an error.

Hello, @Pachuca

Can you please check if mod_rewrite is enabled? You can check it via this command:

httpd -M | grep rewrite

Also, please make sure that the site files are located in the same directory where your apache virtual hosts - document root is pointing to.

Let me know how it goes.

  • that command doesn’t work for me.

    Skynet:/var/www$httpd -M | grep rewrite
    Command 'httpd' not found, did you mean:
      command 'http' from snap http (1.0.2-1)
      command 'xttpd' from deb xtide
      command 'http' from deb httpie
    See 'snap info <snapname>' for additional versions.
    • I’m sorry httpd is for CentOS, for Ubuntu is:

      apache2ctl -M

      You can try:

      apache2ctl -M | grep rewrite

      Let me know how it goes.

      • Thank you for your help. So far I’m not getting anything from that

        Skynet:~$ apache2ctl -M | grep rewrite
        • It might not be enabled.

          Can you please run this command to enable it:

          sudo a2enmod rewrite

          then restart apache:

          sudo systemctl restart apache2

          Check again if mod_rewrite is enabled:

          apache2ctl -M | grep -i rewrite

          If it’s okay/enabled check your site if it’s loading.

          Let me know how it goes.

          • great that did something

            Skynet:/var/www/abc$ apache2ctl -M | grep -i rewrite
             rewrite_module (shared)

            BUT when I visit localhost/abc i’m getting the below instead of a blank page.

            Not Found
            The requested URL was not found on this server.
            Apache/2.4.41 (Ubuntu) Server at localhost Port 80

            My index.php file for the site is in a sub directory of abc so the full path is like localhost/abc/subdirectory/index.php even when I put that into the url I’m getting the same result. I can’t even see the directories from localhost/abc/ or localhost/.

            this is my virtual host file in /etc/apache2/sites-available/abc.conf

            <VirtualHost *:80>
                ServerAdmin webmaster@localhost
                ServerName abc
                DocumentRoot /var/www/abc
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

            I was a little confused at this step. Is the way the Server* should be setup correct in terms of url and root path? I don’t know if I did it right.

            Also I only enabled Apache for ufw and not Apache Full, I don’t know if that makes any difference either.