How to deploy react/laravel project?

Member

by deron , in category: PHP General , 2 months ago

How to deploy react/laravel project?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by hal.littel , 2 months ago

@deron 

To deploy a React/Laravel project, follow these steps:

  1. Build React App: In your React project directory, run the command npm run build. This will create a production-ready build of your React app.
  2. Configure Laravel: In your Laravel project directory, configure your database credentials in the .env file. Generate a unique application key by running the command php artisan key:generate.
  3. Set up Database: Create a new database on your hosting server or local environment and configure the database credentials in the .env file.
  4. Configure Laravel Application URL: Update APP_URL in the .env file to match the URL of your deployed Laravel app.
  5. Configure Web Server: Set up your web server (Apache, Nginx, etc.) to point to the public directory inside your Laravel project.
  6. Upload Files: Upload all the files and directories from the Laravel project to your server, excluding the node_modules and public directories. Also, upload the contents of the React build created in step 1 to the public directory of the Laravel project.
  7. Install Composer Dependencies: Navigate to your Laravel project directory on the server and run composer install --no-dev.
  8. Run Migrations: Run the necessary migrations by executing the command php artisan migrate.
  9. Install Node Dependencies: Finally, navigate to your Laravel project directory on the server and run npm install --production.
  10. Start the Application: After completing the above steps, your React/Laravel app should be ready to run. You can start the application by running php artisan serve or using appropriate commands for your specific hosting environment.


Remember to set up appropriate environment variables and security measures for your production environment.