Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared Hosting: Can it work? #5628

Closed
codyjbennett opened this issue May 30, 2018 · 23 comments
Closed

Shared Hosting: Can it work? #5628

codyjbennett opened this issue May 30, 2018 · 23 comments

Comments

@codyjbennett
Copy link

codyjbennett commented May 30, 2018

I am working on a Bluehost shared hosting account and hoping to install Snipe-IT on a subdomain to review and test for a possible application... I consider myself a noob, so take it easy/slow with instructions - it's entirely possible I don't know what you're saying. Ha!

As it stands, I think I'm doing pretty good (installed smoothly via ssh, created database/user in cpanel, updated .env file) but stuck on how to change the document root. When I load the subdomain, I am presented with "D'oh. If you're seeing this, your DocumentRoot is set incorrectly. It should be set to the public directory."

In the error log, I see, "[29-May-2018 17:26:32 America/Denver] PHP Fatal error: Class 'Illuminate\Foundation\Application' not found in /home2/codyjben/public_html/devices/bootstrap/app.php on line 14" I believe this is in response to my creating a small test file to attempt to identify the current root that SnipeIT sees:

<html><body>
<?php
$root = dirname( __FILE__ );
echo "<a href='$root'>click here to go to home page</a>";
?>
</body></html>

This results in a URL of the href showing "http:https://devices.[domain].com/home2/codyjben/public_html/devices" as the root directory.

Per prereqs for posting, I have enabled the debug mode in the .env file. Also, I have read the common issues page.

If you need me to dive into the various troubleshooting questions, please let me know. After reading several posts in the issues section, I'm not convinced that I am capable of answering all of the questions, nor their utility considering the focused error ("d'oh!").

@snipe
Copy link
Owner

snipe commented May 30, 2018

public_html (or public) should never be in the URL. Your files should live one level up, with the DocumentRoot pointing to the public directory within the Snipe-IT project.

https://my.bluehost.com/hosting/help/274

Assuming your Snipe-IT files are all in /home2/codyjben/, the DocumentRoot should point to /home2/codyjben/public

@snipe snipe closed this as completed May 30, 2018
@codyjbennett
Copy link
Author

codyjbennett commented May 30, 2018 via email

@snipe
Copy link
Owner

snipe commented May 30, 2018

I’ve seen the mention of “public” should not be in the URL, but to date I haven’t seen an explanation - could you offer a quick articulation of why?

Because that's how most modern frameworks work. Files that shouldn't be accessed directly are supposed to live above the document root, so folks can't browse to them.

- snipe-it
---- app
---- blah blah
---- more stuff
---- public <-- this is the ONLY directory that should be accessible via a web browser
---- .env <-- file containing sensitive stuff

If your document root isn't set correctly, someone could browse to your .env file, and if your web server isn't configured correctly, it could disclose your DB settings, etc. That's why we put it above the document root.

Is there some compelling reason that I would need to start over in a different folder structure to avoid the word “public”?

It's not the word public that is the issue, it's a symptom that you're not set up correctly. If I can browse to https://your-snipe-it-site/devices/public, then I can browse to https://your-snipe-it-site/devices/.env, which, as mentioned above, would be very bad.

The link I pasted above shows you how to set the document root in BlueHost using your cpanel UI.

@codyjbennett
Copy link
Author

codyjbennett commented May 30, 2018 via email

@codyjbennett
Copy link
Author

Okay, so I changed the DocumentRoot (in bluehost, I have to remove and readd the subdomain with a new documentroot.)... I'm still running into troubles.

When I try to load http:https://my-snipe-it-site/, it shows me This page isn't working (in chrome), and cites my-site-it-site is currently unable to handle this request. HTTP ERROR 500.

When I look at the error_log within the public directory of the snipe files, I see a single line each time I try to load the page:

[30-May-2018 10:30:14 America/Denver] PHP Fatal error: Class 'Illuminate\Foundation\Application' not found in /home2/codyjben/public_html/devices/bootstrap/app.php on line 14

In app.php, lines 14-16 read:

$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);

Is there some way I can double check or adjust what should be registered for this variable?

Thanks!

@snipe
Copy link
Owner

snipe commented May 30, 2018

Did you run composer install?

@snipe
Copy link
Owner

snipe commented May 30, 2018

(Also, run ls -al on /home2/codyjben/vendor via SSH and paste what you see there.)

