which means there must be some links broken, show us your console errors so we can help you.
Clone a live site and run on localhost
Hi good day!
I'm very new here, as well as in laravel. But i've finished Jeffrey's Laravel 5.4 from Scratch tutorial. I think laravel is very powerful, and i want to be good at it.
However, i want to clone a live site and run it on my local machine so that i won't be messing the live site. I know it's possible, but when i view the site in http://localhost/cloned-site/ html works, but it doesn't render the css file.
Any help would be greatly appreciated.
Best, Knt
To view the site, goto: http://localhost/cloned-site/public
OR
Run php artisan serve under root directory of laravel to check if the CSS being applied. if the CSS is working as expected (URL:http://localhost:8000). This means that you need to create the Apache Virtual Hosts for your website/project and add DocumentRoot path to the public directory of your project.
Hi @RamjithAp, thank you for your response.
The site was made by other devs, i'm just continuing it.
on app.blade.php here's the code for the css:
{{ Html::style(elixir('css/'.$app_type.'.css')) }}
It doesn't work, on view source, this is what i get:
http://localhost:8888/lrvl/cloned-site/build/css/style-e830721e3e.css"> where it should be http://localhost:8888/lrvl/cloned-site/public/build/css/style-e830721e3e.css">
So i manually changed it into: {!!Html::style('public/build/css/style-e830721e3e.css')!!} it works now. And i can see the site, but the images are still not showing, as well as the js.
I guess i have to manually add public/ to all urls? So is there a better way to handle it?
Thanks a lot.
Hi @Vijay, thank you for your help.
I'm using MAMP, should i still run php artisan serve?
I guess i have to manually add public/ to all urls? So is there a better way to handle it?
-- create apache virtual hosts for your website/project and add DocumentRoot path to the public directory of your project
@Vijay , thanks again.
I'm sorry but i don't know how to do that. Would you be kind to teach me?
Yes, you can run php artisan serve. it's in-built server provided by laravel but don't use that for development. For development, always create virtual hosts under apache
Follow this link: http://foundationphp.com/tutorials/vhosts_mamp.php for creating virtual hosts
@Vijay , awesome! Thank you very much. I'll get back to you for the progress.
Thanks again.
Make sure that DocumentRoot path should have a path to the public directory of your laravel project.
@Vijay, i get 404 - Not Found error
Here's my httpd-vhosts.conf code:
<VirtualHost *:80> DocumentRoot "/Users/knt/Documents/Sites/lrvl/cloned/public" ServerName cloned.local <Directory "/Users/knt/Documents/Sites/lrvl/cloned/public"> AllowOverride all
and on my hosts file, i got this: 127.0.0.1 localhost 127.0.0.1 cloned
Have you restarted your server?
Yes, i did. I still get 404 - Not found, but i noticed that the title of the page is Valet - Not Found.
Valet - Not Found
Maybe that would give a hint?
You're using Valet?
Refer this: https://laracasts.com/discuss/channels/general-discussion/valet-404-not-found?page=1
Assume you have valet installed but also apache?
Hello @Snapey,
Yeah, i have MAMP already setup, because i use wordpress.
Now that i'm learning laravel, i followed Jeffrey's tutorial at laracasts to install valet.
Is that wrong?
Not wrong but you cannot have two servers both running on port 80.
As you have been configuring apache vhosts, I assume you want to use mamp
You can use valet stop to stop it listening
I see, yeah, but MAMP apache port is set to 8888.
I tried to valet stop, and when i visit the site it gives an error:
This site can’t be reached
cloned.local refused to connect.
Here's my httpd-vhosts.conf file:
Virtual Hosts
If you want to maintain multiple domains/hostnames on your
machine you can setup VirtualHost containers for them. Most configurations
use only name-based virtual hosts so the server doesn't need to worry about
IP addresses. This is indicated by the asterisks in the directives below.
Please see the documentation at
<URL:http://httpd.apache.org/docs/2.2/vhosts/>
for further details before you try to setup virtual hosts.
You may use the command line option '-S' to verify your virtual host
configuration.
Use name-based virtual hosting.
NameVirtualHost *:8888
VirtualHost example:
Almost any Apache directive may go into a VirtualHost container.
The first VirtualHost section is used for all requests that do not
match a ServerName or ServerAlias in any block.
<VirtualHost *:8888> DocumentRoot "/Users/knt/Documents/Sites" ServerName localhost
<VirtualHost *:8888> DocumentRoot "/Users/knt/Documents/Sites/lrvl/cloned/public" ServerName cloned.local ServerAlias cloned.local <Directory "/Users/knt/Documents/Sites/lrvl/cloned/public"> DirectoryIndex index.php Options +Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted
Anything wrong with it?
So you are running this virtual host on port 8888
You need to add that to your URLs
(and if your post looks wrong, you can always go back and edit it)
yep
@Snapey , i tried to http://cloned.local:8888/ and i got a 500 internal Server Error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
No luck! Don't know what to do anymore.
ok, so that may actually be progress. You need to have various things in place. Check the installation instructions https://laravel.com/docs/5.5/installation
Did you copy the hidden files over (e.g. .env and .htaccess)
Did you edit the .env so that its not trying to access any production services such as mysql
Can MAMP write to the storage folder?
It might be easier to just get a blank install working first to prove you have the right environment.
Really sorry to bother you @Snapey , i'm very new to this, and this project was just handed over to me, please bear with me. Appreciate all your help.
For some reason i tried http://cloned.local:8888/ and the site works, but when i tried to click on login or any other links on the page, it gives 404.
Also, when i tried to visit phpmyadmin, it gives: #1045 - Access denied for user 'root'@'localhost' (using password: YES)
Did you copy the .htaccess file in /public folder
@Snapey , should i copy FROM /public folder, or FROM / going to /public?
@knt you login page is not working because of phpmyadmin not working
stop phpmyadmin service run->service_>findphpmyadmin(stop it) or you can restart your local server check you phpmyadmin port is used by any other services if yes stop it
When you cloned the site from production you may or may not have copied the hidden files such as .htaccess
I'm asking do you have a .htaccess file in /public ? if not then you are going to need one. probably from production public although it may not work depending on what web server is used on production
Also, and I cannot stress this enough.. You MUST change the .env file to use local resources otherwise you could be messing about with production data
Please or to participate in this conversation.