Configure Laravel application in cpanel.

Author
By Darío Rivera
Posted On in cPanel

You already know How to Login through SSH to your cpanel account and now you want to Install Laravel on your web server. The thing with laravel installation is that you have to properly configure the virtualhost in apache. However, in cpanel it is really simple. Let's see how to perform this configuration.

Login through SSH to your server

The first thing you need to do is Login through SSH to your cpanel server. If you list the files and folders in your home directory you should see something similar to the following.

total 32
lrwxrwxrwx  1 youruser youruser   33 May 13 04:27 access-logs -> /etc/apache2/logs/domlogs/youruser
drwxr-x---  3 youruser mail    4096 May 18 19:11 etc
drwx------  2 youruser youruser 4096 May 13 04:27 logs
drwxr-x--x 10 youruser youruser 4096 May  8 13:06 mail
drwxrwxr-x  4 youruser youruser 4096 May  9 07:32 perl5
drwxr-x---  3 youruser youruser 4096 May  8 13:06 public_ftp
drwxr-x---  4 youruser youruser 4096 May  9 07:35 public_html
drwxr-xr-x  5 youruser youruser 4096 May  8 13:08 ssl
drwxr-xr-x  2 youruser youruser 4096 May  8 13:06 tmp
lrwxrwxrwx  1 youruser youruser   11 May  8 13:06 www -> public_html

The next thing to do is to clone your project in this directory. Note that www is a symbolic link to public_html.  Your project should be at the same level as the files listed above.

Install Laravel

The next thing you need to do is to Install Laravel. That is, install dependencies with composer, configure permissions, configure values in the .env file, etc.

Configure public_html redirection

The magic here is to configure public_html as the root directory of your Laravel application. So far, you should have your project in a folder similar to the following one.

/home/youruser/yourproject

What we will do now is delete the public_html folder and create a symbolic link from your project folder.

rm -rf public_html
ln -s yourproject/public/ public_html

Finally, you must verify the configuration by accessing the URL of your project and see that everything is working properly. This configuration should be enough to have your Laravel application running and it is not intended to address security issues. You must consider other aspects of your environment such as whether the apache configuration is sufficient to prevent directories from being listed or sensitive files from being accessed. See you soon!.


Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.