Skip to content

Web Server

Lucas Holt edited this page Aug 22, 2022 · 1 revision

It's possible to setup a Web Server on MidnightBSD to host websites and for developers wishing to test locally.

Several web servers are available for MidnightBSD including Apache httpd, nginx, lighttpd, bozohttpd, and Apache Tomcat.

For caching scenarios, varnish cache or nginx are recommended.

Be Sure to update the firewall configuration to allow port 80 and 443 as needed. By default, MidnightBSD's ipfw blocks these ports.

Apache 2.4

Apache can be installed by running

mport install apache24

You can also build from mports to customize it and add features like HTTP/2.0 support, or enable/disable specific modules.

Configuration files are located in /usr/local/etc/apache24

You will likely want to edit the /usr/local/etc/apache24/extra/http-vhosts.conf and the http-ssl.conf files in there.

If you wish to enable Let's Encrypt, you may want to install the py-certbot-apache port/package.

mport install py38-certbot-apache

Nginx

Similar to Apache, nginx can be installed as a package or compiled via mports/www/nginx

mport install nginx

Apache Tomcat There are several different versions of Tomcat available in mports. You will likely want to install one of the following

mport install tomcat10

mport install tomcat7

mport install tomcat85

mport install tomcat9

Additionally, you can install mports/www/tomcat-native to improve performance.

CGI / Languages

MidnightBSD supports several languages to run web applications such as Perl, Python, Ruby and PHP. Each of these languages requires a different configuration.

Perl

MidnightBSD's base system includes perl so it's simply a matter of installing modules like p5-CGI and then adding your scripts to an appropriate directory. One can also do mod_perl.

e.g. stuff like mport install p5-CGI p5-DBI p5-DBD-mysql

PHP

PHP can be setup with mod_php, php fpm or fast cgi.

With php fpm and apache, you would need these in your /etc/rc.conf

apache24_enable="YES" php_fpm_enable="YES"

Then configure your php settings in /usr/local/etc/ (php.ini and a php extensions in there)

mport install php80 php80-extensions