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)
Related
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.
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 have moved my laravel project from local to production server which is centos vps.
Strange thing I'm facing is laravel can't read from .env file, And I have tested everything to make it work but no success.
I have set it's permission to 777 and it's owner to the owner of vps.
still no success.
FYI : it is in gitignore but I have created .env file on server so this problem has nothing to do with gitignore.
Can someone walk me through step by step running laravel on production server?
Exactly what should be done and what commands do I need to execute, where should I put project and where should put public directory files ?
please help me out.
Maybe you could try to clear config cache:
php artisan config:clear
In production environments you should never have a .env file. Instead, create the appropriate environment variables and PHP will read them from there.
Taken from the official DotEnv docs:
phpdotenv is made for development environments, and generally should
not be used in production. In production, the actual environment
variables should be set so that there is no overhead of loading the
.env file on each request. This can be achieved via an automated
deployment process with tools like Vagrant, chef, or Puppet, or can be
set manually with cloud hosts like Pagodabox and Heroku.
Have you tried this-
Copied from the official Documentation
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.
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.
I am newbie to Laravel. Now I am doing my very first project of Laravel 5. It is a small project.
I already developed it as beta version. Now I need to show it to my client. So I need to do staging.
I have to host it on the subfolder of our company website. For example, I need to host it in {domain}/{project_name} folder. How can I do it properly?
You just need to configure the webserver to point at the .../whatever/{domain}/{project_name}/public directory.
And of course - set proper permissions for storage, run composer install, configure your db and run your migrations, etc.