lat4732's avatar
Level 12

Problems with installing my app on a live server

Hey everyone!

Yesterday was the day of testing the deployment of the app and how it works on live server. I've uploaded the app through cPanel and I'm using Postgre as a database. What I did so far:

  1. Upload the files inside public_html.

  2. Edit .env and .env.example with things like APP_URL, database information etc...

  3. Opened the terminal through cPanel.

  4. Run php artisan migrate, which actually caused an error for old version of PHP, because we installed the newest composer which was released 6 days ago that requires minimum version of PHP 8.

  5. Changed the PHP version to 8.

  6. Tried to run php artisan migrate again which caused an error could not find driver .... Image of the error: https://imgur.com/a/Zq20WUx

But now I'm stuck. What should I do? What actually means this error?

The server has MySQL Databases and PostgreSQL databases installed. I defined in the .env files the following:

DB_CONNECTION=pgsql
DB_HOST=localhost

Is that actually correct? Should localhost actually work? Which file should I actually edit - .env or .env.example or both?

Also what should I do to run the app generally? php artisan serve is for local development, right? When I open the website URL right now I see a Index of / page with the files.

Also, currently the app is in subdomain of the main domain. Can this cause any problems?

Thanks in advance!

Previous thread: https://laracasts.com/discuss/channels/laravel/i-need-some-tips-on-how-to-move-on-with-the-app-im-building?page=1&replyId=767709

0 likes
23 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

First of you need the server guy to install pdo_pgsql. That should fix the error. You might be able to do this inside the cpanel. I found a random guide for enabling php modules: https://cwcshd.freshdesk.com/support/solutions/articles/15000017930-how-to-enable-pdo-in-whm-cpanel

Correct. Dont use php artisan serve. They need to set up the webserver (apache or nginx) to point to /path/to/your/site/public/. Be sure that it points to the public directory and not the root of the project! You might be able to do this inside the cpanel

1 like
Sinnbeck's avatar

@Laralex Be aware that the second part isnt needed if you follow the advice by @snapey

But you can see if you can set the path inside the cpanel instead.

Sinnbeck's avatar

@Laralex Ok. If the files are inside that directory, you need to find a way to point the path to public_html/public. Otherwise people gain access to your .env from the address bar..

lat4732's avatar
Level 12

@Sinnbeck Yep, I understand that. We'll do what you're saying and I'll reply back if there are any problems.

lat4732's avatar
Level 12

Hey @sinnbeck! We've done what you said.

  1. Installed pdo_pgsql

  2. Restarted the apache

  3. Changed the root directory to public_html/public

  4. Restarted the apache

The site is currently running but I faced another problem. Its not loading the css files and scripts. On the view-source page when I click on a link for any of the css files they are opening, but not loading on the pages generally? What can be the issue?

I'm loading the files through the asset() helper function.

Sinnbeck's avatar

@Laralex Any chance you can share a link to a test page so I can inspect the issue? It could be because you are serving the assets as http, and the site as https. That wont work as the browser will not load insecure assets from a secure page

lat4732's avatar
Level 12

@Sinnbeck The assets are loaded with http:// as I can see in the view-source page. And I'm accessing the page through https:// which might actually cause the problems. But I can't access it with http:// probably because the server is configured to redirect to https://. I'm not sure If I can give you the link to the website, I'll ask for a permission and If so I'll share ya. How do I skip the check for insecure assets during the loading of the scripts and stylings?

lat4732's avatar
Level 12

@Sinnbeck Hey. We actually have a valid certificate from cloudflare. We've turned on the SSL certificate for the domain and set the Always HTTPS to true. But now we've came back to the Index of / page. Any ideas why?

When I click to open the public directory from the Index of / page I recieve:

No input file specified. 
lat4732's avatar
Level 12

@Sinnbeck We turned on the SSL certificate for the domain and right after that when I accessed the website I'm receiving the Index of / page again. Remember we changed the root directory to public_html/public. What could have happened?

Sinnbeck's avatar

@Laralex So you are getting a file listing? Sounds like the site does not understand that it is a PHP website (so the php handling is turned off)

Snapey's avatar

@Laralex do you see the files of your project or the files of public folder?

lat4732's avatar
Level 12

@Snapey I see the files of the project, it looks like we have done nothing for the root directory to change.

@sinnbeck I think the problem is with the root directory again. I have no idea why it might reset after enabling the SSL certificate.

Snapey's avatar

step #1 was incorrect

Your app doesn't belong in the public_html folder, it belongs one folder higher. then delete public_html and recreate it as a symlink that points to your projects public folder

don't bother editing .env.example

1 like
lat4732's avatar
Level 12

@Snapey That sounds so confusing. How will my project run when I put it between folders such as public_ftp, php, perl5, mail, ssl etc...? Isn't public_html the folder where you put all your files? The public_html is the folder which is actually visualized when you open the domain name as far as I know.

So I never edit the .env.example, right?

Sinnbeck's avatar

@Laralex You only edit .env.example to show other programmers what values their .env file would need if they are going to work on the project (so just dummy values)

1 like
lat4732's avatar
Level 12

@Sinnbeck And what about MEMCACHED_HOST= and REDIS_HOST= in the .env file? Do I need to edit them? When I uploaded the app they were set to 127.0.0.1 and I've edited them with the current domain name. Is there a documentation for the meanings of everything in the .env somewhere?

EDIT: I've restored the original .env.example.

Sinnbeck's avatar

@Laralex Just ignore them if you dont need them. Or remove them. Of course if you need to use redis or memcached, you should edit them to the correct values

1 like

Please or to participate in this conversation.