Run Laravel on existing Apache server - php

I have a DigitalOcean server running Ubuntu 14.04. I'm using this as a host for my web-development projects.
Now I want to start using Laravel for a project of mine, but I have a question about this.
In the /var/www/html folder of Ubuntu I created a folder, let's say, "project". In this folder I installed Laravel using this tutorial. Now everything is setup I want to run Laravel so I can test it and start developing on it.
When I run the command php artisan serve from within the "project"-folder it says "running on http://localhost:8000". So it's working.
But how do I access it? When I go to http://example.com/project it just shows me the files in that folder.
So it's running on the localhost on my server. Does that mean that it is external-accesible (the url above) or how does this work? (I guess the port is also different, 8000 instead of the default 80 for Apache)
I hope the question is clear and someone can help me out.

I have a Laravel project up and running on Digital Ocean with the Ubuntu 14.04 x64 vmlinuz-3.13.0-24-generic (1221) kernal.
I don't think you should be using php artisan serve for this purpose, as that is more for your local computer if you would like to preview your webpage if you don't want to use Apache.
To get set up, I used the excellent below instructions that were incredibly helpful. As you can see, there are many steps that you should carefully follow to get things up and running.
https://github.com/susanBuck/dwa15-fall2016-notes/blob/master/01_Servers_and_Git/07_Deploy_to_Digital_Ocean.md
Let me know if that helps you, and feel free to follow up with more questions if you get stuck on a step.

Related

My laravel project start page is not opening

I have install Laravel in my pc using composer.
I used gitbash and started xampp control server
First I've changed my directory.
Then I've ran a command composer create-project laravel/laravel project_1. After the command had run, it installed laravel and all necessary file and key was successfully set.
Then I again changed my directory to project_1
Then I ran another command php artisan serve. After running this command Laravel development server started and 127.0.0.1:8000 this ip has genrated.
I copied the id and paste it in my browser url bar.(I copied and pasted it without using keyboard. I only used mouse)
but when I provided the ip the project_1 starting page did not open.
The page was loading and it is still loading.
what can I do? Please help
logs folder
Here is my contribution, I cannot say what is the cause but I have a solution for it; because I have such as a challenge.
run
php -S 127.0.0.1:8000 -t public
Note that the 8000 is your port, and this could be any 4-digit number.
I hope this helps
Every thing you did seems right to me in terms of Laravel requirements, so lets check some other possible issues:
make sure that your internet connection isn't configured to use
proxy, if so make sure you excluded your local address.
if you are using Internet security suite software, make sure it doesn't block your requests, this vary from software to another but you might test this by deactivating the software for a while until you try.
now that's what I have in mind, I hope it help.
First, stop the php artisan serve
After changing directory go to inside your project folder, you can run php artisan serve. Then a localhost URL will be generated for you where you can see your project in the browser
If you have PHP installed locally and you would like to use PHP's built-in development server will start a development server at http://localhost:8000
Please try to install Laragon and forget about Xampp for now. This is really cool tool and you'll start much quicker. I did try to resolve few issues with Xampp myself and always wasted a lot of time. You can google tutorials later for it as well. Plenty of info out there.
As well it comes with in house installer for Laravel ;) and more :).
Make sure that you are not coping the url from Git Bash through command, it will stop running the project
Make sure that you are not using antivirus specially avast antivirus.

Trying run working Laravel project on my PC via XAMPP

I have a whole project with database, everything is working here.
Project with database
I would like to run website so I can see changes I have made.
Im using XAMPP. My configs for VirtualHost hosts and http-vghosts.conf
I have tried this https://youtu.be/iXYCnYRalaw?t=2m13s ->> from [2:13] to [4:22]
using XAMPP, but still cant run it.
Can you give me any advice or steps how to make website run on my PC? [ofcourse just for me (VirtualHost)].
Editor using: Atom
My PC spec
If running laravel appliation inside XAMPP htdocs folder is really necessary, then could you provide some kind of error, simply telling "it doesn't work" doesn't help at all.
One thing you can try is to open command prompt inside laravel folder and run
php artisan serve
This will open local server that runs current project in:
http://127.0.0.1:8000
Also, checking laravel minimum requirements is something you should check out. 5.5 requires PHP 7 and you didnt tell what XAMPP version you are running.

How to set up React-Laravel project with out php artisan serve?

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...

Laravel with xampp

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.

(Laravel) SSH install VS upload folder in server

Are there any differences between using ssh to install laravel
and
just upload my laravel project folder which works on localhost
Since I just upload my laravel project to server but appear Error500
So I want to follow the below tutorial to install a new laravel project with ssh and upload my project to replace it.
https://www.youtube.com/watch?v=DsgWKuGk3yM
You must give write permissions to the storage and bootstrap/cache folder. If the problem still occurs, check error logs and post the error here.
Regarding your initial question which isn't very clear at all, wether there is a difference between uploading your project files and ssh-ing into your VPS or your VM: what is your working environment, and I assume you are uploading these files somewhere else?
There are 2 situations: you are just getting started, and in this case I recommend you follow the official docs, not a YouTube video, and have a local instance where you can work and synchronise files easily between the guest and the host. I would recommend having a look over Homestead or Valet if you are on OS X or macOS. The documentation is very clear and concise.
The second one: you want to deploy your app, in this case a hosting management tool would help you out with this process (of course there is a much more to do with the configuration), as it's pretty much a chore to setup every requirement and dependency for your server, but that's an alternative too if you wish.

Categories