Problem: How to Install and configure Laravel (8.0 v) on Directadmin?
Problem 2: Laravel uses public/index.php to run, but Directadmin uses public_html instead of the public! How to solve it?
We are here to solve these problems in our VPS or hosting service.
Firstly, Laravel needs to install composer on your server or hosting. So if you are using VPS, you can install Composer on Linux tutorial here, and if you are using a hosting service, please get in touch with your hosting provider.
You may have two different situations to your Laravel project:
- You worked on a project and want to release it on your VPS/Host. (Preferred)
- You want to create a project on your VPS/Host. (It’s not a good idea, and we don’t talk about it!)
So we consider you have a ready project and want to release it on your DirectAdmin.
Release Laravel on DirectAdmin – Method #1 change public to public_html:
- Upload your codes to your main directory before public_html or use git clone to get your project with command. (Ex: /home/your_user_name/domain.com/)
Warning: don’t upload your vendor or node_modules.
composer installto download and install composer dependencies directory. If you need to run npm in your project, use the command.
- Rename /public directory to /public_html. (if you have public_html, you can move files from public to public_html)
App\Providers\AppServiceProviderto add this code in register() function:
- Now open
server.phpin your main directory, you can see the below code, and you must replace it with new following code:
Warning: if you had a problem loading static images, you could create a symlink with /public name to /public_html. ex:
Method #2: Don’t change anything in Laravel and use the custom httpd config option in DirectAdmin (Manual)
Warning: In this method, your domain must not be listed in DirectAdmin.
Warning: You need apache configuration knowledge to do this.
- Create your domain manually in DirectAdmin file manager. ex: /home/your_user_name/domain.com/
- Open ‘ Custom HTTPD Configurations ‘ in your DirectAdmin menu.
- On this page, click on your domain’ httpd.conf‘.
- Then select customize to add custom config to your DirectAdmin.
- You must add custom virtual host code to Custom 2.
You can ask your questions and report problems in review 🙂