This is a static archive of the old Zorin Forum.

The information below may be outdated. Visit the new Zorin Forum here ›

If you have registered on the old forum, you will need to create an account on the new forum.

Setting up a webserver in Zorin 15 Ubunu 18.04

ozstar

Sat Jan 11, 2020 11:59:30 pm

SETTING UP A WEBSERVER IN ZORIN 15 (UBUNTU 18.04) Jan 2020


Finally I got it all working..

I figure I best record what I did in case someone else needs to know.
So many questions and now the answer !

SUMMARY

PRE CONDITIONS


ACCESS TO INTERNET
Firstly I had to have an internet static IP# which was the address that
my ISP gave me for my server. This number does not change like a
Dynamic one does. It becomes the foundation for your server.

REGISTERED DOMAIN NAME DELEGATED TO POINT TO IP# (A Zone).

Domain Registry should help you do this if you don't know. When
someone puts this namwe into their brwoser it goes to the Registry then
redirected to this static IP# which is your server.

ACCESS THROUGH TO SERVER
Unless you do the next step, when that IP# is sent to your server, it will stop at the Router admin login panel. You have to tell it to let that request through to your server.

It is done via 'Port Forwarding).Enter the port number (usually) 80 and the server local LAN IP (192.168.xx.xx) in the Router Port Forward area, so that any
attempts to get to the server would be allowed through the router to the server on port 80.

BASIC SERVER SET UP

I have several domain names I want to host and I have installed their
websites in their own folders in the

/var/www/html/ (then name each folder here) /public_html.

Like this. ..

(/var/www/html/mysite1.com/public_html)

Each site will have it's own folder and all website files are only in
the public_html folder.
I first went to the 'hosts' file which is the main file that tells apache what sites it is to look after.

It is in the /etc/apache2/ folder as a file simply called, hosts.

In the hosts file you will see some entries already like..

127.0.0.1 localhost
127.0.1.1 david-HP-Compaq-6000-Pro-MT-PC (my comp name. Yours is different)

You need to add your sites to it like this..

The numbers will be your own static IP#..

***.***.***.*** mysite1.com
***.***.***.*** http://www.mysite1.com
***.***.***.*** mysite2.com
***.***.***.*** http://www.mysite2.com

Save the hosts file.

Go to the 'sites-available' folder in etc/apache2/sites-available/
(NOT the sites-enabled folder - contents are automatically copied there
later when you give some commands in the terminal)

Copy the 000-default.conf file to the same folder
and rename it the name of one of your sites say, mysite1.com.conf

Inside that new file changed/add this..

ServerAdmin me@yahoo.com (This is any email address that will get to you)
ServerName mysite1.com (This is the domain name of this site)
ServerAlias http://www.mysite1.com (Same as above but with www)
DocumentRoot /var/www/html/mysite1.com/public_html
(This is the path to the folder we made where the site is)

SAVE this in the same /etc/www/apache2/ folder 000-default.conf file is in.

If you have another domain name/site, copy the mysite1.com.conf file and rename it, mysite2.com.conf.

Change the contents so that it is the name of the second site,mysite2.com.
Everything else is exactly the same. Only the domain name is changed in the 3 places in the file.
SAVE it, then do this command (MUST DO) in the terminal..

sudo a2dissite 000-default.conf
(This disables that file so that the mysite1 and 2 files become active)

Then activate your 2 websites with the a2ensite command like this

sudo a2ensite mysite1.com (Enter)
then this
sudo a2ensite mysite2.com (Enter)

then this MUST DO...

systemctl reload apache2 (This tells apache what you have done)

Whenever you make any changes in those .conf files, you MUST DO
those two commands otherwise apache doesn't know of the changes.

--------------------------
Below is an actual .conf file from the sites-available folder.
It shows the contents of one of the sites/doms.

-------------------------- start of file------
<VirtualHost *:80> (This is the port your router frees up to get to your server)
# The ServerName directive sets the request scheme, hostname & port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerAdmin myname@syahoo.com
ServerName mysite1.com
ServerAlias http://www.mysite1.com
DocumentRoot /var/www/html/mysitewas1.com/public_html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

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

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
-------------------------- end of file-----------

To reiterate, once you have made any changes to the .conf files
do this command to let apache know.

systemctl reload apache2

CHECK TO SEE SITE FROM INTERNET

If everything was done correctly, you should be able to see your sites from the browser if you enter your domain name.
The main thing is you HAVE to look from outside your LAN network otherwise you will be shown the Router login panel of your router.

To do this, if you have a phone, you can disable WiFi so that it is connected to the net via your mobile network not your LAN network.
Enter the mysite1.com URL in the browser.It should resolve at the public_html folder if that site.

IF IT DOESN'T SHOW
If it does not show yuor site but gets the Apache red and white page, then it has gone to the root of the server and has not been redirected to the site folder.

CHECK ALL ADDRESSES ARE THE SAME

Check your addresses in the .conf files you created as well as the entries in the 'hosts' file. All addresses MUST be EXACTLY the same every time.

MAKE SURE 000-DEFAULT.CONF IS DISABLED

Then make sure you have disabled the 000-default.conf file in
/etc/apache2/sites-available folder with the following command in the terminal.

sudo a2dissite 000-default.conf

systemctl reload apache2

(If you don't do this you will not see your sites, just the Apache default page)

After this you may need to get phpMyAdmin and MySQL and other additions
for databases etc but the above is good for html files.

Next step also is to be sure that your server is secure from hackers, spam and virus. You will have to search for this yourself but this is really important as there are bad people out there.

If you still have trouble use the forums for help. If you are courteous and explain exactly what is happening with you and what you want to happen, you will eventually get it going with their help. Remember to always look for either Zorin 15 or Ubuntu 18.04 versions as other could have different ways of doing things.

This took me near 2 weeks of hours every day to work out. I had to sift through many websites most with different explanations about different Linux versions and most of them really out of date so what they said did not work. Lots of wonderful help and patience from several forum guys sealed the deal.

If you had to do other things to get it working, or if something is wrong here, you might post what you had to do on the forums so others can be helped, like I am helping you.

There is a PDF file available of the above if needed.

Good luck !

Aravisian

Sun Jan 12, 2020 4:36:17 pm

Very thorough and amazing guide. Thanks Ozstar for taking the time to print all this out.