A Few Extra Steps Log Fileīecause the location of the log file we specified in the config is in a folder that does not yet exist, lighttpd will throw an error when it runs.
#Kali linux how to use lighttpd code#
We have already configured the web server in the config file to allow for PHP code to be executed. For MySQL support, ‘php-mysql’ needs to be installed as well.
If you want PHP support, PHP will need to be installed, specifically the ‘php’ and ‘php-cgi’ packages.
#Kali linux how to use lighttpd install#
Here are the contents of the config file: How to Install PHP setenv.add-response-header = ( “Access-Control-Allow-Origin” => “*”) To specify only one domain, replace “*” with the domain you want. If you need to allow cross-origin resource sharing(CORS), add this line below. The FastCGI module is what we use to execute PHP scripts. What we have done is told lighttpd that if a PHP script was requested from the server, it should launch the PHP interpreter on the computer to process it. Since we added these two modules in: we will need to put configurations in the file underneath the server settings (if the executables for ‘php’ and ‘php-cgi’ are located elsewhere, specify those instead): rver = ( ".php" => (( By default, the user ‘In this configuration, let’s change the directory of the document root to ‘/var/change the port to 8080, if you wish. Username and group name corresponding to the ones found on your system. The field ‘upload-dirs’ contains an array of directories to store uploads to. The document root specifies the upper-most directory level visible to the web server. Since this is a new file, copied from the default config file, we can change whatever we want. These are the defaults found in the config file in /etc/lighttpd. These fields are self-explanatory really. Server.pid-file = "/var/run/lighttpd.pid" Server.errorlog = "/var/log/lighttpd/error.log" Server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) Let’s inspect the following section: server.document-root = "/var/www/html" NOTE: if you want to also include ‘mod_status’ in the list, put ‘mod_setenv’ before it. Mod_setenv will allow us to pass a header that will allow the server to make requests to other domains which is useful for loading external libraries.
Mod_fastcgi will allow us to add PHP support. Let’s add two more to the list now: ‘mod_fastcgi’ and ‘mod_setenv’. The ‘server.modules’ field contains an array of modules that are used by the server. $ vim ~/webservers/nf # Or whatever editor you wish Server Modules This is a standard ‘.conf’ file so the normal syntax rules apply, that is, for example, any characters after ‘#’ are treated as comments. We will simply copy the default config file found in /etc/lighttpd. Let’s call this ‘nf’ in the home directory. Lighttpd Configuration OptionsĪfter installing lighttpd, we will begin by creating a file that defines the web server settings. This tutorial will also cover adding PHP support for your web servers. Understanding the configuration file for each web server instance is key to successfully running lighttpd. Setting one lighttpd instance can be a bit tricky, so this tutorial serves as a clear guide on how to properly configure a lighttpd server on Linux. That server is known as lighttpd (pronounced ‘lighty’). There is a web server that is very conservative in its resource usage and memory footprint.