Lighttpd on arch

lighttpd, PHP, MariaDB

https://wiki.ubuntuusers.de/lighttpd/
https://redmine.lighttpd.net/projects/lighttpd/wiki/TutorialConfiguration

Installation

pacman -S lighttpd
pacman -S php php-cgi mariadb mariadb-clients
mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Infos:
Two accounts: root@localhost, mysql@localhost

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

You can start the MariaDB daemon with:
cd ‘/usr’ ; /usr/bin/mysqld_safe –datadir=’/var/lib/mysql’

You can test the MariaDB daemon with mysql-test-run.pl
cd ‘/usr/mysql-test’ ; perl mysql-test-run.pl

User & Group

useradd -r -s /bin/false www
usermod -a -G www www
sudo chgrp www /srv/http

Config for User-Directories

https://redmine.lighttpd.net/projects/1/wiki/docs_moduserdir
https://www.internalpointers.com/post/right-folder-permission-website
https://stackoverflow.com/questions/36251154/lighttpd-specific-user-directory-404
https://wiki.archlinux.org/title/Apache_HTTP_Server#User_directories


chmod o+x /home/daniel
chmod o+x /home/daniel/Documents
chmod o+x /home/daniel/Documents/Sites
chmod -R o+r /home/daniel/Documents/Sites

then Sites can be accessed via: http://localhost/~daniel/

Config in /etc/lighttpd/lighttpd.conf


server.document-root = "/srv/http/"
server.bind = "127.0.0.1"
server.port = 80

server.username = "www"
server.groupname = "www"

server.modules = (
"mod_userdir",
"mod_alias",
)

userdir.path = "Documents/Sites"

mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)

static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )

Setting up PHP

https://wiki.archlinux.org/title/Lighttpd
https://wiki.archlinux.org/title/PHP

Help:
https://stackoverflow.com/questions/11537888/lighttpd-403-forbidden-for-php-files
https://redmine.lighttpd.net/boards/2/topics/3024
https://stackoverflow.com/questions/14471641/how-to-display-php-errors-when-using-lighttpd-and-fast-cgi

Config in /etc/lighttpd/lighttpd.conf


server.document-root = "/srv/http/"

server.port = 80
server.bind = "127.0.0.1"
server.username = "www"
server.groupname = "www"

server.modules = (
"mod_access",
"mod_fastcgi",
"mod_userdir",
"mod_alias",
)

userdir.path = "Documents/Sites"

mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".php" => "text/php",
".css" => "text/css",
".jpg" => "image/jpeg",
".png" => "image/png"
)

fastcgi.server = ( ".php" => ((
"bin-path" => "/bin/php-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"broken-scriptfilename" => "enable"
)))

static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html", "index.php" )

Config-Files and Commands

# Config-Files
/etc/lighttpd/lighttpd.conf
/etc/php/php.ini

# Commands

sudo lighttpd -f /etc/lighttpd/lighttpd.conf

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.