i want to set up a server for hosting a static website (html/css/javascript), so i install RHEL 7 on my computer , and i install apache2.4.6 , also i forward the ports 80 (for apache ) and 22 (for ssh), after i set up a dns server from this tutorial , and when i test the dns server with :
dig @192.168.1.110 www.example.com
i get this output :
; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> @192.168.1.110 www.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46518
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.example.com. IN A
;; ANSWER SECTION:
www.example.com. 10800 IN A 1.1.1.1
;; AUTHORITY SECTION:
example.com. 10800 IN NS ns2.rhel7.local.
example.com. 10800 IN NS ns1.rhel7.local.
;; Query time: 31 msec
;; SERVER: 192.168.1.110#53(192.168.1.110)
;; WHEN: Fri Mar 02 18:48:12 WET 2018
;; MSG SIZE rcvd: 107
so i think all is good , after i create in /var/www/ one directory called sites (where i gnna past all my website ) and i copy tow website ( directories ) inside this directory : site1 and utopic_flowers. now i can access to my website from another computer (outside my network) with this syntax :
public_ip_address/sites/site1/
and
public_ip_address/sites/utopic_flowers/
now how can i set a domain name for those websites , where i can access to it by this syntax :
www.site1.com
and
www.utopic_flowers.com
thank you in advance.
You need to create config files for your websites.
In ubuntu they are stored in /etc/apache2/sites-available
folder.
After you will create 2 new config files for your websites you will need to enable them with a2ensite websiteconfigname
command then restart apache2 service.
Those links might help. https://httpd.apache.org/docs/2.4/vhosts/examples.html https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts#step-four-%E2%80%94-create-new-virtual-host-files