Deploying a Laravel Project in a LAMP Ubuntu 20.4 Droplet. error 404 when trying to access with my domain

Posted December 10, 2021 128 views
ApacheLAMP StackLaravel

Good afternoon,

I do not have much knowledge of servers and I am having problems configuring my virtual host environment.
In addition to setting up a lamp environment, I have created a domain and created a certificate within the droplet.
But when I access my web from the ip, it does load although it gives me an error when downloading the images.
But when I try to access from the domain, I get a 404 error.

Attached virtual host configuration


<VirtualHost *:80>
    ServerAdmin *****
    DocumentRoot /var/www/notasweb/public

    <Directory /var/www/notasweb/public/>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.cgi index.html index.xhtml index.htm

    RewriteEngine on
    RewriteCond %{SERVER_NAME} [OR]
    RewriteCond %{SERVER_NAME}
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ServerName localhost

If you need more information do not hesitate to ask me.
Please could you help me.

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
1 answer

Hi there,

It sounds like Mod Rewrite is not enabled. You can do that with the following command:

sudo a2enmod rewrite

After that restart Apache to make sure that it loads the new module:

sudo systemctl restart apache2

Let me know how it goes.

  • Hi Bobby,

    I have tried to execute the two commands that you indicate, but I still have the same problem.

    Redirects me to a Digitalocean page, where it asks me to log into the droplet via ssh and configure my LAMP installation.

    Thanks for your help


    • Hi there,

      There are a few more things that I could suggest:

      • I can see that you have a redirect for HTTP to HTTPS but there is no SSL certificate installed yet. Make sure to install an SSL certificate before you add the redirect:

      • If you no longer need the default Apache configuration you can remove it with the a2dissite default command. That way the default page will no longer show up.

      • Alternatively, I would personally use Nginx and the LaraSail tool to do all of my initial server configuration for Laravel and automate the creation of additional websites:

      Let me know how it goes.

      by Erika Heidi
      Let's Encrypt is a Certificate Authority (CA) that facilitates obtaining and installing free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. Currently, the entire process of obtaining and installing a certificate is fully automated on both Apache and Nginx with the use of Certbot. In this guide, we'll use Certbot to obtain a free SSL certificate for Apache on Ubuntu 20.04, and make sure this certificate is set up to renew automatically.