Apache24 showing a default page of "It works" instead of Nextcloud page after changing documentroot directory

I’ve been following this guide: https://www.adminbyaccident.com/freebsd/how-to-freebsd/how-to-install-nextcloud-on-freebsd-12/

Used this guide for FreeBSD 14.1-RELEASE using apache24.

I installed nextcloud-30.0.4 into

/usr/local/www/nextcloud

directory.

apachectl -S
VirtualHost configuration:
*:80                   [REDACTED] (/usr/local/etc/apache24/extra/httpd-vhosts.conf:23)
*:443                  [REDACTED] (/usr/local/etc/apache24/extra/httpd-vhosts.conf:35)
ServerRoot: "/usr/local"
Main DocumentRoot: "/usr/local/www/apache24/data"
Main ErrorLog: "/var/log/httpd-error.log"
Mutex default: dir="/var/run/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www" id=80
Group: name="www" id=80

I’ve configured the main documentroot to the nextcloud folder in httpd.conf file but doing that didn’t change anything so I reverted back to original directory (/usr/local/www/apache24/data).

I’ve used this configuration from the link.

<VirtualHost *:80>
  ServerName Nextcloud
  ServerAlias Nextcloud
  DocumentRoot "/usr/local/www/nextcloud"
  ErrorLog "/var/log/nextcloud-error_log"
  CustomLog "/var/log/nextcloud-access_log" common
  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
  Protocols h2 h2c http/1.1
</VirtualHost>

<VirtualHost *:443>
  ServerName Nextcloud
  ServerAlias Nextcloud
  DocumentRoot "/usr/local/www/nextcloud"
  SSLEngine on
  SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
  SSLHonorCipherOrder on
  SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
  SSLCertificateFile "/usr/local/etc/apache24/server.crt"
  SSLCertificateKeyFile "/usr/local/etc/apache24/server.key"
  ErrorLog "/var/log/nextcloud-error_log"
  CustomLog "/var/log/nextcloud-access_log" common
  Protocols h2 http/1.1
</VirtualHost>

And enabled the virtualhost in httpd.conf

Did apachectl configtest

AH00526: Syntax error on line 43 of /usr/local/etc/apache24/extra/httpd-vhosts.conf:
SSLCertificateFile: file '/usr/local/etc/apache24/server.crt' does not exist or is empty

My SSL configuration isn’t complete with certbot because I plan on using nextcloud as an intranet cloud

Not sure how I can get the page to come up as Nextcloud at this point without relocating the nextcloud to the apache24/data/ directory, I’d like to have nextcloud sit in /usr/local/www/nextcloud directory because most of my configurations are set for that directory.

Just to be on the safe side: Did you reload or even restart Apache after the change?

This would be necessary for the change to be applied.

2 Likes

If there are syntax errors, Apache will not use the new config when restarted. You need to remedy this.

See Apache: Stopping and Restarting.

@jtr Apparently it was the vhost issue with SSLCertificateFile error problem. I tried self signing with openssl and create a certification but I am suffering internal error when I self sign and use my IP address without the domain name. Is there a way to not use the domain name and just use the IP address without using SSL on vhosts??

I’ve done a lot of restarting but it turns out the SSL error with vhost is hanging me up.

Remove these lines from your virtual host configuration

  SSLEngine on
  SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
  SSLHonorCipherOrder on
  SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
  SSLCertificateFile "/usr/local/etc/apache24/server.crt"
  SSLCertificateKeyFile "/usr/local/etc/apache24/server.key"

set this line in your nextcloud/config/config.php

 'overwrite.cli.url' => 'http://123.123.123.123/',
 'trusted_domains' => 
  array (
    0 => '123.123.123.123',
  ),

where 123.123.123.123 is your local ip

if you still have ssl errors remove these lines from apache config

Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults

@Vincent_Stans Thank you for your reply.

Ok I got those lines removed from virtual host configuration.

Your config.php code isn’t exactly clear to me. I’m not sure how to integrate it with it currently shown in this. I understand parts of what you’re saying here as far as putting local IP in the code.

<?php $CONFIG = array ( 'instanceid' => '[REDACTED]', );

Somehow, I don’t think this file seems to be complete with