@codyjbennett
Copy link
Author

I thought I had followed that step, but perhaps not. Ran composer install and also ls -al in vendor. Here is what I see there:

ls -al

total 256
drwxr-xr-x 63 codyjben codyjben 4096 May 30 14:13 ./
drwxr-xr-x 17 codyjben codyjben 4096 May 30 10:24 ../
-rw-r--r-- 1 codyjben codyjben 183 May 30 14:13 autoload.php
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 barryvdh/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 behat/
drwxr-xr-x 2 codyjben codyjben 4096 May 30 14:13 bin/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 christian-riesen/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 codeception/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 codeclimate/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 composer/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 defuse/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 dnoegel/
drwxr-xr-x 10 codyjben codyjben 4096 May 30 14:13 doctrine/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 erusev/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 facebook/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 fideloper/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 firebase/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 fzaninotto/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 guzzle/
drwxr-xr-x 5 codyjben codyjben 4096 May 30 14:12 guzzlehttp/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 intervention/
drwxr-xr-x 4 codyjben codyjben 4096 May 30 14:12 jakub-onderka/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 javiereguiluz/
drwxr-xr-x 5 codyjben codyjben 4096 May 30 14:12 laravel/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 laravelcollective/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 lcobucci/
drwxr-xr-x 6 codyjben codyjben 4096 May 30 14:12 league/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 maknz/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 maximebf/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 monolog/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 mtdowling/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 myclabs/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 neitanod/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 nesbot/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 nikic/
drwxr-xr-x 4 codyjben codyjben 4096 May 30 14:13 padraic/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 paragonie/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 patchwork/
drwxr-xr-x 5 codyjben codyjben 4096 May 30 14:12 phpdocumentor/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 phpseclib/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 phpspec/
drwxr-xr-x 9 codyjben codyjben 4096 May 30 14:13 phpunit/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 pragmarx/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 predis/
drwxr-xr-x 4 codyjben codyjben 4096 May 30 14:12 psr/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 psy/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 ramsey/
drwxr-xr-x 4 codyjben codyjben 4096 May 30 14:12 rollbar/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 satooshi/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 schuppo/
drwxr-xr-x 12 codyjben codyjben 4096 May 30 14:13 sebastian/
drwxr-xr-x 4 codyjben codyjben 4096 May 30 14:12 spatie/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:13 squizlabs/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 stecman/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 swiftmailer/
drwxr-xr-x 24 codyjben codyjben 4096 May 30 14:13 symfony/
drwxr-xr-x 4 codyjben codyjben 4096 May 30 14:12 tecnickcom/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 tightenco/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 tijsverkoyen/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 unicodeveloper/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:11 vlucas/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 watson/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 webmozart/
drwxr-xr-x 3 codyjben codyjben 4096 May 30 14:12 zendframework/

Trying to load http:https://my-snipe-it-site/ gives the same 500 error as before, but the error log now shows
[30-May-2018 14:14:10 America/Denver] PHP Fatal error: Class 'Log' not found in /home2/codyjben/public_html/devices/app/Exceptions/Handler.php on line 39

Within the Handler.php file, lines 36-42 read:
public function report(Exception $exception)
{
if ($this->shouldReport($exception)) {
Log::error($exception);
return parent::report($exception);
}
}

What do we try next?

Also, FWIW, I have not yet resolved the original observation that I should not be installing snipe-it in a public_html directory (thus, the snipe-it install is at /home2/codyjben/public_html/devices/ until I solve that problem down the line).

Very much appreciate the assistance!

@codyjbennett
Copy link
Author

I should also mention that I ran into issues adding an apache user which might be part of my troubles... In SSH, I attempted useradd -g apache snipeit as noted in instructions, but received the response -jailshell: /usr/sbin/useradd: Permission denied.

Running ls -alh storage, I see:

ls -alh storage
total 28K
drwxr-xr-x 7 codyjben codyjben 4.0K May 24 18:03 ./
drwxr-xr-x 17 codyjben codyjben 4.0K May 30 14:34 ../
drwxr-xr-x 3 codyjben codyjben 4.0K May 24 18:03 app/
drwxr-xr-x 2 codyjben codyjben 4.0K May 24 18:03 debugbar/
drwxr-xr-x 5 codyjben codyjben 4.0K May 24 18:03 framework/
drwxr-xr-x 2 codyjben codyjben 4.0K May 24 18:03 logs/
drwxr-xr-x 9 codyjben codyjben 4.0K May 24 18:03 private_uploads/

