Apache works fine, but when I got to http://localhost/nextcloud for the final part of the setup, I get this in my browser:
* @author Joas Schilling * @author Jörn Friedrich Dreyer * @author Lukas Reschke * @author Morris Jobke * @author Robin Appelman * @author Sergio BertolĂÂn * @author Thomas MĂÂŒller * @author Vincent Petry * * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see * */ require_once __DIR__ . '/lib/versioncheck.php'; try { require_once __DIR__ . '/lib/base.php'; OC::handleRequest(); } catch(\OC\ServiceUnavailableException $ex) { \OC::$server->getLogger()->logException($ex, array('app' => 'index')); //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 503); } catch (\OC\HintException $ex) { try { OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503); } catch (Exception $ex2) { try { \OC::$server->getLogger()->logException($ex, array('app' => 'index')); \OC::$server->getLogger()->logException($ex2, array('app' => 'index')); } catch (Throwable $e) { // no way to log it properly - but to avoid a white page of death we try harder and ignore this one here } //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 500); } } catch (\OC\User\LoginException $ex) { OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage(), 403); } catch (Exception $ex) { \OC::$server->getLogger()->logException($ex, array('app' => 'index')); //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 500); } catch (Error $ex) { try { \OC::$server->getLogger()->logException($ex, array('app' => 'index')); } catch (Error $e) { http_response_code(500); header('Content-Type: text/plain; charset=utf-8'); print("Internal Server Error\n\n"); print("The server encountered an internal error and was unable to complete your request.\n"); print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n"); print("More details can be found in the webserver log.\n"); throw $ex; } OC_Template::printExceptionErrorPage($ex, 500); }
Nothing on the Apache logs, /var/log/nextcloud contains 0 bytes, so I just donât know how to proceed. Any suggestions?
How familiar are you with setting up a web server and PHP? Due to the fact that PHP code is displayed, I would tend to say that you havenât correctly configured the necessary environment to run Nextcloud.
Please follow these steps to double-check that PHP is correctly installed and configured:
PHP 7.2.24-0ubuntu0.18.04.1 (cli) (built: Oct 28 2019 12:07:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
and I can run phpinfo(); successfully on the site.
That narrows it down to Nextcloud, so I did a grep on parts of that message and discovered it comes from nextcloud/index.php. Running http://localhost/nextcloud just produced the string of text (above) but running http://localhost/nextcloud/index.php brought up the GUI.
So is that it? Unfortunately not. I set up Nextcloud in the GUI, got through to the home screen with the default files, etc. then clicked on Settings. Bang: Internal Server Error. And I now get the same message when I try http://localhost/nextcloud/index.php again. (But http://localhost/nextcloud still gives me a string of text.
Conclusion: the latest version of Nextcloud is badly broken, at least on Ubuntu. Is there such a thing as a stable build?
Based on your description I still assume that your Apache setup needs some adjustments, otherwise it would automatically open the index.php file. Please check how the following Apache parameter is set on your server and make sure that index.php is listed:
Thanks for the suggestion, but DirectoryIndex is definitely set Nextcloudâs .htaccess: ./.htaccess: DirectoryIndex index.php index.html
(Itâs in the section labelled #### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####. I tried adding your line again at the bottom and restarting Apache, but no luck.)
PHP is also enabled in Apache. apache2ctl -M shows: php7_module (shared)
Disabling and re-enabling the module makes no difference.
So I span up a AWS lightsail instance with Ubuntu 18.04 and followed the guide you referenced EXACTLY.
So, to troubleshoot, we need to replicate the issue. If there is an issue with Ubuntu, Nextcloud or the guide you used we should encounter the same error.
There was ONE correction I needed to make. To this end can you post the output of:
1.) apachectl configtest (when run from terminal).
2.) The exact contents of your /etc/apache2/sites-available/nextcloud.conf
if you have tried these steps and your system still isnât running as expected, could you please post the following WITHOUT any critical informations?
config.php
apache2: nextcloud.conf for HTTP/HTTPS or combined
@NeptuneUK hereâs what I get when I run apachectl configtest: Syntax OK
and hereâs the contents of /etc/apache2/sites-available/nextcloud.conf:
Alias /nextcloud "/var/www/html/nextcloud/"
<Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
</Directory>
@victorbw Iâve tried your two suggestions, both with no change. (Still getting Internal Server Error.)
apache2: nextcloud.conf is listed above, and hereâs Nextcloudâs config.php:
I tried that, restarted Apache, and Nextcloud did allow me to sign in. Then, clicking on Admin/Services it crashed back to displaying âInternal Server Errorâ.
So I removed your code and restarted Apache again. Still âInternal Server Errorâ. As a last resort, I stopped and started both MySQL and Apache and found I could access the site â for a while.
Nextcloud now stays up sometimes for minutes at a time, then â while in the middle of simple housekeeping tasks such as adding an email address for admin â it simply crashes out to the login screen. And wonât let me log in again. Nothingâs changed. Thereâs only one user and one password, but it insists theyâre wrong. The only way to get back in is to restart MySQL and Apache, then I can log in again.
Just tried it again. Clicked on Admin/Apps. Bang! Out again to the login screen but no login accepted. Stop and start MySQL and Apache and I can get back in again ⊠for a few more minutes.
There are no significant issues on the Overview â just a warning about using HTTP â and the NC Security Scan gives the site an A rating.
You shouldnât try to change more than one thing at a time, when performing such kind of trouble shooting. First, Iâd rule out the MySQL instance⊠no need to restart it, if itâs working. So before you restarted MySQL did you check to see, if it still runs and if you can connect to it using the credentials you have in your config.php?
Thanks for the feedback on your nextcloud.conf and the apache syntax check.
They both seem fine in terms of configuration at the site level.
1.) Could you post the contents of your /etc/httpd/conf/httpd.conf?
2.) Was this install a fresh one, on a clean box? That is to say this box wasnât in service prior to to your attempt to install NC?
3.) Does the server meet the recommended minimum installation requirements?
I noticed you deviated from the NC install guide you referenced.
As I installed on a virgin lightsail instance, using the same NC installation guide, OS (and version) and NC version, it would seem at this point to indicate that Ubuntu isnât the issue, or NC. It would point to a configuration issue with Apache. Sometimes a small omission or typo can have bewildering effect.
It also seems that the original issue you posted is resolved. That is to say .php files are not being served as text/raw files. Correct us if this is not the case. It would seem you are now dealing with other issues. @budy gave some great advice, stick to the issue at hand, one at a time, implement a suggestion, test, evaluate, feedback and if not resolved move forward, just small steps one at a time.
My personal opinion at this point would be to do a completely fresh install from scratch on a clean box if this is possible. Follow exactly the guide you referenced, donât change anything. Establish if the install and initial configuration is good. Then small steps to change data directory etc. Obviously remembering to backup your server at key points to enable you to roll-back if needed.
Thanks for the response. In response to your pointsâŠ
Iâm guessing you mean /etc/apache2/apache2.conf. (Thereâs no /etc/httpd/conf/httpd.conf in Ubuntu.) Itâs a 7K file so rather than post it here, Iâve copied it to a Pastebin link: https://pastebin.com/yxEhWSLF
Yes, this was a fresh install.
Yes, the server meets the minimum requirements.
And yes, the original issue has been resolved, and thatâs lead on to the current issue.
Iâve been developing and testing software for decades so Iâm well aware of the incremental nature of the debugging process, and that is partly why Iâm hesitant to do a fresh reinstall. NC is now working, sometimes for 10-15 minutes at a time. Then it simply crashes out to the login screen and refuses a login until I restart Apache. That suggests a problem in NC itself. (Or perhaps not. Having just typed the above, I had a crash out to an âInternal Server Errorâ screen which requires a restart of MySQL and Apache, then Iâm back to login.)
You say you tried a virgin install on Lightsail. Did you also run it for a while? Iâm back in again just now, looking at Logging, Apps, etc. then, after a few minutes, it crashes back to âInternal Server Errorâ.
Iâm not sure what you mean when you say I deviated from the installation guide. The only deviation Iâm aware of was to reference attached storage when configuring Nextcloud. The reason I did that was because I followed the advice detailed here, specifically:
Changing data directory after installation is not officially supported. Consider re-installing Nextcloud with new data directoryâŠ
(The original was also in bold type!)
Wiping the server and starting again is an option, but that will destroy any chance of learning whatâs actually going wrong here â and perhaps finding a rare, gnarly bug that could affect someone else.
So maybe it might be best to document which action you implemented that led to the original issue âNextcloud Nightmare - php code is shown instead of web interfaceâ being resolved, then marking this thread as closed and resolved, attributing whoever if anyone gave the solution that worked for you.
That done open a new thread with the new issue you are experiencing? It will make it easier for people to locate whichever issue it is they are experiencing and itâs resolution.
I ran the instance I span up for about 3 days, and it had a few visits other than myself. The instance remained available and stable during that time without crashing, displaying PHP as text/raw and there were no other issues in the error or sys logs. I obviously then terminated the instance as itâs billable.
Yes the deviation for the data directory is specifically what I was referring to. It wasnât something you mentioned previously, and is important in terms of the operation of NC (NC checks the data directory and specifcally a text file written there). If NC is unable to read the text file for whatever reason (permissions, mountpoint availability etc) you can see the âinternal serverâ error message, depending on what / how you mounted your data directory could have a bearing (eg a physical disc that is slow to respond to read requests after idling.) Also the omission could indicate other deviations you felt werenât relevant, but that possibly could be.
1.) What do the apache / NC logs have to say about the âinternal server errorâ?
2.) What happens if you change the data directory to the default location (same physical media as you NC installation?) Do you get stability.
3.) Do a fresh install, following the guide you referenced EXACTLY and see if the issue/issues are replicated again. This could point to a issue with your data directory mountpoint / media etc depending on the result. (You can always backup your current installation using your preferred method dd, rsync, tar etc) and restore later to troubleshoot if you really want to find that gnarly bug.
I just thought Iâd mention I also just did a quick install on an MS Azure compute unit (alternative Hypervizor to AWS), using the guide you referenced. All worked OK and as expected.