snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.95k stars 3.16k forks source link

Clean Install - not working #8632

Open Nais0r opened 3 years ago

Nais0r commented 3 years ago

Please confirm you have done the following before posting your bug report:

Describe the bug After clean install i get following error when trying to access setup page for the first time in httpd error log:

[php7:error] [pid 12423] [client 172.16.66.150:53716] PHP Fatal error: Uncaught ErrorException: file_put_contents(/var/www/snipe-it/storage/framework/cache/cf/90/cf906e7195218453e4ff6f1bdcdc6b2d9f6cae71): failed to open stream: No such file or directory in /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:133\nStack trace:\n#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'file_put_conten...', '/var/www/snipe-...', 133, Array)\n#1 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(133): file_put_contents('/var/www/snipe-...', '9999999999N;', 2)\n#2 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(74): Illuminate\\Filesystem\\Filesystem->put('/var/www/snipe-...', '9999999999N;', true)\n#3 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(138): Illuminate\\Cache\\FileStore->put('snipeit_app_set...', NULL, 0)\n#4 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(355): Illuminate\\Cache\\FileStore->foreve in /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 133 Browser only displayed a Blank Page at this time. My first time installing snipe-it, maybe i am missing something vital.

To Reproduce Steps to reproduce the behavior:

  1. Clean CentOS 7 Setup
  2. Follow Installation Instructions step by step
  3. Try Access Web-Based-Installer
  4. check /var/log/http/error.log

Expected behavior To start my setup process.

Screenshots not useful

Server (please complete the following information):

Desktop (please complete the following information):

Error Messages

[Wed Oct 28 19:47:02.657294 2020] [php7:error] [pid 12423] [client 172.16.66.150:53716] PHP Fatal error: Uncaught ErrorException: file_put_contents(/var/www/snipe-it/storage/framework/cache/cf/90/cf906e7195218453e4ff6f1bdcdc6b2d9f6cae71): failed to open stream: No such file or directory in /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:133\nStack trace:\n#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'file_put_conten...', '/var/www/snipe-...', 133, Array)\n#1 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(133): file_put_contents('/var/www/snipe-...', '9999999999N;', 2)\n#2 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(74): Illuminate\\Filesystem\\Filesystem->put('/var/www/snipe-...', '9999999999N;', true)\n#3 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(138): Illuminate\\Cache\\FileStore->put('snipeit_app_set...', NULL, 0)\n#4 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(355): Illuminate\\Cache\\FileStore->foreve in /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 133 [Wed Oct 28 19:47:02.657972 2020] [php7:error] [pid 12423] [client 172.16.66.150:53716] PHP Fatal error: Uncaught ErrorException: file_put_contents(/var/www/snipe-it/storage/framework/cache/cf/90/cf906e7195218453e4ff6f1bdcdc6b2d9f6cae71): failed to open stream: No such file or directory in /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:133\nStack trace:\n#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'file_put_conten...', '/var/www/snipe-...', 133, Array)\n#1 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(133): file_put_contents('/var/www/snipe-...', '9999999999N;', 2)\n#2 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(74): Illuminate\\Filesystem\\Filesystem->put('/var/www/snipe-...', '9999999999N;', true)\n#3 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(138): Illuminate\\Cache\\FileStore->put('snipeit_app_set...', NULL, 0)\n#4 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(355): Illuminate\\Cache\\FileStore->foreve in /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 133

Additional context 2 x Fresh Installs - new centos minimal installation, all clean one time with php7.3 once with php7.4

welcome[bot] commented 3 years ago

šŸ‘‹ Thanks for opening your first issue here! If you're reporting a šŸž bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

snipe commented 3 years ago

Is your storage directory writable by the web server and/or the user you're running composer as?

Nais0r commented 3 years ago

yes it is writeable

composer command was executed with root user

snipe commented 3 years ago

You should never use composer as root. That will end up making some weird file permissions, and will cause you lots of heartache later.

What's the output of ls -al /var/www/snipe-it/storage/ and ls -al /var/www/snipe-it/storage/framework?

Nais0r commented 3 years ago
[root@inventory snipe-it]# ls -al /var/www/snipe-it/storage/
total 12
drwxr-xr-x.  7 apache apache  134 Oct 28 20:14 .
drwxr-xr-x. 17 root   root   4096 Oct 28 20:15 ..
drwxr-xr-x.  3 apache apache   39 Oct 28 19:28 app
drwxr-xr-x.  2 apache apache   24 Oct 28 19:28 debugbar
drwxr-xr-x.  5 apache apache   66 Oct 28 19:28 framework
drwxr-xr-x.  2 apache apache   43 Oct 28 20:14 logs
-rwxr-xr-x.  1 root   root   3292 Oct 28 20:14 oauth-private.key
-rwxr-xr-x.  1 root   root    812 Oct 28 20:14 oauth-public.key
drwxr-xr-x.  9 apache apache  115 Oct 28 19:28 private_uploads