Thoughts?

@snipe
Copy link
Owner

snipe commented May 30, 2018

Yeah, if you're on shared hosting, you can't create users like apache, because you're jailshelled. You should just be able to run everything as your codyjben user. Bluehost is handling all of the other stuff (apache crap, etc).

PHP Fatal error: Class 'Log' not found in /home2/codyjben/public_html/devices/app/Exceptions/Handler.php on line 39

This usually means you've got a stray space or unenclosed phrase in your .env, or you've got a syntax error in there somewhere. If you want to paste your .env here (redacting the passwords, etc) I can take a look.

https://snipe-it.readme.io/docs/installation-issues#section-fatal-error-uncaught-exception-reflectionexception-with-message-class-log-does-not-exist

@codyjbennett
Copy link
Author

That could be part of the issue. My password within .env actually includes a space; is there some type of enclosure (single quotes?) that would allow my password (with the space) to be correctly interpreted?

@snipe
Copy link
Owner

snipe commented May 31, 2018

Single quotes should work, per the documentation in the link above.

@codyjbennett
Copy link
Author

The single quotes worked. Thank you. Going to http:https://my-snipeit-site/, the setup preflight is shown; I see that my gmail send is having trouble, but decided to click on to click Next: Create Database Tables...

Now, I've got a new issue - on the following page, I receive Whoops, looks like something went wrong message. When I turn on debug and retry that page, I see the following Exceptions:

(1/3) PDOException
SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'action_logs_target_id_target_type_index'
(2/3) PDOException
SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'action_logs_target_id_target_type_index'
(3/3) QueryException
SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'action_logs_target_id_target_type_index' (SQL: alter table `action_logs` add index `action_logs_target_id_target_type_index`(`target_id`, `target_type`))

What can I do to resolve this one?

@snipe
Copy link
Owner

snipe commented May 31, 2018

Can you look at your logs? I think that duplicate key error is a false flag. I'd be curious to know what the error was before that one, when you hit the original whoops when you first clicked on Create Database Tables.

You can remove the index by using this query in your phpMyAdmin, or whatever system your shared hosting lets you interact with your databases:

DROP INDEX action_logs_target_id_target_type_index ON action_logs

My guess is that the first "Whoops" without a stack trace is the real issue, the migrations ran, but because one of those queries didn't complete right, it thinks it needs to re-run them, thus resulting in the duplicate error.

@codyjbennett
Copy link
Author

I'm not sure I know where that particular log lives - I tried looking at the /public/error_log and the error log at the core directory of snipe-it, but don't see any current errors...

I ran the DROP INDEX command within phpMyAdmin and re-tried the Create Database Tables, and the exceptions look a bit different - if you can help me copy the info you would need to dissect the problem (perhaps the stack trace?), I'd be happy to get that to you.

Here's the debugged "whoops" page screenshot I saw after the drop index - maybe it will provide you some clues?

image

@snipe
Copy link
Owner

snipe commented May 31, 2018

Run this:

DROP INDEX action_logs_target_id_target_type_index ON action_logs
DROP INDEX action_logs_created_at_index ON action_logs
DROP INDEX action_logs_item_type_item_id_action_type_index ON action_logs
DROP INDEX action_logs_target_type_target_id_action_type_index ON action_logs

And then reload the page you're seeing the whoops on.

Docs on error logs are here: https://snipe-it.readme.io/docs/getting-help#section-step-3-check-your-app-and-server-logs

@codyjbennett
Copy link
Author

Ran those. Here's what I saw upon reload of the whoops error page (http:https://my-snipeit-site/setup/migrate?):

image

Also, I was able to download the log file (1.2mb) - would you prefer a copy/paste or as an attachment to be able to review the logging?

Thanks!

@snipe
Copy link
Owner

snipe commented May 31, 2018

@codyjbennett
Copy link
Author

Hi Snipe. Thanks for all your help here. The saga continues... I'm still having troubles here. This morning I tried:

After manually dropping all tables from the database, I loaded http:https://my-snipeit-site/. This of course loads and shows me the validation checklist. I hit the next button (to generate the database tables) and I am immediately presented with the recent errors (noted above also):

Whoops, looks like something went wrong.

(1/3) PDOException
SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'action_logs_target_id_target_type_index'