?>

at the end of the line. It shows exactly as that in the code block when I have not touched this.

Also, which apache config are you referring to that has the Mutex ssl-*?

Your help is very much appreciated!

your config.php should look like this and no ?> ending. because it’s included in other page that closes the php

<?php $CONFIG = array ( 
 'instanceid' => 'hide this on the forum', 
 'overwrite.cli.url' => 'http://123.123.123.123/',
 'trusted_domains' => 
  array (
    0 => '123.123.123.123',
  ),
);

also there is alot missing if you only have the instanceid

below should be all set when you install nextcloud

 'passwordsalt' => 'should have something',
  'secret' => 'should have something ',
  'datadirectory' => 'should be set',
  'installed' => true,
  'maintenance' => false,
  'version' => '30.0.4.1',
  'default_phone_region' => 'NL',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'redis' => 
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
  ),
  'dbtype' => 'mysql',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'SECRET_USERNAME',
  'dbpassword' => 'P@SSw0rd',

  ),

unfortunately you can’t simply copy paste this as some are set by nextcloud setup and others can be set with the occ command.

the also need all the require php modules to be installed and redis-server.

If you need help with any of the above simply ask. Though I have no experience in FreeBSD I try Google also knows a lot :slight_smile: of websites that have help.

I think I’m running ahead and your still half way the tutorial and have not run the setup yet.

I’m not sure where the mutex is set probably with the ssl module I’m not sure it can be disabled. I have no testing center atm.

but with the ssl removed from the vhost and a apache restart you still get errors? what are the errors.

1 Like

@Vincent_Stans FreeBSD is supposedly a more stable operating system compared to Linux. It uses init system unlike new Linux uses systemd nowadays. I recommend you to check out FreeBSD if you’re interested in having a super stable system. Though fair warning compatibility isn’t on par like Linux.

Now all the SSL problems are not there anymore. I removed the rewrite lines in the virtual host configuration file and now I can see the page through w3m in the main server terminal. I’ve used the following links, which all came from the main link I posted in the first post.

https://www.digitalocean.com/community/tutorials/how-to-install-an-apache-mysql-and-php-famp-stack-on-freebsd-12-0

I used this guide it’s partially working now, it was fully working before I got into this… probably need to resinstall the php.

@Vincent_Stans I reinstalled php mysql and apache altogether again the page looks better now aesthetically the way it is supposed be than before.

I think the php modules are working great now and the ssl are disabled and working got access to the http port on browser. Though I am getting Internal Server Error with nextcloud.

[Tue Dec 31 23:31:30.433880 2024] [php:notice] [pid 39792] [client [REDACTED]] {“reqId”:“15hWzFUI6bdpsLdBRS21”,“level”:3,“time”:“2025-01-01T07:31:30+00:00”,“remoteAddr”:“[REDACTED]”,“user”:“–”,“app”:“base”,“method”:“GET”,“url”:“/”,“message”:“Failed to start session”,“userAgent”:“Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0”,“version”:“”,“exception”:{“Exception”:“Exception”,“Message”:“Failed to start session”,“Code”:0,“Trace”:[{“file”:“/usr/local/www/nextcloud/lib/base.php”,“line”:396,“function”:“__construct”,“class”:“OC\\Session\\Internal”,“type”:“->”},{“file”:“/usr/local/www/nextcloud/lib/base.php”,“line”:664,“function”:“initSession”,“class”:“OC”,“type”:“::”},{“file”:“/usr/local/www/nextcloud/lib/base.php”,“line”:1134,“function”:“init”,“class”:“OC”,“type”:“::”},{“file”:“/usr/local/www/nextcloud/index.php”,“line”:22,“args”:[“/usr/local/www/nextcloud/lib/base.php”],“function”:“require_once”}],“File”:“/usr/local/www/nextcloud/lib/private/Session/Internal.php”,“Line”:46,“message”:“Failed to start session”,“exception”:{},“CustomMessage”:“Failed to start session”}}

Thank you for your patience and helping me with this. I am not sure where the issue needs to be fixed now.

Trying to at least finally be able to login Nextcloud for the first time locally.

