I'm following the official Laravel course (currently the first chapter "Meet Composer,"), but I can't seem to get it right. In the course I was instructed to enter in the command line:
php -S localhost:8888 -t public
and I should be able to reach the URL: "http://localhost:8888/learning-laravel-5", but this gives me a 404 error.
But if I put in this URL I get to see the frontpage, as it should: http://localhost:8080/learning-laravel-5/public/index.php
My question is, how can I see the frontpage as instructed in the video, following the provided URL: http://localhost:8888/learning-laravel-5 ?
I have looked through the duplicate questions on stackoverflow but I can't find a solution to this problem.
Edit: I have tried to get my absolute path by doing pwd, its says "/media/sf_sandbox/laracast-4.2", I now have done this: "php -S localhost:8888 -t /media/sf_sandbox/laracast-4.2/public". I now go to localhost:8888 but it still doesn't work.
It says my documentroot is /media/sf_sandbox/learning-laravel-5/public
If you are running below command from the project root learning-laravel-5 , than localhost:8888
it self points to the learning-laravel-5/public folder
php -S localhost:8888 -t /var/www/html/learning-laravel-5/public
In this case only localhost:8888 should work and you don't need to append learning-laravel-5 after that.
It seems like you are using XAMP..because
For XAMP, localhost port is 8000 And
For XAMP, localhost port is 8000.
in the laravel directory, where you ran composer, type php artisan serve. This will run an internal webserver, which opens up 8000 port by default. Once you have that, open your browser and access http://localhost:8000
If that works, you have an issue with your MAMP configuration.
If it is MAMP, check the following
1) make sure you set the document root to the /public directory in your laravel installation.
2
make sure you have enabled rewrite module in your mamp.
Checkout How to get htaccess to work on MAMP
Related
I have created small blog application in laravel 5.2 .the app works whenever i run it using php artisan serve.
But without running artisan serve , when i access it from public folder for e.g. localhost/blog/public/addBlog it gives error page not found.
My routes.php has following lines
Route::get('addBlog','BlogsController');
It works fine with php artisan serve with visiting http://localhost:8000/addBlog
The solution is pretty simple. Laravel expects your public folder to be the root of the webserver / url / domain.
Using the serve command works since localhost:8000 is the root then.
Using the longer url doesn't work since your root is localhost/blog not localhost.
A fairly simple solution is to create a virtualhost, to explain how you can do this we would need to know what is running on your localhost (xampp? wamp?)
Nevertheless, the solution would be a virtualhost pointing to localhost/blog/public
Update
example for wamp virtual hosts
C:\Windows\System32\drivers\etc\hosts => open as admin and add
127.0.0.1 blog.dev
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerName blog.dev
DocumentRoot "C:\wamp\www\blog\public"
ServerAlias blog.dev
</VirtualHost>
It's basically the same for xampp, but the path to the vhosts conf is different
Don't forget to restart wamp/xampp after doing the changes. Then simply open http://blog.dev via browser and enjoy
Laravel expects the folder to be in the root of the application so set-up a virtual host and update your hosts file to match.
Use following command
sudo a2enmod rewrite
I had tried in to the ubuntu but i am not sure that will run in another os or not
although the path /mnt/my-proj/app/../var/sessions/dev is accessible for both the normal user and www-data I get the following message:
Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/mnt/op-accounting2/app/../var/sessions/dev)
I get the message above only in dev, but not in prod.
/mnt/my-proj/app/../var/sessions/dev and /mnt/my-proj/app/../var/sessions/prod have the same pemissions: 777.
The path above is mounted as following:
# mount -t vboxsf -o uid=1000,gid=33,umask=000 my-proj /mnt/my-proj;
What am I doing wrong?
I've read the following posts, but could find no solution for me:
PHP session handling errors
https://github.com/NewEraCracker/suhosin-patches/issues/3
PHP7 + Symfony 2.8, Failed to write session data
I'm using Vagrant 1.8.1 on Windows 8.1 Enterprice (64Bit) and ubuntu-xenial 16.04 in Vagrant. The provider is VirtualBox 5.0.20. The settings are mostly default ones. The path above is shared using VirtualBox GUI with full access.
Kind regards,
Juri
SOLVED! :-)
Setting
save_path: "/var/lib/php/sessions"
in /mnt/my-proj/app/config/config.yml solved the problem. Any adjusting of ini-Files in /etc/php/7.0/ wasn't neccessary (those files have still default values only).
But I wander why didn't I get that error message in prod?
You can just edit the configured file.
vi /etc/php/7.2/fpm/pool.d/www.conf
Then change the owner role for PHP from www-data to vagrant
user = vagrant
group = vagrant
In addition to the previous answer from Juri Sinitson, it also solved me tweaking the VM instead of tweaking the project base.
Adding to my Vagrant bash root provisioner this line:
sed -i "s/www-data/vagrant/g" /etc/apache2/envvars
service apache2 restart
Makes the apache run as vagrant. This confers apache more power on the shared directory as it appears to the filesystem that it is the user vagrant and not the user www-data who happens to be touching there.
Maybe this is 'apparmor' related or so.
I cannot load the webpage of my laravel when I try to put in my URL localhost:8000. It gives me the following error :
Failed to load resource: net::ERR_EMPTY_RESPONSE
GET http://localhost:8000/ net::ERR_EMPTY_RESPONS
The last time I used laravel, it worked fine but now when I load it to browser, it doesn't work anymore. Screenshot below.
you need to remove chrome extensions and then try again and see if it works.
Try the command, php -S 0.0.0.0:80 -t ~. Make sure you are Superuser, so if you're on UNIX, type sudo before the command. php -S runs a server on 0.0.0.0:80. 0.0.0.0 means to run the server on localhost on all interfaces on port 80. Port 80 is the default web port that is accessed by web browsers. -t ~ means to use the directory ~ for hosting. You could actually replace ~ with any directory with an index.php in it.
I recently installed WAMP on Windows and have set up a local MediaWiki installation. After the installation, I tried to to install a new extension. For it to work, I have to run the maintenance script update.php. However, when I go to localhost/maintenance/update.php, I'm getting a 403 error.
Forbidden
You don't have permission to access /maintenance/update.php on this server.
Apache/2.4.9 (Win32) PHP/5.5.12 Server at 127.0.0.1 Port 80
How do I fix this? or is there another way to run the maintenance scripts on WAMP (perhaps with a command line)?
This is not an error, it is desired behaviour for the program, since the .htaccess file for the /maintenance/ directory has this:
Deny from all
This is because the update.php file is not meant to be loaded directly from a web browser. You must read the documentation for MediaWiki updating from a browser to utilize it correctly. You can also run it from the command line
I have created a fresh Laravel application by using composer create-project command. Then I put all the folders and files in /usr/share/nginx/html/, which is the default document root for my nginx server. However everytime I runs the http://localhost, it keeps displaying 403 Forbiden. I tried creating a testing index.php (<? php_info();) and it worked fine.
I've read somewhere that I need to set the containing folder (/html), as well as the app/storage folder permission to 777 but still no luck.
Please help me. Thank you in advance.
Here is the nginx default.conf
Laravel projects serve from the <projectName>/public directory. Make sure your nginx config is set up to look there for your index file and NOT in your <projectName> folder only.
Would you edit your question and paste your server config there?
I think it may because index.php is not in the index file list. check these lines:
index index.html index.php;
or
try_files $uri $uri/ =404;
The accepted answer is correct - Laravel services from the public folder and you need to tell nginx to look there - but also a little vague if you're bumping up against this problem. When you create new sites on a Homestead installation by adding them to your .yaml file and using vagrant provision or vagrant up --provision, the created nginx conf file will need editing before Laravel will serve files correctly.
Go to your CLI, and enter Homestead using vagrant ssh or homestead ssh. It will ask for your password, which by default is "vagrant".
Once you're in the virtual machine, type the following commands:
sudo nano /etc/nginx/sites-enabled/your-site-name-here
Then add /public to the end of the existing root near the top of the file (it'll be something like /home/vagrant/projects/your-site to begin with and save in Nano (ctrl+s), then exit nano (ctrl+x).
Once you've exited Nano, restart nginx using sudo nginx -s reload. Your routing will now work!