How do I add webpage to apache2 after setting up Nextcloud linode?

I am having trouble finding information on how to properly modify an existing Apache2 install.

I just setup a Nextcloud linode and I have it setup with a subdomain, and it's using let's encrypt.

I would like to setup the apache2 install to also serve a webpage (not nextcloud) to the www domain and also use let's encrypt.

Any help is appreciated. Thanks!

1 Reply

The same way you set up any other site on apache2… The existence of NextCloud does not change the laws of physics in apache-world.

You don't say which distro you're using. Here's how I would do it on Debian or Ubuntu (Debian's downstream child)…

  1. Create a file in /etc/apache2/sites-available…call it mysite.conf.

  2. Put the following content in mysite.conf:

<VirtualHost _default_:443>

    # Admin email, Server Name (domain name), and any aliases
    #
    ServerAdmin webmaster@mysite.com   # this is optional
    ServerName mydomain.com            # this is optional
    ServerSignature Off                # this is optional

    Include /the/path/to/letsencrypt/options-ssl-apache.conf

    SSLCertificateFile /the/path/to/letsencrypt/live/mydomain.com/cert.pem
    SSLCertificateKeyFile /the/path/to/letsencrypt/live/mydomain.com/privkey.pem 
    SSLCACertificateFile /the/path/to/letsencrypt/live/mydomain.com/chain.pem

    # Index file and Document Root (where the public files are located)
    #
    DirectoryIndex index.html
    DocumentRoot /the/path/to/your/site         # does NOT have to be under /var/www!

    Alias "/some/url" "/the/path/to/your/site"  # does NOT have to be under /var/www!

    <Directory /the/path/to/your/site>          # does NOT have to be under /var/www!
        SSLOptions +StdEnvVars
        AllowOverride None             # disables .htaccess (consult the docs)
        Options -Indexes
        Require all granted
    </Directory>

</VirtualHost>
  1. Create a file called /the/path/to/your/site/index.html with the following content:
<html>
<head></head>
<body>
  <h1>Hello World!</h1>
</body>
</html>
  1. Enable your site: sudo a2ensite mysite. Fix any errors. Rinse. Repeat.

  2. Restart your server: sudo systemctl restart apache2. Fix any errors. Rinse. Repeat.

  3. Navigate to https://www.mydomain.com/some/url . You should see the words "Hello World!" as a first-level heading.

This is just a basic guide and there are probably errors. Obviously, I've left out a lot of the details here…especially about correct file ownership and permissions. You'll have to figure this out by yourself. Generally, everything should be owned by www-data:www-data and have permissions of at least 0644 (-rw-r--r--).

Here's the apache2 documentation: https://httpd.apache.org/docs/current/

Have fun!

-- sw

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct