This might be really a painful process if you don't understand it. Here are steps and please keep in mind that ideal would be to use command php artisan serve, but on shared hosting, it's not possible I think at all of the hosting providers. It's still doable and I have for now one Laravel app working on the shared one: http://bblstock.uk. The only thing which might not work is .htaccess file. I had many times issues with this file and most of the time I've spent too much time on it. I'll add the content of my .htaccess at the very bottom of this page.
So, here are steps to make it work:
If you won't have PHP-FPM enabled on your account, your Laravel won't work! So, please check it here in MultiPHP Manager and if it's off, pls ask your hosting company to enable it:
If you are able to enable it yourself in let say WHM, then please keep in mind that it can take 2 minutes even before the change will apply, it's not instant.
Before doing anything else, we should check if settings in PHP are OK like here:
If they are not, correct them and hit:
Now you can upload files. You can use File Manager:
We should have in the file manager folder called Public Html:
Inside it, we should place our Laravel filed in some folder. I call it 'przepisy' which in Polish means recipes. Inside this folder recipes, we should unzip our whole content from localhost, github, etc. But there should be as well folder called Public. Content of this folder, we should move to Public Html.
Now it's time to edit index.php which should be in public html folder. There are two errors which we should see on the URL of our website now. If you see something like this, everything is fine. You did a good job!
Please find those links inside index.php and edit them to point like I did:
require __DIR__.'/przepisy/vendor/autoload.php';
Of course, you should not use my 'przepisy', but the name you've used to create your new folder inside the public html folder where you hold all your files from the Laravel project. Originally index.php should look like this before the change:
You might see as well an error :
The Process class relies on proc_open, which is not available on your PHP installation.
This is only because I've used Quick Admin Panel to manage users in my Laravel. If you can't install it in your PHP, your app might not work. You can change to polymorphic relationships, but if you want to use some Admin Panel, that might be the deal.
There is another way how it worked for me. I did search in google on proc_open and showed that I need to edit my flare.php file which is in the config folder. But, I did not have it here. So, they're asking to publish it by command:
php artisan vendor:publish --tag=flare-config
I did it on my localhost and found where this file is hidden. I did add this flare.php and set:
'collect_git_information' => false
But as well I went to przepisy/vendor/fascade/ignition/config/flare.php
and edit this file to have git as well false. After that I've seen my proper error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'jaffke_przepisy.users' doesn't exist
When you see this, you can just go and import data to your DB if you haven't done it yet. Maybe you haven't connected yet? Please keep in mind to set the same collation in Operations section in your MySql. Otherwise, this might trigger an additional error. As well you might see CSS failed. For a quick fix if you use bootstrap, you can use CDN Bootstrap. Otherwise, it's another topic to cover.
After this, you should be able to connect to your DB (you have to edit details of your DB in .env file if you haven't done it yet), if not, please check your .htaccess file. My files at both domains have the content which is just below this text. If you can't find either .htaccess, or .env file, but for sure you did upload it, then you should show hidden files in Cpanel. They are in the right top corner of Cpanel in Settings. Here is a content of .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
#allow from all
#####
# BEGIN WordPress
#<IfModule mod_rewrite.c>
#RewriteEngine On
#RewriteBase /blog/
#RewriteRule ^index\.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /blog/index.php [L]
#</IfModule>
# END WordPress
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
php_flag display_errors On
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 256M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
php_value upload_max_filesize 8M
php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
php_flag display_errors On
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 256M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
php_value upload_max_filesize 8M
php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit











No comments:
Post a Comment