Setup a basic web server and serve a static HTML file via HTTP and HTTPS
- setup a Apache web server with default configuration
- serve a website that contains
Hello World!as landing-page (plaintext, no need for HTML).
- make your website accessible via SSL (a simple selfsigned-snakeoil cert is ok)
The Apache HTTP Server or short just Apache is one of the internets first and most used, web server. Originally based on the NCSA HTTPd server, you'll still find it referenced as httpd(Hypertext Transfer Protocol daemon).
One reason for its popularity is the ability to quickly add features through dynamically loadable modules. However, this also makes it a bit clunky compared to alternatives like Nginx, which is optimized for performance.
Apache is also part of the popular LAMP Stack - which is a bundle of Linux, Apache, MySQL, and PHP". Generally speaking, this refers to installing: - an operating system - a web server - a database - and an interpreter to create dynamic websites (without it, a web server usually just serves HTML content only)
Starting and controlling Apache
There are a few ways to manage programs in Linux. To understand older tutorials and books, you should know some of them.
The full story is quite complex and an interesting read for later. For now, just remember that
systemctrl should always do the trick.
sudo service programX startThis was the old command till Ubuntu 14.10. Used with SysVinit.
sudo systemctl start programXThis is the modern and universal approach. Used by systemd - a system and service manager.
There is even an extra program to control Apache:
sudo Apache2ctrl start Since Ubuntu 16.04 this is already replaced and liked to the
- To check the status of a program, use
sudo systemctl status programX
- Not all programs are stating automatically during the system start-up. Use
sudo systemctl enable programX to enable the autostart.
Accessing websites from terminal
Since you're in a terminal, you'll have to judge the status of websites by text-information only. There are a few tools for that e.g. :
- curl: a tool that can handle almost every internet-related protocol
- lynx: a text-based web-browser. It can't handle complex/modern websites or technologies. But it'll give you a visual representation of the website
Always keep in mind what information you're interested in. E.g:
- accessing "localhost" will only give you the status of the local web server. Users will access your web server via its public IP or FQDN
- web servers will always send response status codes(e.g. 200 or 404). These codes are only visible in the HTTP header fields. Try
- ports and protocols are important. When checking websites, also check what protocol(e.g. try
curl -v http://wikipedia.com:443)