如何在不使用 php artisan serve 的情况下在本地主机上运行 laravel 5.0 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31046999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run laravel 5.0 project on localhost without use php artisan serve
提问by Ravi
I have created a laravel 5.0 project with php artisan serve, now i need to know how to run laravel 5.0 project run without start php artisan serve, i have already browse lot of websites no one help me..
我已经用 php artisan serve 创建了一个 laravel 5.0 项目,现在我需要知道如何在不启动 php artisan serve 的情况下运行 laravel 5.0 项目,我已经浏览了很多网站没有人帮我..
回答by Ricardo Vigatti
You need to change "server.php" to "index.php" then copy ".htaccess" from public to root directory.
您需要将“server.php”更改为“index.php”,然后将“.htaccess”从公共目录复制到根目录。
回答by Gautam Patadiya
Laravel sever Folder is "public". There is an index.php so you can run you project from there.
Laravel 服务器文件夹是“公开的”。有一个 index.php,所以你可以从那里运行你的项目。
Suppose if you using UbuntuOS then you have to create your local server in public directory. Suppose your folder name is laravel_test then go in that directory and run some thing like this
假设您使用 UbuntuOS,那么您必须在公共目录中创建本地服务器。假设您的文件夹名称是 laravel_test 然后进入该目录并运行类似这样的事情
php -S localhost:8000 -t public
If you using windows then access public folder from URL.
如果您使用 Windows,则从 URL 访问公共文件夹。
localhost/laravel/public
Actually it's bad practise to access folder from URL but for local its good. You also can go with host entry. Just make sure that your target folder is "public" directory.
实际上,从 URL 访问文件夹是不好的做法,但对于本地来说它是好的。您也可以使用主机条目。只需确保您的目标文件夹是“public”目录。
回答by pinkal vansia
Normally you would have WAMP/XAMPP installed. You can access Laravel project like below
通常你会安装 WAMP/XAMPP。您可以像下面一样访问 Laravel 项目
localhost/laravel/public
But this is not recommended. You should create Virtual host for example
laravel.local
that pints to server-root/laravel/public
.
thisis how you create virtual host.
但不建议这样做。您应该创建虚拟主机,例如
laravel.local
品脱到server-root/laravel/public
.
这就是您创建虚拟主机的方式。
Or even better go for a Laravel Homestead.
或者甚至更好地去 Laravel Homestead。
回答by Angherq
How is your .htaccess
file configured?
你的.htaccess
文件是怎么配置的?
Try with localhost/laravel/public/index.php
试试 localhost/laravel/public/index.php
回答by Renish Gotecha
- Use http://localhost/projectName/public
It will be work. but in case if you have another Route and you can not access that Route and get the error like " Page Not Found " then please use the following command
sudo a2enmod rewrite
Now open the http://localhost/projectName/public/yourRoute
- 使用http://localhost/projectName/public
这将是工作。但是,如果您有另一条路线并且无法访问该路线并出现“找不到页面”之类的错误,请使用以下命令
sudo a2enmod rewrite
回答by Artur Poniedzia?ek
If you have access to xampp or wampp on your operating system you can more or less configure your virtual host like in the instruction below:
如果您可以在操作系统上访问 xampp 或 wampp,您可以或多或少地配置您的虚拟主机,如下面的说明:
https://bestin-it.com/creating-virtualhost-on-your-local-computer-to-start-simple-index-php/
https://bestin-it.com/creating-virtualhost-on-your-local-computer-to-start-simple-index-php/
This instruction shows how to run it locally on your PC, but it works generally the same on any hosting portals. In most case in payed portals you have any web panels to configure your public folder that reference to /public folder in laravel folder's structure.
此说明显示了如何在您的 PC 上本地运行它,但它在任何托管门户上的工作方式通常都相同。在大多数情况下,在付费门户中,您有任何 Web 面板来配置您的公用文件夹,这些文件夹在 laravel 文件夹结构中引用 /public 文件夹。
回答by Robert Pounder
This is a little late but still applicable, what I like to do (using ubuntu 14.x+) is put my laravel project (let's say Project1
) in my var directory, so it would be in /var/Project1
, then symlink the public folder to somewhere in /var/www
(+/html
depending on apache version).
这有点晚了,但仍然适用,我喜欢做的(使用 ubuntu 14.x+)是将我的 laravel 项目(假设Project1
)放在我的 var 目录中,所以它会在/var/Project1
,然后将公共文件夹符号链接到/var/www
( +/html
取决于 apache 版本)。
Symlink can be done something like this:
符号链接可以这样做:
ln -s /var/Project1/public /var/www/html
ln -s /var/Project1/public /var/www/html
This keeps your internal files off the grid so to speak, this is untested so if I've missed anything just comment and I will amend this post.
这可以让你的内部文件远离网格,可以这么说,这是未经测试的,所以如果我错过了任何评论,我会修改这篇文章。
EDIT:
编辑:
Obviously if your http root is /var/www/html
you can put your project in /var/www/Project1
显然,如果您的 http 根是/var/www/html
您可以将您的项目放入/var/www/Project1