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)…
Create a file in /etc/apache2/sites-available…call it mysite.conf.
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>
- 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>
Enable your site: sudo a2ensite mysite. Fix any errors. Rinse. Repeat.
Restart your server: sudo systemctl restart apache2. Fix any errors. Rinse. Repeat.
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