I\ve noticed in the first tutorial you send that they use outdated software php7.4 with nextcloud 20.0.7.zip this is not related to the latest error but I just hope you installed php8.x preferably 8.3 and the latest NC 30.0.4 the last tutorial is even 7.3

The error might be that the remote address is not in the trusted list of your config.php

'trusted_domains' => 
  array (
    0 => '123.123.123.123',
    1 => 'add externale ip',
    2 => '127.0.0.1',
  ),

maybe your router sends a loopback and you connect through the external ip add it to the list.

I also don’t see any file locking php module in the tutorial APCu or redis. The last tutorial doesn’t even tell phpX.X-mysql which you definitely need or pgsql or sqlite

What does php -m output on the console

[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
http
iconv
igbinary
imagick
imap
intl
json
libxml
mbstring
mcrypt
memcache
memcached
msgpack
mysqli
mysqlnd
OAuth
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_sqlite
Phar
posix
pspell
random
raphf
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Edit:

I personaly use this installer for the first time installing nextcloud

wget https://download.nextcloud.com/server/installer/setup-nextcloud.php -O /usr/local/www/nextcloud/setup-nextcloud.php

you could then browse to http://localhost/setup-nextcloud.php and it will tell you what is missing before installation

I also see your installing 30.0.4 in your first post which doesn’t work with php lower then 8.1. What does php -v say?

@Vincent_Stans I actually skipped modifying the config.php file when I reinstalled apache, mysql, and php. Then reconfigured the system without the rewrite and the SSL in httpd-vhosts.conf which bypassed the redirection and SSL issue.

Getting very close to the working Nextcloud program. I’ve installed more php modules.

PHP modules installed and referred to page: https://docs.nextcloud.com/server/latest/admin_manual/installation/php_configuration.html#php-modules

root@freebsd:~ # php -m
[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
http
iconv
imagick
imap
intl
json
ldap
libsmbclient
libxml
mbstring
mcrypt
memcache
memcached
msgpack
mysqli
mysqlnd
OAuth
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_sqlite
Phar
posix
pspell
random
raphf
readline
redis
Reflection
session
SimpleXML
smbclient
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

The PHP version I am using is PHP8.3 with Mysql80 and apache24.

Page looks like it is missing the aesthetics (the GUI is missing)

Here is what the current page looks like now that the Internal Server Error problem is gone. The GUI is missing after installing some PHP modules.

Also, I’ve tried the setup-nextcloud.php file but that failed after pressing the next button on the page.

I am not sure what needs to be properly configured because I installed after collecting a list of necessary packages for PHP83

pkg install -y php83-ctype php83-curl php83-dom php83-fileinfo php83-filter php83-gd php83-mbstring php83-posix php83-session php83-xml php83-simplexml php83-xmlreader php83-xmlwriter php83-zip php83-zlib php83-pdo_mysql php83-intl php83-sodium php83-ldap php83-ftp php83-imap php83-bcmath php83-gmp php83-pecl-smbclient php83-exif php83-pecl-APCu php83-pecl-redis php83-pecl-memcache php83-pecl-memcached php83-pecl-imagick php83-bz2 php83-ffi php83-gettext php83-pecl-http php83-iconv php83-pecl-mcrypt php83-pecl-msgpack php83-odbc php83-pcntl php83-opcache php83-pdo_odbc php83-pecl-oauth php83-pdo_sqlite php83-phar php83-pspell php83-pecl-raphf php83-readline php83-soap php83-sockets php83-sqlite3 php83-sysvmsg php83-sysvsem php83-sysvshm php83-tidy php83-tokenizer php83-xsl php83-pecl-xmlrpc

So close to getting this right. I haven’t gotten this far on FreeBSD, I was able to do it on Linux but wanted to give FreeBSD a try.

1 Like

I would check the apache logs to see why it doesn’t load the css/images. have you checked that all permissions are correct?

as for the setup-nextcloud.php that should be a single file in your installation directory but don’t mind that.

There is always room to grow and get smarter glad to see at least you run the latest version software.

I would suggest to open a new topic if you need more help with your setup because most will read the first post and not read everything between. as far as I can see now you got most of it under control and the topic title is solved.

I would set this post as the solution.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.