So this is a bit of a debugging question, but I do not have any idea what else to try.

I am new to Magento and I wanted to set up a local instance of it to fiddle around. I followed effectively this tutorial. After everything is done, trying to open the Magento site on browser merely shows the index of the directory Magento is installed on, as shown below:

On the same machine, another test pure php page works fine.
I will post the Apache configuration of the site and the configuration of Magento as shown by the magento config:show command. Feel free to ask whatever other configuration or log is needed to find out what is happening.

Site Apache configuration:

<VirtualHost *:80>
     ServerAdmin admin@localhost
     DocumentRoot /var/www/magento2.4/pub

     <Directory /var/www/html/magento2.4/pub>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
#       Require all granted

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

Magento config output:

$ sudo -u www-data /var/www/magento2.4/bin/magento config:show
yotpo/module_info/yotpo_installation_date - 2021-05-08
yotpo/sync_settings/orders_sync_start_date - 2021-05-08
catalog/search/engine - elasticsearch7
catalog/search/elasticsearch7_server_hostname - localhost
catalog/search/elasticsearch7_server_port - 9200
catalog/category/root_id - 2
web/seo/use_rewrites - 1
web/unsecure/base_url - http://localhost/
general/locale/code - en_US
general/locale/timezone - America/Chicago
general/region/display_all - 1
general/region/state_required - AU,BG,BR,CA,CH,CN,CO,EE,ES,HR,IN,IT,LT,LV,MX,PL,RO,US,UY
currency/options/base - USD
currency/options/default - USD
currency/options/allow - USD
analytics/subscription/enabled - 1
crontab/default/jobs/analytics_subscribe/schedule/cron_expr - 0 * * * *
crontab/default/jobs/analytics_collect_data/schedule/cron_expr - 00 02 * * *
msp_securitysuite_recaptcha/frontend/enabled - 0
msp_securitysuite_recaptcha/backend/enabled - 0
twofactorauth/duo/application_key - FLUe5W1ndlNSCOt5ah5IUluRgIbO2ahoz8pWOVykoky06biGd0Aisvdw1slOIIfX
connector_dynamic_content/external_dynamic_content_urls/passcode - V1QrRRz31I7TUG0TZ1RDJZE7eRxFxaiR
connector_automation/review_settings/allow_non_subscribers - 1
connector_configuration/abandoned_carts/allow_non_subscribers - 1
sync_settings/addressbook/allow_non_subscribers - 1
connector_developer_settings/system_alerts/user_roles - 1

Elastic search ping command output:

$ curl -XGET localhost:9200
  "name" : "user-pc",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "RfVO4Tj6TcCQWwyDegap3g",
  "version" : {
    "number" : "7.12.1",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "3186837139b9c6b6d23c3200870651f10d3343b7",
    "build_date" : "2021-04-20T20:56:39.040728659Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  "tagline" : "You Know, for Search"

.htaccess file contents:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /pub/$0 [L]
DirectoryIndex index.php

Apache error log has nothing generated whenever I access the site.

Below are the contents added to the Apache access logs when I access the site: - - [09/May/2021:19:52:43 +0300] "GET / HTTP/1.1" 200 1036 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0" - - [09/May/2021:19:52:43 +0300] "GET /icons/blank.gif HTTP/1.1" 304 179 "http://localhost/" "Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0" - - [09/May/2021:19:52:43 +0300] "GET /icons/unknown.gif HTTP/1.1" 304 179 "http://localhost/" "Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0" - - [09/May/2021:19:52:43 +0300] "GET /icons/text.gif HTTP/1.1" 304 180 "http://localhost/" "Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0" - - [09/May/2021:19:52:43 +0300] "GET /icons/folder.gif HTTP/1.1" 304 179 "http://localhost/" "Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0"

Apache modules loaded:

$ apache2ctl -M
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 php7_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared)

I made sure multiple times to convert the permissions of all the files in the directory to www-data user, recursively.
Any help appreciated.

EDIT: So I changed my DocumentRoot to /var/www/magento2.4/pub. Now I get a page with no css apparently:

And every link I try is a 404:

The rest of the configuration is the same. pub folder has its own default .htaccess file.

  • is elastic search enabled ? Commented May 9, 2021 at 16:38
  • @VibhoreJain Yes, it is running, I will post the test curl command proving it.
    – Noob Doob
    Commented May 9, 2021 at 16:39
  • are you getting some error message or error from error logs. Commented May 9, 2021 at 16:41
  • I checked Apache's logs and they seemed fine, but I will post them. What other logs should I look into apart from that?
    – Noob Doob
    Commented May 9, 2021 at 16:43
  • So the problem I had not detected is, as is evident in the conf file, that I have set DocumentRoot /var/www/magento2.4/pub but for the rules I have <Directory /var/www/html/magento2.4/pub>, a whole html off. The joys of copy pasting code and only changing half of it.
    – Noob Doob
    Commented May 9, 2021 at 18:50

2 Answers 2


Your document root in your Apache virtual host needs to point to /pub directory. It’s mandatory now from v 2.4.2. See here for details. https://devdocs.magento.com/guides/v2.4/install-gde/tutorials/change-docroot-to-pub.html

Try updating your virtual host to following and restarting Apache

<VirtualHost *:80>
 ServerAdmin admin@localhost
 DocumentRoot /var/www/magento2.4/pub/

 <Directory /var/www/magento2.4/pub/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
  • .htaccess must change accordignly I suppose? Because the default one tries to rewrite request inside the pub folder.
    – Noob Doob
    Commented May 9, 2021 at 18:25
  • No because the pub directory has its own index.php and htaccess file. Web user will never hit the main directory if the document root is set to pub.
    – bernieu2
    Commented May 9, 2021 at 18:34
  • In your original virtual host file you have the main directory AllowOverride set to none. That’s why the main dir htaccess file redirect is being ignored and you’re just seeing the directory contents.
    – bernieu2
    Commented May 9, 2021 at 18:42
  • I had changed that part but had not updated in the question, did now.
    – Noob Doob
    Commented May 9, 2021 at 18:46
  • You had not observed it, but I had an extra http in the directory of the Directory rules that should not be there, due to copy pasting. Your conf made it work.
    – Noob Doob
    Commented May 9, 2021 at 18:53

Dowloand the .htaccess file to add to your project. https://github.com/magento/magento2/blob/2.4-develop/.htaccess The .htaccess is required when you run Magento 2 project with apache.

  • The .htaccess mentioned in the link you gave in your answer is identical to the one already existing in the project. Do you think there might be a problem in that an index.php is referred even though it does not exist in the directory?
    – Noob Doob
    Commented May 9, 2021 at 16:51
  • If it is exited in the project. Please check the rewrite module of apache hostadvice.com/how-to/… Install, enable it and then try to restart apache server.
    – Steve Pham
    Commented May 9, 2021 at 16:54
  • $ sudo a2enmod rewrite [sudo] password for user: Module rewrite already enabled
    – Noob Doob
    Commented May 9, 2021 at 17:21
  • If enable rewrite mode and restart apache2 doesn't help (Remember to restart the server) . You can try to change the folder config in apache to the pub folder of the project. The problem on seeing the directory file is on the .htaccess file and the rewrite module in my experience. You can try to use the Nginx for your local setup. SInce magento have a sample config file for Nginx.
    – Steve Pham
    Commented May 9, 2021 at 17:42
  • Ok I can look into nginx if I see no solution with Apache. Thank you!
    – Noob Doob
    Commented May 9, 2021 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.