I have created an application in laravel 5.4 and I'm running it using
php artisan serve. Now I want to host it on live server. I have some question about this.
How can we build Laravel app to host on the production server? (just like Angular 2/4).
Do we always need artisan serve to run the application?
How to communicate local development and remote development via FTP or same?
First of all i highly recommend read Laravel Deployment document, that added in 5.5 documents.
Why we use from "php artisan serve":
in the local development we have 2 way to see result of our scripts.
define a domain in local and point that to public directory of your site.
use "php artisan serve" command and word imminently after getting the script.
in the remote server you just need to point public directory.
About number 3: you can first compress your files and upload to your remote server and uncompressed that in server with tools of remote server.
How can we build laravel app to host on the production server?(just like angular 2/4).
You need a web server like apache or nginx or light httpd, then you should create a virtual host to host your project code.
Do we always need artisan serve to run the application?
No. artisan serve is just a fast demonstration tool for local test. It can't supervise file modifications so you should never use it in dev or production.
How to communicate local development and remote development via FTP or same.
Some IDE can help you to synchronize files between local and remote environment like zend studio or phpstorm(itellij studio).
Try that but pay attention to file access privilege (think of difference between 755 and 644 )
but git is always the best way to keep your production code clean.
Here are the answers of your question
How can we build Laravel app to host on the production server? (just like Angular 2/4).
You need to deploy all your files exclude vendor directory, composer.json,storage. After deployment you need to run below command
composer update
composer dump-autoload
Do we always need artisan serve to run the application?
No, You need to create DNS and it should point to your public directory.
How to communicate local development and remote development via FTP or same.
There are many ways, you can choose what you are comfortable with, like, You can use FTP or you can use version control like Git etc.
Related
So I am setting up a laravel project on my existing Ubuntu Dev server. (So I won't need to run php artisan serve)
I managed to make it work by renaming server.php to index.php and copied the htaccess from public to project root.
However I am concerned if this might create a security issue? Is there a better way how to do this?
I believe This would also apply once the app is deployed to a live server.
Any feedback would be appreciated!
EDIT:
This is for development environment only as in my /var/www I have other projects not related to laravel and cannot change apache's virtual host to point to this laravel project. (Basically I need to run laravel in a subdirectory)
I am learning laravel for a school research project and am currently stuck at this. I have installed xampp and composer so far, I installed xampp to make use of the php.exe file that composer asks for, however, I realized that when I execute this command "php artisan serve" I am able to launch the new laravel project without having xampp running, does this mean that laravel does not require a separate server?
does this mean that laravel does not require a separate server?
Not really, php artisan serve is only meant to be used for developing environment since it uses PHP's built-in webserver.
Taken from its documentation
This web server was designed to aid application development. It may
also be useful for testing purposes or for application demonstrations
that are run in controlled environments. It is not intended to be a
full-featured web server. It should not be used on a public network.
In production you should use a better webserver such as nginx.
I have created a react-laravel project using laravel-mix. Right now I am run project using
npm run watch
php artisan serve
So by this, I access project by : http://localhost:8000
I have also worked in laravel. In laravel, if we want to access project without php artisan serve then we can access using : http://localhost/project_name/public.
Now my question is, how can I access/execute react-laravel project without php artisan serve? Is there any kind of way to access/execute project without port? Because I want to set up react-laravel on live server and I don't want to continue open terminal on server after code uploading.
I will really appreciate your feedbacks.
There are a multitude of ways to set up a laravel project. and it has nothing to do with the frontend suite you use whether its React or Vue, I will give you 2 options here to run a laravel application.
1. vagrant/homestead
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!
Doc Link
2. XAMPP/WAMP/ or any LAMP stack
XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.
Link
Personally I prefer Laravel Homestead since it contains everything out of the box for laravel Development. like PHP, Nginx, MariaDB, Node, etc...
I need to understand this behavior.
I use xampp for web development. I start to apache server in the xampp gui and then I can start my projects in the browser via localhost...
Since yesterday I have added laravel to my mac book. My project is in the xampp htdocs folder and I want to use it witch xampp. But when the xampp apache server instance is running, nothing is happened to my laravel project until I run php artisan serve in the cmd.
How can I combine larael with xampp?
And what exactly does php artisan serve do? Start another apache server instance?
The artisan command is just a command line utility for laravel. The serve command just starts up the PHP server.
to run it without artisan you can Configure a server virtual-host (Apache or Nginx) which have the public directory of your project as root directory. Since you are using a MAC I can't exactly instruct you to how to do that.
NOTE
this will help to create the virtual host. but i haven't tried that
sorry i can't comment due to reputation :/ i use lumen (rest api of laravel) with xampp and it works fine. Can you provide somemore details?
I also think the path is the problem. Which path you use to access it via a browser? for lumen its /htdocs/project/public/ so in browser: http://localhost/project/public/
there i can access the api. should be similar for full laravel project?
Create virtual host and point it to laravel_directory/public/index.php and restart apache.
Creating apache virtual host:
http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost
If you don't want to do that load, localhost/lara_dir/public/index.php
index.php is where all the requests go through.
I am using laravel 5.2 to develop app.
As of now I am using php -S localhost:8888 -t public to deploy the test development app.
I know that I have to change configuration file .env for production.
But itseams I can't use php artisan serve or php -S localhost:8888 -t public to deploy the app as production app.
I am using WAMP in my machine. Currently I placed my laravel app in C:\wamp\www\laravel.
What are the correct steps to deploy my laravel 5.2 app?
php artisan serve creates a local, development, very basic HTTP server and is not for production. It won't handle more than a handful of visits and will break quickly, and isn't secured in the way Apache or Nginx are.
Based on your directory path C:\wamp\www\laravel, I guess you are using a WAMP server? The A in WAMP is Apache - the web server you use instead of php artisan serve.
Setting up the site on a production server will vary based on your setup, but the general steps will look like:
You should just put your project files straight into in your WAMP directory
Run composer install to install the dependencies.
Edit the database and other vars in your .env file.
Ensure that WAMP is running and the site is configured and you should should be good to go.
If you don't have much server experience and just want to securely and simply host a Laravel app, I would strongly suggest checking our Laravel Forge - it does everything and your site will be on the public Internet within 10 minutes.