[root@inventory snipe-it]# ls -al /var/www/snipe-it/storage/framework
total 4
drwxr-xr-x. 5 apache apache  66 Oct 28 19:28 .
drwxr-xr-x. 7 apache apache 134 Oct 28 20:14 ..
drwxr-xr-x. 2 apache apache  24 Oct 28 19:28 cache
-rwxr-xr-x. 1 apache apache  92 Oct 28 19:28 .gitignore
drwxr-xr-x. 2 apache apache  24 Oct 28 19:28 sessions
drwxr-xr-x. 2 apache apache  24 Oct 28 19:28 views
[root@inventory snipe-it]#
sudo chown -R apache:apache storage public/uploads
sudo chmod -R 755 storage public/uploads

changed this before doing the composer install

snipe commented 3 years ago

Try deleting the contents of the storage/framework/cache directory.

You can probably use something like:

php artisan cache:clear
php artisan view:clear
php artisan config:clear
Nais0r commented 3 years ago

did above, directory is clean, restarted httpd (i did those things in my first install after googling what might have gone wrong) i found some with failed to open stream: permisson denied .. but nothing with "no such file or directory"

but still same result exactly the same error in the log :(

what is the correct user context composer has to be executed with? i can do clean install only takes 20min from snapshot

markr-metra-autosound-com commented 3 years ago

This is probably because of selinux is protecting the web folder from being written to:

semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/directory(/.*)?"

You can also test that it is selinux by running setenforce 0 (but remember to turn it back on with setenforce 1 !!!! ) then trying to run your app

snipe commented 3 years ago

We have some notes on SELinux here:

https://snipe-it.readme.io/docs/linuxosx#notes-on-selinux https://snipe-it.readme.io/docs/installation-issues#permission-issues https://snipe-it.readme.io/docs/common-issues#swift_transportexception-connection-could-not-be-established-with-host-permission-denied-13

Snipe-IT Documentation
Linux/OSX
Setting up a web server can sound daunting for folks who don't normally do that kind of thing. This guide will help you walk through the configuration for Apache or Nginx on Linux and OSX.The most common setup for Snipe-IT on a linux server is to use Apache, so if you're not sure what to pick, Apach...
Snipe-IT Documentation
Installation/Upgrading Issues
Common installation/upgrading issues and solutions
Snipe-IT Documentation
Common Issues
These commands should be run from your Snipe-IT project root, just like every other cli command we mention. They should not need to be run as root/sudo/admin.These commands clear out cached service files that help speed up modern PHP applications but can also very occasionally be out of date, resu...
mrj1600 commented 3 years ago

I'm experiencing this issue also actually. I'm running a RHEL7.9 VM on VMWare. I've set storage/* owner and group as apache:apache, tried 777 and 775 permissions, run through clearing everything as stated in the common issues wiki, completely disabled SELinux and restarted httpd. The error still persists though the app appears to be running normally so far. I'm a first-time user and this is a clean install on a freshly built server using PHP 7.4, apache 2.4, and SnipeIT v5. I used the ./install.sh method.

Has anyone else run into this issue and found a workaround?

uberbrady commented 3 years ago

The only other possible things I can think of are that maybe PHP is in 'safe_mode'? Or maybe that newer RedHat distros decided to chroot() their PHP setups by default (and, run via fastcgi)? You can check the former with php -i| grep safe. You can check the latter by doing a ps aux|grep php and seeing what the output is.

Barring that, this is pretty much standard Linux permissions stuff. We know that selinux causes problems, and we know that permissions for Laravel directories (and, thus, Snipe-IT directories) need to match the webserver's (or, the user that php-fpm is running as, if you're running that way).

mrj1600 commented 3 years ago

Thank you for your input! That turned out to be part of the issue. The scripts were executing as a different user that wasn't in the apache group. The other issue was a conflict between mod_php and php-fpm, which I corrected.

There was another issue that threw me off, but I'm not sure if this is a bug or if its working as intended. I chased my tail on the issue for most of yesterday only to realize I had actually fixed it earlier in the day. The error didn't clear from /storage/log/laravel.log. Is that typical behavior or should I submit a bug report?