Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bertmi01's avatar

Help with new production server setup

I have a project that has been stuck on Laravel 7 and I just updated it to 10. Works great locally on my Windows dev machine with Laragon and works great on a test server I have on forge. The current production server is running on Ubuntu 18, php 7.2, Mysql 5.7... It seems like it would be a huge pain to try to update all of that, and not even sure I could successfully update Ubuntu without getting locked out. So I opted to spin up a new production server on Forge with everything up to date (like test and local dev).

Unfortunately, I can't view the app in the browser when navigating to the server address. In Firefox, I see "Problem loading page, The connection was reset". No difference when enabling debug in .env or setting environment to test.

The app seems to be deployed just fine. Artisan commands work, DB was migrated, cleared caches and all that.

I think the problem probably lies with me not understanding the folder structure / APP_URL? The app folder is "subdomain.domain.org", which is the same as the current production server, and APP_URL in .env is the same. Of course, the actual domain points to the current production server, but I don't want to point it to this new server until I'm sure it's working. SSL is not set up on this yet.

Any help would be sincerely appreciated!

0 likes
7 replies
LaryAI's avatar
Level 58

It sounds like you're facing a common issue when deploying a Laravel application to a new server environment. Here are some steps to troubleshoot the problem:

  1. Check Server Requirements: Ensure that the new server meets the system requirements for Laravel 10, which includes PHP 8.0 or higher. You can check the PHP version by running php -v in the terminal.

  2. Configure Environment Variables: Make sure that the .env file on the new server has the correct settings for your application, including APP_URL, database credentials, and any other necessary configuration.

  3. Check Web Server Configuration: Verify that your web server (Nginx or Apache) is configured correctly to serve your Laravel application. The document root should point to the public directory of your Laravel application.

  4. File Permissions: Ensure that the storage and bootstrap/cache directories are writable by the web server. You can set the correct permissions using the following commands:

    sudo chown -R www-data:www-data storage bootstrap/cache
    sudo chmod -R 775 storage bootstrap/cache
    
  5. Clear Caches: Since you've migrated the database and deployed the application, clear all caches to ensure that the application is not using any stale configuration. Run the following artisan commands:

    php artisan config:clear
    php artisan cache:clear
    php artisan route:clear
    php artisan view:clear
    
  6. Check Logs: Look at the Laravel log file in storage/logs/laravel.log for any application-specific errors. Also, check the web server's error logs for any server-level issues.

  7. SSL Configuration: If your application is supposed to run under HTTPS, browsers may refuse to connect if the SSL certificate is not set up correctly. Since you mentioned SSL is not set up yet, you can temporarily test the application using HTTP, but remember to configure SSL before going to production.

  8. DNS and Hosts File: Since you haven't pointed your domain to the new server yet, you can modify your local hosts file to point the domain to the new server's IP address for testing purposes. This will allow you to access the application in the browser as if the domain was already pointed to the new server. Remember to remove this entry after testing.

    On Windows, the hosts file is usually located at C:\Windows\System32\drivers\etc\hosts. On Linux and macOS, it's at /etc/hosts. Add a line like this:

    new.server.ip.address subdomain.domain.org
    
  9. Firewall and Ports: Ensure that the firewall on your new server is not blocking HTTP/HTTPS traffic. Also, make sure that the web server is listening on the correct ports (80 for HTTP and 443 for HTTPS).

After going through these steps, try accessing your application again. If you still encounter issues, the error messages from the logs or any new symptoms should help you narrow down the problem further.

bertmi01's avatar

@LaryAI

#1: OK

#2. OK as well - but I'm not 100% sure. Should APP_URL be the eventual domain, or http://localhost for testing purposes until DNS is configured for production?

#3. OK

#4. OK

#5. OK

#6. Nothing in logs other than some unrelated logs

#7. NA as not configured.

#8. Haven't tried this, but not sure this is the issue as I have two other test sites running fine by having the project in the "default" folder where I can use the app by just navigating to the server in HTTP. Is this just doing something like "test.subdomain.domain.org" in my case?

#9. Server should be configured to allow HTTP

martinbean's avatar

@bertmi01

This reply was automagically generated by our local A.I. Think of it as a one-off attempt to instantly solve your problem. It will not respond to further replies.

Snapey's avatar

step 8.

your new install will be using virtual hosts which means the server can host multiple sites unde4 the same ip address and relies on a host header sent by the browser to say which server it wants to reach.

This will not happen if you try to load by ip address

You need to add an entry to local hosts file so that you can reach the new server by its corr3ct domain name

Garet's avatar

In addition to what @snapey said above, are you seeing anything in the Apache error log /var/log/apache/error.log ?

bertmi01's avatar

@snapey Ok, I tried this but now I get the same result via the domain name specified in localhosts.

I re-read this on The Basics for Forge:

When you initially provision a Forge server, Forge creates a single site on the server named default. This site may be accessed by visiting the IP address of your server in your web browser. This is convenient because sometimes you may not have a particular domain you want to associate with a given server immediately after provisioning.

When you are ready to transition your application to an official domain name, you may rename the site in the Settings tab of the site's management panel. After renaming the site, you will no longer be able to access it using the server's IP address. After renaming the site, you should add a DNS A record for the domain that points to your server's IP address.

So I renamed the site using the Meta page back to 'default', checked NGINX config and it all referenced 'default', rebooted the server, tried again, no luck. I've done exactly what Forge says above for two other servers and test sites - each server only has a 'default' and I can access the apps fine by navigating to the server's Public IP with no need to change anything in my localhost file on my local machine to access. Maybe I should just shutter the server and try all over again just using the default site from the start? Then when it's good, rename it to the actual domain and update the DNS?

Thanks a lot for your earlier response.

@garet no apache folder in /var/log/ so maybe that means there haven't been any issues?

bertmi01's avatar
bertmi01
OP
Best Answer
Level 3

Ok, I destroyed the server, spun up a new one, deployed the site, and everything works fine.

The only possible difference I can think of is that when doing updates on the first server, I noticed that some upgrades were held back:

The following packages have been kept back:
  linux-aws linux-headers-aws linux-image-aws ubuntu-advantage-tools
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
root@pax-training-prod:/home/forge# apt list --upgradable
Listing... Done
linux-aws/jammy-updates,jammy-security 6.2.0.1018.18~22.04.1 amd64 [upgradable from: 5.15.0.1028.26]
linux-headers-aws/jammy-updates,jammy-security 6.2.0.1018.18~22.04.1 amd64 [upgradable from: 5.15.0.1028.26]
linux-image-aws/jammy-updates,jammy-security 6.2.0.1018.18~22.04.1 amd64 [upgradable from: 5.15.0.1028.26]
ubuntu-advantage-tools/jammy-updates 30~22.04 amd64 [upgradable from: 27.13.3~22.04.1]

and I think I brute-forced them on the last server with sudo apt-get dist-upgrade, which likely resulted in all of this fun. Hope this helps someone in the future...

Please or to participate in this conversation.