Error 404 after creating new website on installing laravel web app

Hi @usmannasir @die2mrw007 @qtwrk @shoaibkk

I am facing a strange issue which started occuring after I upgraded to latest stable version 2.3.2.

Whenever I try to setup a laravel web app, by creating a fresh website using cyberpanel the site starts with cyberpanel installed index.html

But after I remove it and upload the web app files in the root directory and try to open the install wizard or access index it shows me 404 error.

I know this has something to do with htaccess rewrite rules as this is an issue with all new websites we create but previously it got fixed if we saved rewrite rules by manage website page as it added rules generated by cyberpanel by editing htaccess file but now if I do it then starts to show error 403.

RewriteEngine On

RewriteRule . /public/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

I tried to manually edit the htaccess file with solution you mentioned in this post but still the same 403 error.

Here is the link to my htaccess rules content : htaccess content - Pastebin.com

In forum previously it had a tutorials section where there was a guide to fix error by editing virtual host config & context from OLS web console but I am unable to find it now.

I would really appreciate any help in this matter. Thanks.

Start by understanding the error 403 Access Denied – You don’t have permission to access.

First ensure the following directories are writable:

chmod -R 777 storage
chmod -R 777 bootstrap/cache

Also check ownership of public folder - directory flags drwxr-x--- ( octal notation 750) and all the files contained (index.php, .htaccess) with directory flags -rw-r--r-- (octal notation 644)

Also try a simple .htaccess as done here How to setup a Laravel application on CyberPanel! in the blog post.

Also scan you server files for malware using ImunifyAV offered via CyberP or whichever malware scanner your hosting provider offers you.

I see you are serving public files from same folder as the application files are in. This is not recommended. To deploy Laravel application you need to separate public folder (served files) from application files.e.g. /home/ cloudride.com/aap for application files, copy all public contents to /home/ cloudride.com/public_html or if its a subdomain move public files to location such as /home/ cloudride.com/public_html/subdomain or /home/ cloudride.com/subdomain

Finally change path of

require __DIR__.’/../bootstrap/autoload.php’; and
$app = require_once __DIR__.’/../bootstrap/app.php’;

to

require __DIR__.’/../aap/bootstrap/autoload.php’; and
$app = require_once __DIR__.’/../aap/bootstrap/app.php’;

Hi @josephgodwinke

Thanks for replying to post, if you check my post again I mentioned it shows error 404 when I create a new website & when I upload contents for the web app to public_html directory first.

Then if I try to use fix permission option in files manager or use the save rewrite rules which inserts the cyberpane rules in htaccess files then it starts to show error 403

You will face a 404 error most of the time in every new website you create using cyberpanel but previously it got fixed by just using fix permission in files manager or just saving the rewrite rules in website manager refer below image.

I previously resolved this kind of issue with help of @qtwrk on old forum of cyberpanel, it’s related to permission setup & can be fixed by editing entries of virtual hosts OLS console but I am unable to find that tutorial link.

Hopeully @usmannasir @shoaibkk can help in this matter.

I tried very hard to solve this problem. I tried many things. Finally, I simply solved the problem. Things to do:

  1. Login to Litespeed Webadmin Console. (https://IPaddress:7080)
  2. Click the Virtual Hosts button in the left menu.
  3. Find that domin you’re looking for.
  4. Go to the “General” tab.
  5. Add “/public” at the end of the “Document Root” section under the “General” section in the “General” tab.
  6. Save it.
  7. " Configuration has been modified. To apply changes, please perform a graceful restart." warning will appear.
  8. Click the green restart button in the upper right corner.
  9. That’s it.

1 Like

Thanks @ofyalcin I will try this and update back if it solves the issue.

I have tried editing the vhost config for the domain and added /public Document Root contexts. Performed a graceful restart but now again I am getting 404 error.

The solution @ofyalcin shared did not worked for me.