问题描述
大家好,我已经搜索了四个多小时,但是当我在本地主机上时,我仍然找不到我真正需要的东西,我习惯用php artisan在我的命令行中输入消息显示了在 http://localhost:8890/上启动的Laravel开发服务器,因此现在我正尝试使用ssh进行操作同样的事情,但令我惊讶的是,它总是显示相同的消息,就像我在本地主机上一样("Laravel开发服务器在 http://localhost:8890/).我期待的是
Hi everyone I've been googling for more than 4 hours now ,but i still don't find what I really need,when i am on my localhost i am used on typing php artisan serve ON MY COMMAND LINE and the message Laravel development server started on http://localhost:8890/ is shown ,so now I am trying to use ssh to do the same thing but from my surprise it always show the same message like when i am on my localhost("Laravel development server started on http://localhost:8890/").I was expecting something like
Laravel development server started on http://myElasticIp:8890/
但是不行.欢迎其他任何人也可以使用其他方法来解决此问题,谢谢.
but it doesn't .Anyone who also have alternative methods to solve this problem is welcomed .Thank you in advance.
我的.htaccess文件
MY .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /laravel/public/
# change above to your site i.e., RewriteBase /whatever/public/
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我的虚拟主机
<VirtualHost *:80>
DocumentRoot "/var/www/html/"
<Directory "/var/www/html/kidio/mergeogle/laravel/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
Allow from all
</Directory>
</VirtualHost>
推荐答案
sudo php artisan serve --host 0.0.0.0 --port 80
将解决问题,但您从不请勿使用php artisan serve
进行生产.适当的网络服务器(如nginx/Apache)对于生产用途是必需的-Laravel文档具有这两个服务器的配置示例.
sudo php artisan serve --host 0.0.0.0 --port 80
will do the trick, but you should never use php artisan serve
for production. A proper webserver like nginx/Apache is necessary for production use - the Laravel docs have configuration examples for both.
这篇关于我们如何在EC2上运行PHP Artisan服务以指向弹性IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!