简体   繁体   English

AWS EC2 上的 Laravel 开发

[英]Laravel Develoyment on AWS EC2

I am trying to deploy laravel 5.1 project on AWS EC2 cloud server and having an issue with laravel web site route URLs.我正在尝试在 AWS EC2 云服务器上部署 laravel 5.1 项目,但遇到了 laravel 网站路由 URL 的问题。

I ran the following commands to configure the EC2 ubuntu 14.04 LTS server.我运行以下命令来配置 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

getting the following error when I try access any route URLs but my home page is loading correctly.当我尝试访问任何路由 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>

I have changed the apache route URL to the public folder of my laravel project without any success.我已将 apache 路由 URL 更改为我的 laravel 项目的公共文件夹,但没有成功。 Also I tried to enable the following virtual host file but still got the same error.我也尝试启用以下虚拟主机文件,但仍然出现相同的错误。

<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>

I ran the following command to grant permission to the storage folder我运行以下命令来授予存储文件夹的权限

 chmod -R 777 storage

do I need to grant any permission to my laravel project folder?我需要为我的 Laravel 项目文件夹授予任何权限吗?

appreciate any help.感谢任何帮助。

This is my configuration for Laravel 5.1 on Ubuntu 14.04这是我在 Ubuntu 14.04 上对 Laravel 5.1 的配置

You might need to enable your rewrite engine您可能需要启用重写引擎

sudo a2enmod rewrite

If that doesn't work you can change the virtualhost configuration to something like this如果这不起作用,您可以将虚拟主机配置更改为这样的

<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>

Additionally add the ServerName to /etc/hosts另外将 ServerName 添加到/etc/hosts

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM