Hi all,
I have just finished a project on DEV, using XAMPP local server.
I want to deploy on PROD, using same localhost and XAMPP.
The application runs correctly. The only thing, I always must execute the following command, to render styling correctly.
npm run dev
Now, in Production, I don't want to run this command every time I access the application.
So, I followed this doc to deploy on PROD: https://laravel.com/docs/10.x/deployment
Then, I ran :
npm run build
This command created public\build\assets files.
However, when I am trying to run my application, it renders ugly UI.
So, I have again to execute "npm run dev" comand.
@Snapey The problem is that I don't deploy, because I don't know how to.
My project's folder resides inside xampp\htdocs directory.
I have configured the hosts files, to access it from url on localhost: localhost.myproject.com
I have Breeze authentication, and the login's page styling is not rendering correctly if I not run npm run dev command in separate command window, before typing the url.
I would like to make sure that my project is built for production and not for development.
As npm run build command created assets files in public folder(JS and CSS), I guess, all I need is my application to point to the right assets: Prod and not Dev.
What Config files and which settings do I must verify?
Thank you
Do you have a shared-hosting or a VPS for your Production server? In other words, do you have ssh access on your server?
If it's a shared-hosting, chances are you don't (depending from the provider). And not just that, but you may also have restrictions on installing composer and npm.
In this case, most likely, you'll have to manually send all files through FTP client, including /vendor/ and /node_modules/ folder.
In case you have VPS or either shared-hosting server with ssh access and no restrictions on installing composer and npm, then the easiest solution is to do this through GitHub/GitLab. You push your code to your git repository, and then you ssh into your server and run git pull from there. Of course, you need to properly setup your server to access your git repository, but just trying to give you a quick information on how you can achieve it. Also you need to properly configure your apache/nginx to serve your Laravel application. Keep in mind that with VPS you need to manually install php, nginx/apache, mysql and other services needed. Here's one example on what may need to do to setup your application and deploy a Laravel project https://www.iankumu.com/blog/how-to-deploy-laravel-on-apache-server/
The easiest solution is if you use Laravel Forge or Ploi.io that takes care of all your deployment process.
Of course that there are more details in all three examples given and for sure there are more options available than these three mentioned, but since there's no information on your production infrastructure, this was just a simple answer to give you an idea of what you need to do.
@codexknight7 Running project on your PC on localhost, it means that the project is accessible only for you and your local network (as long as you don't have a Public IP). If you want this project to run in Production mode, where your project's sensitive information won't be shared to other users in your local network, then you need to at least modify your .env values to APP_ENV=production and APP_DEBUG=false and run composer install --no-dev and npm run build.
But I guess you misunderstood the concept of deploying a Laravel application on Production environment a little bit. Generally, this means that you rent a server that is publicly available to the rest of the world. You deploy your application from your local (PC) to a remote server, and at least you'll have to make sure that the application is deployed in a secure way that it won't share your app's sensitive information which could compromise your server.
@besfort Thank you for these details. Yes, I will consider to set the minimum security settings.
However, my main problem is that my application runs just fine when I do the following steps:
Open project in Visual Studio Code
Run npm run dev in command shelll
Open my application URL in browser: localhost.myapp.com
Now please pay attention.
If I don't run npm run dev command, then my app does not render JS and CSS correctly. The UI is ugly.
What I want to do is to skip running npm run dev all the time, because it is annoying.
Hi all.
I am happy to share good news.
I finally could fix my problem.
The issue was due to the outdated XAMPP server and related PHP version which comes with it.
I upgraded my XAMPP to the latest version and my website is working just fine.
So, no need for npm run dev command each time.
To upgrade XAMPP, I followed this excellent guide: https://wpmudev.com/blog/upgrading-xampp/