Laravel setup projects on personal web server

时间:2015-07-13 21:00:29

标签: php apache laravel

I have at home a personal web server running apache where I have a /var/www/{project_folder} to serve my websites, where I access them by the other machines by the IP/{project_folder}, nothing new for now. :)

I have some new projects done with laravel, but I only run them at my local machine to use the cli command to serve where it always runs at localhost:{door}

I would like to put that projects at my web server but I'm facing some difficulties because I only have some basic knowledge about apache and I'm having trouble to figure out the configuration.

I believe someone have already done that :)

Thanks in advance.

1 个答案:

答案 0 :(得分:1)

假设你已经有PHP使用Apache,那么你的httpd.conf文件是完全配置的,这样如果你有一个以.php结尾的文件将被正确处理。

您现在要做的就是将项目放在htdocs文件夹中,在该文件夹中您可以使用所有正常项目。就是这样。

您可以安装composer并使用它安装Laravel。例如通过

"composer create-project laravel/laravel --prefer-dist". 

See here

现在棘手的部分: 如果您想通过http://localhost/your-project而不是http://localhost/your-project/public访问该网站,请执行此操作(取决于您的操作系统):

  • 激活Mod_Alias
  • 转到'< IfModule alias_module>'

然后在里面加上这一行:

 Alias /your-project/ "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/your-project/public/"

在这种情况下,您不需要虚拟主机。

如果您还有其他问题,请与我们联系。