gpt4 book ai didi

php - AWS EC2 上的 Laravel 开发

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:44:02 28 4
gpt4 key购买 nike

我正在尝试在 AWS EC2 云服务器上部署 laravel 5.1 项目,但遇到 laravel 网站路由 URL 问题。

我运行了以下命令来配置 EC2 ubuntu 14.04 LTS 服务器。

sudo apt-get install apache2
sudo apt-get install mysql-server php5-mysql
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
sudo apt-get install php5 php-pear
sudo apt-get install curl php5-curl php5-cli git
sudo a2enmod rewrite
sudo php5enmod mcrypt
sudo service apache2 restart

当我尝试访问任何路由 URL 但我的主页正确加载时出现以下错误。

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /register was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at xxxx.ap-southeast-2.compute.amazonaws.com Port 80
</address>
</body></html>

我已将 apache 路由 URL 更改为我的 laravel 项目的公共(public)文件夹,但没有成功。我也尝试启用以下虚拟主机文件,但仍然出现相同的错误。

<VirtualHost *:80>  
ServerAdmin webmaster@mynewhost.com
DocumentRoot /var/www/html/mynewhost/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我运行了以下命令来授予对存储文件夹的权限

 chmod -R 777 storage

我需要为我的 laravel 项目文件夹授予任何权限吗?

感谢任何帮助。

最佳答案

这是我在 Ubuntu 14.04 上的 Laravel 5.1 配置

您可能需要启用重写引擎

sudo a2enmod rewrite

如果这不起作用,您可以将虚拟主机配置更改为类似这样的内容

<VirtualHost *:80>

ServerName laravel.example.com
DocumentRoot /var/www/html/mynewhost/public

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/mynewhost/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

另外将 ServerName 添加到 /etc/hosts

<your-server-ip-address> laravel.example.com

关于php - AWS EC2 上的 Laravel 开发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33450843/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com