{"id":718,"date":"2024-04-18T19:58:23","date_gmt":"2024-04-18T17:58:23","guid":{"rendered":"https:\/\/www.gonscak.sk\/?p=718"},"modified":"2024-07-09T09:09:21","modified_gmt":"2024-07-09T07:09:21","slug":"how-to-install-nextcloud-v-28-0-4-on-centos-9-stream-with-php-8-3","status":"publish","type":"post","link":"https:\/\/www.gonscak.sk\/?p=718","title":{"rendered":"How to install Nextcloud v 28.0.4 on Centos 9 Stream with PHP 8.3"},"content":{"rendered":"\n<p>I assume, that we have already a clean installation of Centos Stream 9.<\/p>\n\n\n\n<p>So, as usual, start with full upgrade of this system:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf update -y<\/pre>\n\n\n\n<p>After reboot set hostname:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hostnamectl set-hostname cloud.example.com<\/pre>\n\n\n\n<p>Next, we install and create empty database for our nextcloud. Then we start it and enable for autostart after boot.<br>If you wish, you can skip installations of MariaDB and you can use built-in SQLite. Then you can continue with installing apache web server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf -y install mariadb-server<br>...<br>systemctl enable mariadb --now<\/pre>\n\n\n\n<p>Now, we run post installation script to finish setting up mariaDB server. Set your own password for root access:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql_secure_installation\nSet root password? [Y\/n] y\nRemove anonymous users? [Y\/n] y\nDisallow root login remotely? [Y\/n] y\nRemove test database and access to it? [Y\/n] y\nReload privilege tables now? [Y\/n] y<\/pre>\n\n\n\n<p>Now, we can create a database for nextcloud.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql -u root -p\n...\nCREATE DATABASE cloud;\nGRANT ALL PRIVILEGES ON cloud.* TO 'nextuser'@'localhost' IDENTIFIED BY 'YOURPASSWORD';\nFLUSH PRIVILEGES;\nexit;<\/pre>\n\n\n\n<p>Now, we install Apache web server, and we start it and enable for autostart after boot:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf install httpd -y<br>systemctl enable httpd.service --now<\/pre>\n\n\n\n<p>And set up firewall fow port http\/80 only:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl status httpd\nfirewall-cmd --list-all\nfirewall-cmd --zone=public --permanent --remove-service=dhcpv6-client\nfirewall-cmd --zone=public --permanent --add-service=http\nfirewall-cmd --reload<\/pre>\n\n\n\n<p>Now point your browser to this server and look, if you see a Apache test page.<\/p>\n\n\n\n<p>Now we can install php. Nextcloud (at this time is version 28.0.4) supports PHP (8.1, 8.2, 8.3). So I use remi repositories and install php 8.3 for Centos Stream 9. Because by default, Centos has available packages for 8.0.30 now:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf info php<br>...<br>Available Packages<br>Name         : php<br>Version      : 8.0.30<br>Release      : 1.el9<br>Architecture : x86_64<br>Size         : 4.7 k<br>Source       : php-8.0.30-1.el9.src.rpm<br>Repository   : appstream<\/pre>\n\n\n\n<p>So, continue and enable Remi for php v. 8.3:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf install dnf-utils http:\/\/rpms.remirepo.net\/enterprise\/remi-release-9.rpm<br>dnf module list php<br>dnf module reset php<br>dnf module enable php:remi-8.3<br>dnf info php<br>...<br>Available Packages<br>Name         : php<br>Version      : 8.3.6<br>Release      : 1.el9.remi<br>Architecture : x86_64<br>Size         : 1.8 M<br>Source       : php-8.3.6-1.el9.remi.src.rpm<br>Repository   : remi-modular<\/pre>\n\n\n\n<p>Now we install som recommended php packages<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dnf install -y php php-gd php-mbstring php-intl php-pecl-apcu php-mysqlnd  php-pecl-zip.x86_64 php-process.x86_64 php-bcmath php-gmp php-redis php-imagick<br>systemctl enable php-fpm.service --now<br>php -v<br>...<br>PHP 8.3.6 (cli) (built: Apr 10 2024 14:21:20)<\/pre>\n\n\n\n<p>Now, create own lvm partition for nextcloud of size 5G, and set xfs file system. If wish, create a much bigger partition fot nextcloud (mayby 100G&#8230;):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">lvcreate -n cloud -L+5G your-vg\nmkfs.xfs \/dev\/mapper\/your-vg-cloud<\/pre>\n\n\n\n<p>Now, create you own directory, where the web content and all data from nextcloud will be server and mount our partition on it. Maybe, edit fstab and add this mount point, to enable it after reboot\/start:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir -p \/var\/www\/html\/nextcloud\/<br>mount \/dev\/mapper\/your-vg-cloud \/var\/www\/html\/nextcloud\/<br>echo \"\/dev\/mapper\/your-vg-cloud \/var\/www\/html\/nextcloud xfs defaults 0 0\" &gt;&gt; \/etc\/fstab<\/pre>\n\n\n\n<p>Now, we create a dedicated unix user for our cloud instance, who will be the owner of directory with files and these users run dedicated php-fpm process:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">useradd -r com.example.cloud<br>cd \/etc\/php-fpm.d\/<br>mv www.conf cloud.example.conf<\/pre>\n\n\n\n<p>Now, change pool name [www] with our name, change user and group of processes. Change socket name for this user, and directory for php sessions:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim cloud.example.conf<br>[example]<br>user = com.example.cloud<br>group = com.example.cloud<br>listen = \/run\/php-fpm\/example.sock<br>php_value[session.save_path]    = \/var\/lib\/php\/session\/example<\/pre>\n\n\n\n<p>Now, create above folder for php session and change permissions:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir \/var\/lib\/php\/session\/example<br>chown com.example.cloud:com.example.cloud \/var\/lib\/php\/session\/example<br>chmod +x \/var\/lib\/php\/session\/<\/pre>\n\n\n\n<p>And restart php-fpm process and see, if there is php process with our name:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart php-fpm.service \nps aux | grep example\n...<\/pre>\n\n\n\n<p>Check, what php configuration is loaded and edit some variables for non-problem using of nextcloud:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">php --ini |grep Loaded\nsed -i \"s\/post_max_size = 8M\/post_max_size = 4G\/\" \/etc\/php.ini\nsed -i \"s\/upload_max_filesize = 2M\/upload_max_filesize = 4G\/\" \/etc\/php.ini\nsed -i \"s\/memory_limit = 128M\/memory_limit = 1G\/\" \/etc\/php.ini<\/pre>\n\n\n\n<p>Now, go into our directory for cloud, and download latest nextcloud. Unzip it, move files and set ownership and restore label for selinux:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/var\/www\/html\/nextcloud<br>wget https:\/\/download.nextcloud.com\/server\/releases\/latest.zip<br>unzip latest.zip<br>rm latest.zip<br>mv nextcloud\/* .<br>mv nextcloud\/.htaccess .<br>mv nextcloud\/.user.ini .<br>rmdir nextcloud\/<br>mkdir data<br>cd ..<br>chown com.example.cloud:apache -R nextcloud<br>restorecon -Rv nextcloud<\/pre>\n\n\n\n<p>Now, if you (and I) using selinux, set permissions for some folders\/files. Adjust you filepaths:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">semanage fcontext -a -t httpd_sys_rw_content_t '\/var\/www\/html\/nextcloud\/data(\/.*)?'<br>semanage fcontext -a -t httpd_sys_rw_content_t '\/var\/www\/html\/nextcloud\/config(\/.*)?'<br>semanage fcontext -a -t httpd_sys_rw_content_t '\/var\/www\/html\/nextcloud\/apps(\/.*)?'<br>semanage fcontext -a -t httpd_sys_rw_content_t '\/var\/www\/html\/nextcloud\/.htaccess'<br>semanage fcontext -a -t httpd_sys_rw_content_t '\/var\/www\/html\/nextcloud\/.user.ini'<br>semanage fcontext -a -t httpd_sys_rw_content_t '\/var\/www\/html\/nextcloud\/3rdparty\/aws\/aws-sdk-php\/src\/data\/logs(\/.*)?'<br><br>restorecon -Rv '\/var\/www\/html\/nextcloud\/'<\/pre>\n\n\n\n<p>We can check our instance via built-in occ command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/var\/www\/html\/nextcloud<br>sudo -u com.example.cloud php occ<br>...<br>Nextcloud is not installed - only a limited number of commands are available<br>Nextcloud 28.0.4<\/pre>\n\n\n\n<p>Now, we create a configuration file for httpd. FilesMatch attribute is for handling php files with our own dedicated php-fpm process:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/etc\/httpd\/conf.d\/<br>vim nextcloud.conf<br><br>&lt;VirtualHost *:80&gt;<br>  DocumentRoot \"\/var\/www\/html\/nextcloud\"<br>  ServerName  your.server.com<br><br>  &lt;Directory \/var\/www\/html\/nextcloud&gt;<br>    Require all granted<br>    AllowOverride All<br>    Options FollowSymLinks MultiViews<br><br>    &lt;IfModule mod_dav.c&gt;<br>      Dav off<br>    &lt;\/IfModule&gt;<br><br>&lt;FilesMatch \\.(php|phar)$&gt;<br>        SetHandler \"proxy:unix:\/run\/php-fpm\/example.sock|fcgi:\/\/localhost\"<br>&lt;\/FilesMatch&gt;<br><br>  &lt;\/Directory&gt;<br>&lt;\/VirtualHost&gt;<\/pre>\n\n\n\n<p>Now, reload gracefully httpd and we can access to our web via http:\/\/your.server.com and continue installation viac web installer. Set database, user, password&#8230;<\/p>\n\n\n\n<p>Have fun and nice day.<\/p>\n ","protected":false},"excerpt":{"rendered":"<p>I assume, that we have already a clean installation of Centos Stream 9. So, as usual, start with full upgrade of this system: dnf update -y After reboot set hostname: hostnamectl set-hostname cloud.example.com Next, we install and create empty database for our nextcloud. Then we start it and enable for autostart after boot.If you wish, &hellip; <a href=\"https:\/\/www.gonscak.sk\/?p=718\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to install Nextcloud v 28.0.4 on Centos 9 Stream with PHP 8.3<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[95,149,70,150,27],"class_list":["post-718","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-apache","tag-centos-9","tag-nextcloud","tag-php-8-3","tag-stream"],"_links":{"self":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=718"}],"version-history":[{"count":24,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/718\/revisions"}],"predecessor-version":[{"id":1044,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=\/wp\/v2\/posts\/718\/revisions\/1044"}],"wp:attachment":[{"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gonscak.sk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}