{"id":6679,"date":"2024-05-23T16:52:12","date_gmt":"2024-05-23T14:52:12","guid":{"rendered":"https:\/\/shakti.tattva.se\/?p=6679"},"modified":"2024-06-04T16:22:03","modified_gmt":"2024-06-04T14:22:03","slug":"nextcloud-configuration-for-lighttpd","status":"publish","type":"post","link":"https:\/\/shakti.tattva.se\/index.php\/nextcloud-configuration-for-lighttpd\/","title":{"rendered":"Nextcloud Configuration for Lighttpd"},"content":{"rendered":"<h2>Prerequisites<\/h2>\n<p>Before starting, ensure you have the following software installed on your server:<\/p>\n<ul>\n<li>Lighttpd<\/li>\n<li>PHP and necessary modules<\/li>\n<li>MariaDB (or MySQL)<\/li>\n<\/ul>\n<h3>Install Lighttpd<\/h3>\n<pre><code>sudo apt update\r\nsudo apt install lighttpd        <\/code><\/pre>\n<h3>Install PHP and Necessary Modules<\/h3>\n<pre><code>sudo apt install php-cgi php-cli php-fpm php-curl php-gd php-intl php-json php-mbstring php-mysql php-xml php-zip php-apcu php-redis php-imagick        <\/code><\/pre>\n<h3>Install MariaDB (or MySQL)<\/h3>\n<pre><code>sudo apt install mariadb-server mariadb-client        <\/code><\/pre>\n<h3>Download and Extract Nextcloud<\/h3>\n<p>Download the latest Nextcloud server package from <a href=\"https:\/\/nextcloud.com\/install\/#instructions-server\">Nextcloud&#8217;s download page<\/a>.<\/p>\n<pre><code>tar -xjf nextcloud-x.y.z.tar.bz2\r\nsudo mv nextcloud \/var\/www\/<\/code><\/pre>\n<h2>Database Setup<\/h2>\n<h3>Secure MariaDB Installation<\/h3>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<h3>Create a Nextcloud Database and User<\/h3>\n<pre><code>sudo mysql -u root -p\r\nCREATE DATABASE nextcloud;\r\nCREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password';\r\nGRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';\r\nFLUSH PRIVILEGES;\r\nEXIT;        <\/code><\/pre>\n<h2>Lighttpd Configuration<\/h2>\n<h3>Enable Necessary Modules<\/h3>\n<pre><code>\r\nsudo lighty-enable-mod fastcgi\r\nsudo lighty-enable-mod fastcgi-php\r\nsudo lighty-enable-mod rewrite\r\nsudo systemctl restart lighttpd\r\n        <\/code><\/pre>\n<h3>Configure Lighttpd for Nextcloud<\/h3>\n<p>Edit the Lighttpd configuration file:<\/p>\n<pre><code>\r\nsudo nano \/etc\/lighttpd\/lighttpd.conf\r\n        <\/code><\/pre>\n<p>Add the following configuration:<\/p>\n<pre><code>\r\nserver.modules += ( \"mod_accesslog\", \"mod_rewrite\", \"mod_setenv\" )\r\n\r\nserver.document-root        = \"\/var\/www\/nextcloud\"\r\nserver.upload-dirs          = ( \"\/var\/cache\/lighttpd\/uploads\" )\r\nserver.errorlog             = \"\/var\/log\/lighttpd\/error.log\"\r\naccesslog.filename          = \"\/var\/log\/lighttpd\/access.log\"\r\nserver.pid-file             = \"\/var\/run\/lighttpd.pid\"\r\nserver.username             = \"www-data\"\r\nserver.groupname            = \"www-data\"\r\nserver.port                 = 80\r\n\r\nindex-file.names            = ( \"index.php\", \"index.html\",\r\n                                \"index.htm\", \"default.htm\" )\r\nurl.access-deny             = ( \"~\", \".inc\" )\r\nstatic-file.exclude-extensions = ( \".php\", \".pl\", \".fcgi\" )\r\n\r\nfastcgi.server = ( \".php\" =&gt;\r\n    ( \"localhost\" =&gt;\r\n        (\r\n            \"socket\" =&gt; \"\/var\/run\/lighttpd\/php.socket\",\r\n            \"bin-path\" =&gt; \"\/usr\/bin\/php-cgi\"\r\n        )\r\n    )\r\n)\r\n\r\nsetenv.add-response-header = (\r\n    \"X-Content-Type-Options\" =&gt; \"nosniff\",\r\n    \"X-XSS-Protection\" =&gt; \"1; mode=block\",\r\n    \"X-Robots-Tag\" =&gt; \"none\",\r\n    \"X-Download-Options\" =&gt; \"noopen\",\r\n    \"X-Permitted-Cross-Domain-Policies\" =&gt; \"none\"\r\n)\r\n\r\n$HTTP[\"url\"] =~ \"^\/data\/\" {\r\n    url.access-deny = (\"\")\r\n}\r\n\r\n$HTTP[\"url\"] =~ \"^($|\/)\" {\r\n    url.rewrite-once = (\r\n        \"^($|\/)$\" =&gt; \"\/index.php$1\"\r\n    )\r\n}\r\n\r\n$HTTP[\"url\"] =~ \"^\/\\.well-known\/(card|cal)dav\" {\r\n    url.rewrite-once = (\r\n        \"^\/\\.well-known\/(card|cal)dav\" =&gt; \"\/remote.php\/dav\/\"\r\n    )\r\n}\r\n\r\n$HTTP[\"url\"] =~ \"^\/\\.well-known\/(webfinger|nodeinfo)\" {\r\n    url.rewrite-once = (\r\n        \"^\/\\.well-known\/(webfinger|nodeinfo)\" =&gt; \"\/index.php\/.well-known\/$1\"\r\n    )\r\n}\r\n        <\/code><\/pre>\n<h3>Set Permissions<\/h3>\n<pre><code>\r\nsudo chown -R www-data:www-data \/var\/www\/nextcloud\/\r\nsudo chmod -R 755 \/var\/www\/nextcloud\/\r\n        <\/code><\/pre>\n<h2>Finalizing Installation<\/h2>\n<h3>Access Nextcloud Web Installer<\/h3>\n<p>Open a web browser and go to <code>http:\/\/your_server_ip\/<\/code> to complete the installation via the web interface.<\/p>\n<h3>Follow the On-screen Instructions<\/h3>\n<ul>\n<li>Enter your database details.<\/li>\n<li>Create an admin account.<\/li>\n<li>Complete the setup.<\/li>\n<\/ul>\n<h3>Secure Your Nextcloud Instance (Optional but Recommended)<\/h3>\n<ul>\n<li>Consider setting up HTTPS using Let\u2019s Encrypt.<\/li>\n<li>Enable and configure a firewall.<\/li>\n<\/ul>\n<p>By following these steps, you should have a functional Nextcloud installation running on Lighttpd.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisites Before starting, ensure you have the following software installed on your server: Lighttpd PHP and necessary modules MariaDB (or MySQL) Install Lighttpd sudo apt update sudo apt install lighttpd Install PHP and Necessary Modules sudo apt install php-cgi php-cli php-fpm php-curl php-gd php-intl php-json php-mbstring php-mysql php-xml php-zip php-apcu php-redis php-imagick Install MariaDB (or&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_kad_post_transparent":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6679","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/posts\/6679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/comments?post=6679"}],"version-history":[{"count":3,"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/posts\/6679\/revisions"}],"predecessor-version":[{"id":6699,"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/posts\/6679\/revisions\/6699"}],"wp:attachment":[{"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/media?parent=6679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/categories?post=6679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shakti.tattva.se\/index.php\/wp-json\/wp\/v2\/tags?post=6679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}