Problems with Nextcloud/PHP on my LAMP server

Hello, I have been having trouble getting my nextcloud instance to run with my server lately. Initially it worked fine, but then I edited the index.html file (for the login page) directly and it appeared to cause the instance to break. I undid my changes, but the instance still remained broken. Not knowing what else to do, I backed up my files, removed the mysql databases, and began anew. That still did not work and upon looking for any errors, I noticed that in the index.php file, a commented heading reads: * Your webserver seems to be not configured to use PHP or PHP is not installed. However, that doesn’t make sense because as far as I can tell all of the PHP modules are installed and enabled for Apache as per the Nextcloud installation documentation. Please know that this is all new to me and while I have enjoyed teaching myself how to use Apache and MySQL, I have been bashing my head against the wall when it comes to my broken nextcloud instance. It used to work, and so I had enough time to actually become dependent on it. I also do not know PHP at all. My knowledge of HTML, CSS, and JavaScript is competent, but still growing (as they are all rather large languages that constantly evolve). I should also mention that the installation page prevents me from interacting with any of the buttons; and when I attempt to install Nextcloud from the CLI, the login button is dead. These were the original problems that sparked my hunt for the source. My search led me to the conclusion about awry PHP or Apache configuration settings. Any help or guidance is appreciated.
Thanks.

P.S. The server is powered by Debian 10 - which I am most familiar with out of all Nextcloud supported platforms.

Apparently, you burned your fingers by tampering NC server system files unnecessarily and curiosity killed the cat.

Hello, I have been having trouble getting my nextcloud instance to run with my server lately. Initially it worked fine, but then I edited the index.html file (for the login page) directly

Maybe a word of advice: Always seek to make a backup copy of any system file before tampering. On CLI a sudo -u www-data cp -p index.html index.html.old or similar command could have helped to avoid your personal admin trap.


Please consult the docs:

Make yourself familiar with the system administration tasks before hitting the iceberg:

Usually, on first system setup there should be an option in the Debian installer where you can choose to include the Web server and this would install everything you need to run an Apache 2 web service. An sudo apt install php7.3 should get almost anything ready for a later NC standard install.

Please choose libapache2-mod-php7.3 over php-fpm as a home user certainly.


Hope this helps.
:smile:

