Osijek,
Croatia
+385 95 578 4732
MON - FRI, 4PM - 10PM
ivan@javorovic.com
REPLY IN 24 HOURS
Ivan Javorović profile image

Ivan Javorović

Full Stack Developer

  • BORN : October 3, 1995
  • NICKNAME : Jawe
  • FAVORITE BAND : The Beatles

Setup Laravel 5.6 on reseller hosting (FULL GUIDE)

3,467 views

NameCheap, php version, cPanel, Upload, Project, .env, Mail, phpMyAdmin, Database, Reseller Hosting, Laravel 5.6, MochaHost

If you already don't have a domain I recommend getting it from Namecheap.


Also if you need a hosting provider I suggest MochaHost.


Now with that out of the way, lets get started!



Step 1 (Setting up your Database)



First log into cPanel (www.example.com/cpanel) and click on MySQL Databases.

On the top you have the option 'Create New Database', enter your database name in the input below and press the button 'Create Database'.


Now scroll down until you see the option 'MySQL Users' => Add New User.

Enter your username and password (I recommend generating a password and saving it somewhere safe).


After that scroll down to 'Add User To Database'. Select the User you just made and the Database and press Add.


A new window will open where you can pick the privileges (which the user has over the database), such as drop, create, update etc.

For security purposes I recommend not adding all privileges to the same user.



Step 2 (php version)



Since we're using Laravel 5.6 which requires php version >=7.1.3 we need to change a few things (if you server uses php 5.6 by default).


To change this you need to go to your cPanel and scroll down to 'Select PHP Version'.


Once opened in the top left corner you have a dropdown where your php version (I use 7.2, it just needs to be >=7.1.3).


Also here you can select a few options you would like to use (I usually leave them on default, depends on the project).


My default checkboxes are bcmath, dom, fileinfo, gd, imagick, imap, json, mbstring, mysqli, mysqlnd, pdo, pdo_mysql, pdo_sqlite, phar, posix, sockets, xml_reader, xmlwriter.


Click 'Save' in the bottom left corner and then click 'Set as current' on the top left.



Step 3 (Making your webmail) *Optional*



Go to you cPanel and click on 'Email Accounts', once opened go to 'Add Email Account' and type in your new Email and Password (again I recommend generating a password).


After that click on the button below 'Create Account'.

You just created your webmail!



Step 4 (Uploading and setting up the project)



Zip up your whole project,  open cPanel  and go to File Manager and upload it to your main root directory on your server (right outside of your public_html folder) -it's the first directory that opens right after you click on File Manager.


Now that your zip file is uploaded, extract it in your root directory (make sure you make a new directory to extract the project in).

Your new directory should have the path something like this  '/home/user/newDirectory'.


The new directory contents should look something like this:


As you might have noticed the 'public' folder is missing.

That's because everything you have in you public folder should be moved to your public_html folder.


Your public_html  folder should look something like this:


Now we need to change your index.php inside your public_html directory to direct the app to your autoload.php and app.php.


To do this right click on your and click on 'Edit' or 'Code Edit' make sure utf-8 is selected.

Edit these two lines something like this (so they aim for the new directory you just made):



Now go back to the new directory you made earlier (in you root directory) and edit your .env file.


First turn off debug mode, to do this change this line of code:


APP_DEBUG=false


Also change DB_DATABASE, DB_USERNAME  and  DB_PASSWORD  to the ones we made earlier when we were setting up the DATABASE.

If you forgot the names you can go back to your cPanel  and check them by going to  MySQL Databases.



**OPTIONAL**


You can setup your email here as well.

Go to you cPanel (don't close the .env file).


Go to 'Email Accounts', scroll down and you'll see the email we created earlier, click on 'Set Up Mail Client'.


By scrolling down you will see on the left side 'Secure SSL/TLS Settings'.

As we're looking at these settings were going to edit the .env file as follows.



MAIL_DRIVER=smtp

MAIL_HOST= (The incoming Server that's listed in your settings ex. 'something.example.com')

MAIL_PORT= (The SMTP port listed in your settings ex. 465)

MAIL_USERNAME= (The email that you created ex. example@example.com)

MAIL_PASSWORD= (The generated/written password you made while making the email)

MAIL_ENCRYPTION=SSL


That's it, now save the changes in your .env file.


The only thing left is to go in your localhost and export you database, you do this by going to phpMyAdmin (locally)  and clicking on the table you want to export, then clicking on the export button on the right and download the .sql  file.


Now go to you cPanel  and click on phpMyAdmin, click on Databases  and select the database that we've made earlier.


Once you've done that you can click on the Import option in the top right and select the .sql  file you just downloaded, click on 'Go' and you're done!


Congratulations your project is setup!


By: Ivan Javorović