2015-10-31 111 views
4

我试图在AWS EC2云服务器上部署laravel 5.1项目,并且遇到laravel网站路由URL的问题。Laravel在AWS EC2上的部署

我运行了以下命令来配置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 

得到以下错误,当我尝试访问任何途径网址,但我的主页加载正确。

<!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项目的公用文件夹,但没有任何成功。此外,我试图启用以下虚拟主机文件,但仍然有相同的错误。

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    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项目文件夹?

感谢任何帮助。

+0

您是否启用了重写模块?尝试sudo a2enmod重写并重新启动你的apache – JLPuro

+0

@JPPuro是的,我做到了。我会更新我的问题。 – WPS2

+0

它将加载/var/www/html/mynewhost/resources/views/auth/login.blade.php模板作为主页。所以我认为Route :: get('/','Auth \ AuthController @ getLogin')路线正在工作。 – WPS2

回答

1

这是在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> 

此外,该服务器名称添加到/etc/hosts

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

在这里,您已将ubuntu服务器的Web根目录更改为laravel网站的公用文件夹。你如何在这个配置的同一台服务器上托管2个laravel网站? – WPS2

+0

你可以尝试将'DocumentRoot'设置为'/ var/www/html /'我认为它仍然可以工作。 – Saad