you shouldn’t do this. (as you know already. :wink: )
to restore the original content it’s enough to download your nextcloud version from the download page and extract the file from the archive. (if you have mc installed on your system, you can open the archive with that program very easy. if you don’t have it installed sudo apt install mc -y

you’ll see this error messge in your browser, if there is no php on your server. in that case the php code is not processed by the php engine and the code is presented as plain text. do you see this text in your browser?

did you check the apache, php an dnextcloud logs?

Here is a copy of the original NC 16 file you tampered with:

$ sudo cat /var/www/nextcloud/index.html

<!DOCTYPE html>
<html>
<head>
	<script> window.location.href="index.php"; </script>
	<meta http-equiv="refresh" content="0; URL=index.php">
</head>
</html>

Copy and paste this code into your file and you should be on the safe bank, hopefully.
:repeat_one:

Please take an advice and never again change this file or similar system files. You should be aware that such a file by self describing from the code lines shall not be changed (besides developers) as it purposefully aims to provide a standard access procedure and points any http request to the index.php file which is capable of starting the NC server frontend process as is quite appropriate. Naturally, neither change the index.php of the NC server.
:warning:

Hope this helps.

Good luck.
:four_leaf_clover:

Good guess. However, the reason my be more basic.

The message may appear due to index.html not calling index.php after the tampering, I presume.

Anyway, when one wants to check the PHP install do:

$ php --version

Similar to check the Apache install is running:

$ systemctl status apache2

Happy hacking.
:sunny:


Addendum 1

The Midnight commander is still a thing? Never expected to find this around today. Apparently, another project where the documentation (last modified 8 years ago) utterly needs support by the community.

However, this is a tool which typically should not be installed on a server.

Furthermore, I would advice to be more conservative on the install and would seek to avoid the ‘-y’ i.e. ‘yes to every thing’ option after a look on the long list of suggested additional packages being included with the ‘mc’ package.

Midnight Commander - a powerful file manager

GNU Midnight Commander is a text-mode full-screen file manager. It uses a two panel interface and a subshell for command execution. It includes an internal editor with syntax highlighting and an internal viewer with support for binary files. Also included is Virtual Filesystem (VFS), that allows files on remote systems (e.g. FTP, SSH servers) and files inside archives to be manipulated like real files.

I would stay neutral for a client machine. Everybody is free to choose and may install any and all open source software which they hope to be convenient at their own liberty,

utterly stable. i would say. :stuck_out_tongue:

therefore - for people how are new to all that - i wouldn’t advice experimenting with tar to get one single file out of a tar archive.

1 Like

Point taken. However, someone who is not capable to list tar files and cannot at least untar into a safe folder on one’s system but is already actively tampering with the CLI or other tools at the system admin level may get lost sooner than later.

Ne discere cessa

:smiley:

Please be aware that I do not need an introduction to the command line. Also, you guys thanks for the support, but none of you seem to be getting to the root of the problem. I wiped the server, after backing up everything important and reinstalled Nextcloud. I installed all the dependencies as per the Nextcloud administration manual. So there is no reason for the edited html file to be a problem. I also tried to hint that me editing index.html was coincidental. My first troubleshooting step was to undo my changes so @TP75, I don’t need an instruction on how to copy a file to a backup. Of course I looked at the logs -at least the ones whose path I am aware of. That only means that I haven’t looked at php logs. My PHP version is 7.3…btw. How is php --version going to help me in that case then? Apache runs. So a systemd status command isn’t going to help me there. For those of you who it might help, the website is located at https://cloud.codedragon.dev. (Despite what Firefox says, my SSL comes from Let’s Encrypt. Cloudflare is set to strict ssl too though).

@LinuxDragon57 Before you start to spill the soup I would like to stress this is an open ‘home user’ forum and can have many online readers with many backgrounds. I cannot avoid to mainly address the general public while honoring at least some of the aspects of your kind personality and of your presumably educated expertise.

Please be aware certain aspects of the discussion was addressed between @Reiner_Nippes and @TP75 only and not pointing at any third person specifically.

Furthermore, one could consult the Nextcloud Community Guidelines


Be pragmatic

Nextcloud is a pragmatic community. We value tangible results over having the last word in a discussion. We defend our core values like freedom and respectful collaboration, but we don’t let arguments about minor issues get in the way of achieving more important results. We are open to suggestions and welcome solutions regardless of their origin. When in doubt support a solution which helps getting things done over one which has theoretical merits, but isn’t being worked on. Use the tools and methods which help getting the job done. Let decisions be taken by those who do the work.


No offense taken.
:innocent:

Happy hacking.
:sunflower:

right now you are at the point of initial setup. and your problem is you can’t press that buttons?
grafik

i don’t know much about cloudflare. but you are behind a loadbalancer and may look into your config.php about trusted_domains and so on.

grafik

grafik

if you believe you have made a mistake with your lamp setup. since you wiped your server. would you mind do it again?

yesterday i pushed a new version of my playbook now supporting also apache. i tested it on debian 10 on aws. but you would be my first beta tester. :wink:

if the playbook succeeds but you can’t reach your side it’s the cloudflare thing.

be aware that beside the command in the readme.md you have to perform a git checkout nextcloud-reloaded to get the new version of the playbook. the old one is nginx only.

2 Likes

Thank you so much. I honestly do not know what this implies (e.g. how to configure it if it is Cloudflare’s fault, but this is very helpful). As far as trusted domains go, I have noticed that when I install Nextcloud from the commandline that I have to manually edit my config.php file to include cloud.codedragon.dev as a trusted domain, but I don’t edit config/config.php before then. So really, nothing is set as a trusted domain right now. I could install Nextcloud from the CLI again and see if there is something more that we can find? Really, I only began using Cloudflare as my DNS so that I could use their page rules feature to create a 301 redirect on the root domain (which is unfinished and last priority compared to some of my other subdomains - so navigate at your own risk).

Thank you for your pragmatism. I apologize for my lack therof.

1 Like

well. seems to be a known issue.

https://docs.nextcloud.com/server/stable/admin_manual/issues/general_troubleshooting.html?highlight=cloudflare#other-issues

2 Likes

Cloudflare was the issue. Instead of trying to work around it, I just moved my DNS over to my hosting provider. I have some issues with Cloudflare’s ethics anyway, so it doesn’t bother me to switch DNS resolvers. Furthermore, I can just figure out how to configure apache to create a 301redirect to make up for the loss of the page rules feature.

1 Like