(2/3) PDOException
SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'action_logs_target_id_target_type_index'

(3/3) SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'action_logs_target_id_target_type_index' (SQL: alter table `action_logs` add index `action_logs_target_id_target_type_index`(`target_id`, `target_type`))

The URL where these appear is http:https://my-snipeit-site/setup/migrate? - which I find interesting because I am not migrating - this is supposed to be a fresh install. Did I somehow trigger a migration with some earlier setting/command and now am having troubles since the database starts out blank?

So, using the earlier direction (now that I have a database filled with tables), I attempt to run the recommended SQL to set things straight:

ALTER TABLE action_logs ENGINE = InnoDB
ALTER TABLE assets ENGINE = InnoDB

DROP INDEX action_logs_target_id_target_type_index ON action_logs
DROP INDEX action_logs_created_at_index ON action_logs
DROP INDEX action_logs_item_type_item_id_action_type_index ON action_logs
DROP INDEX action_logs_target_type_target_id_action_type_index ON action_logs

I then reload http:https://my-snipeit-site/setup/migrate? in my browser and I am presented with the same PDOException errors I noted above (the 1061 errors).

Any thoughts of next steps?

Thanks again!

@snipe
Copy link
Owner

snipe commented Jun 2, 2018

Drop your tables and clear your cookies again. Before you start the /setup, open your config/database.php, find the mysql block, and change 'engine' => null, to 'engine' => 'InnoDB',, then try re-running setup.

I have no idea why you're running into so many problems here. Setup can be challenging, sure, but this is getting ridiculous.

@codyjbennett
Copy link
Author

Following your steps, we get something different... Dropped tables, changed database.php, and then loaded /setup in incognito mode and now get:

Whoops, looks like something went wrong.

(1/3) PDOException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'codyjben_snipeit.oauth_clients' doesn't exist

(2/3) PDOException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'codyjben_snipeit.oauth_clients' doesn't exist

(3/3) QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'codyjben_snipeit.oauth_clients' doesn't exist (SQL: insert into `oauth_clients` (`user_id`, `name`, `secret`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `updated_at`, `created_at`) values (, Snipe-IT Personal Access Client, DhQPzDjoNww58Goji6rgSKZORnKBm67vXupogTka, http:https://localhost, 1, 0, 0, 2018-06-02 03:53:17, 2018-06-02 03:53:17))

Snipe, as long as you're willing to continue with the tips of things to try, I'm thrilled. I've had a good experience with snipe-it on a vps in the past (I don't have access to it now), so I'm happy to go the distance here. Thanks for hanging in there with me. As the original post inquired, "can it be done?", we'll soon know! Ha! Cheers!

@snipe
Copy link
Owner

snipe commented Jun 2, 2018

It can be done - that's why we have a shared hosting section. It's just always a little tricky since each shared host is different.

Run php artisan passport:install and reload the page.

@codyjbennett
Copy link
Author

codyjbennett commented Jun 2, 2018

Success! I'm in! I had to add --force to the above command, and also noted a couple of possible errors, but I haven't seen any adverse effects. I was able to add the first user. Here is the command and response from my terminal in case anyone is reading along.

[~/public_html/devices]# php artisan passport:install --force

Encryption keys generated successfully.

In Connection.php line 647:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'codyjben_snipeit.oauth_clients' doesn't exist (SQL: insert into `oauth_clients` (`user_id`, `name`, `secret`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `updated_at`, `created_at`) values (, Snipe-IT Personal Access Client, m2hZxiBNommR4AbJr7R0u6vBme1qCsRBsmVU3oiV, http:https://localhost, 1, 0, 0, 2018-06-02 04:35:05, 2018-06-02 04:35:05))

In PDOConnection.php line 79:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'codyjben_snipeit.oauth_clients' doesn't exist

In PDOConnection.php line 77:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'codyjben_snipeit.oauth_clients' doesn't exist

When I reloaded the page, this time, I saw the setup skin with the message, "There was nothing to migrate. Your database tables were already set up!". From here, I was able to add the first user.

Snipe, thanks for your perseverance and support. As you might already know, I wouldn't have made it without you.

--

For those who are working to install Snipe-IT on a Shared Hosting platform, it can be done (at least in the case of Bluehost). If you experience troubles, open up an issue here and just keep plodding along. It obviously might take a few back-and-forth adjustments, but it can be done.

-cb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants