Ubuntu server 18.04 apache2 how to change the default page?

7,879

You need to change document root of apache2

leonid@DevSSD:~$ cat /etc/apache2/apache2.conf |grep DocumentRoot
leonid@DevSSD:~$ cat /etc/apache2/sites-available/000-default.conf |grep DocumentRoot
    DocumentRoot /var/www/html

Above commands not find documentroot in main config, but find it in default virtualhost config, run commands and find out where this setting located. Edit file by sudo nano /etc/apache2/sites-available/000-default.conf
Change DocumentRoot to your site folder /var/www/html/oscommerce/, then restart apache2 by systemctl reload apache2

Update: Apache gives permission error in two cases, first when file permissions not allowing apache2 to read folder/file, when folder requested, e.g. / at end of request line but no index file found.
To fix file/folder permissions:

sudo chown -R youruser:www-data /var/www
sudo chmod -R u=rwX,g=rX,o= /var/www

Additionaly, if web application writes something to some folder, like templates_cache, give that folder write permissions for group.

For index type of error look for DirectoryIndex option in config files

Edited by User asking the question. The way I fixed this issue is by changing the DocumentRoot for my site config and also creating a index.html file to redirect from the DocumentRoot to the site Index.html

   <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Refresh" content="5; URL='https://myIPaddress/oscommerce/catalog/index.php'" />
</head>
<body>

</body>
</html>
Share:
7,879

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I will keep this short. I am trying to figure out how to change the default page for apache2 to point at my oscommerce site instead by default. I have deleted the default index.html file.

    As of now I have to type: https://myIPaddress/oscommerce/catalog

    My default install location for oscommerce is: /var/www/html/oscommerce/

    What I want to type to get to the oscommerce site: https://myIPaddress

    I have created a oscommerce.conf file but I am unsure how to get apache2 to point to the site. Sorry if I am missing information. I am new to linux and I will give more information as needed. This is what I am running into at this time Index /

  • LeonidMew
    LeonidMew about 5 years
    Are there index.html or index.php or some other index in /var/www/html/oscommerce/?
  • LeonidMew
    LeonidMew about 5 years
    Are myipaddress/catalog working? Do you have some site files outside catalog? What files are in /var/www/html/oscommerce/ ? You may point documentroot to /var/www/html/oscommerce/catalog but I don't know if it correct, as don't know your app structure.
  • LeonidMew
    LeonidMew about 5 years
    its wrong - /var/www/html/oscommerce/catalog/index.php. It should be DocumentRoot /var/www/html/oscommerce/catalog/ without file name. Don't forget to restart apache after change
  • LeonidMew
    LeonidMew about 5 years
    What I see, you have changed DocumentRoot not correctly, may be not in all places of config. You should not see oscommerse as DocumentRoot should point above it.
  • LeonidMew
    LeonidMew about 5 years
    You may also do redirect by index.php file, with the following content: <?php header('Location: https://myIPaddress/oscommerce/catalog/index.php');