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

LordV8or's avatar

Deployment

Is there a laracast, YouTube video, or step-by-step instruction on deploying an app on shared hosting? I'm currently using Godaddy for testing, I'll be using AWS in the future so it would be great if there were a source of knowledge on deploying on both. I've gone step by step using this video: https://www.youtube.com/watch?v=UPCMtfIaGpA&t=436s I get a 500 error when trying to run it. Where do the error logs go so I can find out what is going on?

0 likes
3 replies
LaryAI's avatar
Level 58

To deploy an app on shared hosting, such as GoDaddy, and later on AWS, you can follow these general steps. I'll also provide some guidance on how to troubleshoot the 500 error you're encountering.

Deploying on Shared Hosting (GoDaddy)

  1. Prepare Your Application:

    • Ensure your application is ready for deployment. This includes setting up environment variables, configuring your database, and ensuring all dependencies are installed.
  2. Upload Your Files:

    • Use an FTP client (like FileZilla) to upload your application files to your GoDaddy hosting account. Typically, you will upload your files to the public_html directory.
  3. Configure Your Environment:

    • Create a .env file in the root of your application and configure it with your production settings (database credentials, app URL, etc.).
  4. Set Up Your Database:

    • Use GoDaddy's cPanel to create a new database and user. Update your .env file with these credentials.
    • Run your database migrations using a tool like phpMyAdmin or through SSH if available.
  5. Set File Permissions:

    • Ensure that the storage and cache directories are writable. You can set permissions using your FTP client or through the cPanel file manager.
  6. Update Your Web Server Configuration:

    • Ensure your .htaccess file is correctly configured to handle URL rewriting if you're using a framework like Laravel.

Troubleshooting 500 Errors

  1. Check Error Logs:

    • On GoDaddy, you can find error logs in the cPanel under the "Metrics" section, look for "Errors" or "Raw Access Logs".
    • Alternatively, you can create a custom error_log file in your application directory by adding the following line to your .htaccess file:
      php_value error_log /path/to/your/application/error_log
      
  2. Enable Debugging:

    • Temporarily enable debugging in your .env file by setting APP_DEBUG=true. This will display detailed error messages in your browser. Remember to set it back to false after troubleshooting.

Example .htaccess for Laravel

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ / [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Deploying on AWS

  1. Set Up an EC2 Instance:

    • Launch an EC2 instance with your preferred operating system (Ubuntu, Amazon Linux, etc.).
  2. Install Required Software:

    • SSH into your instance and install necessary software (Apache/Nginx, PHP, MySQL, etc.).
  3. Upload Your Application:

    • Use SCP or SFTP to upload your application files to the EC2 instance.
  4. Configure Your Environment:

    • Set up your environment variables and database configuration.
  5. Set Up Your Web Server:

    • Configure Apache or Nginx to serve your application. Ensure your virtual host configuration points to the correct directory.
  6. Set Up a Database:

    • You can use RDS for a managed database service or install MySQL directly on your EC2 instance.

Example Nginx Configuration for Laravel

server {
    listen 80;
    server_name your_domain.com;
    root /path/to/your/application/public;

    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Conclusion

By following these steps, you should be able to deploy your application on both shared hosting and AWS. Make sure to check the error logs to troubleshoot the 500 error you're encountering. If you need more detailed guidance, there are many tutorials available on Laracasts and YouTube that cover deployment in depth.

jlrdw's avatar

Besides the AI answer, there has been many past posts on setting up Shared host. Many even have how to articles.

PeteBatin's avatar

Have you tried Google? I can't post links (thinks it's my first day here) but there's a good article on Medium dot c o m that looks fairly comprehensive, the article is titled "Deploy Laravel Application on Shared Hosting (Godaddy)"

Please or to participate in this conversation.