在 MAMP 上安装 Laravel
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18639720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing Laravel on MAMP
提问by Lance
I downloaded the latest version of Laravelfrom Github, unzipped it, and then placed it inside of the htdocs folder in MAMP. MAMP is running PHP version 5.4.10 and therefore fulfills Laravel's requirement of PHP >= 5.3.7. I tried using the terminal to install composer by entering:
我从 Github下载了最新版本的 Laravel,解压后将其放入 MAMP 的 htdocs 文件夹中。MAMP 运行 PHP 5.4.10 版,因此满足 Laravel 对 PHP >= 5.3.7 的要求。我尝试使用终端通过输入以下内容来安装 Composer:
curl -sS https://getcomposer.org/installer | php
And was greeted with an error reading:
并收到一个错误读数:
#!/usr/bin/env php
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The detect_unicode setting must be disabled.
Add the following to the end of your `php.ini`:
detect_unicode = Off
A php.ini file does not exist. You will have to create one.
If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.
When I try to load
当我尝试加载时
http://localhost:8888/laravel/public/
in my browser, the PHP error log shows
在我的浏览器中,PHP 错误日志显示
05-Sep-2013 16:57:03 Europe/Berlin] PHP Fatal error: require(): Failed opening required '/Applications/MAMP/htdocs/laravel/bootstrap/../vendor/autoload.php' (include_path='.:/Applications/MAMP/bin/php/php5.4.10/lib/php') in /Applications/MAMP/htdocs/laravel/bootstrap/autoload.php on line 17
I have a feeling that this error has a fairly simple solution, but as I'm very new to Laravel I need to be pointed in the right direction in regards to solving this.
我有一种感觉,这个错误有一个相当简单的解决方案,但由于我对 Laravel 很陌生,我需要指出解决这个问题的正确方向。
Thanks.
谢谢。
回答by ciruvan
You need to get Composer up and running before you can install Laravel 4. That step failed here.
在安装 Laravel 4 之前,您需要启动并运行 Composer。这一步在这里失败了。
Try running this command instead:
尝试运行此命令:
$ curl -sS getcomposer.org/installer | php -d detect_unicode=Off
It will circumvent the problem so you can get on with installing Laravel 4.
它将绕过这个问题,因此您可以继续安装 Laravel 4。
EDIT:
编辑:
For a global installation of Composer, do this afterwards:
对于 Composer 的全局安装,请在之后执行以下操作:
$ sudo mv composer.phar /usr/local/bin/composer.phar
$ alias composer='/usr/local/bin/composer.phar'
Then, in your directory where you would like to put Laravel 4 into,
然后,在您要将 Laravel 4 放入的目录中,
$ php composer create-project laravel/laravel --prefer-dist
回答by kofi
I had the same problem, your system is not using MAMP
's PHP
but instead uses the php
that comes with your mac.
我遇到了同样的问题,您的系统没有使用MAMP
'sPHP
而是使用php
您的 mac 附带的 s 。
I made notes on how I installed laravel
when MAMP
is already installed. I hope you and others find it helpful.
我在已经安装laravel
时记录了我如何MAMP
安装。我希望你和其他人觉得它有帮助。
a.add MAMP
's PHP
to PATH VARIABLE
in .bash_profile
一种。添加MAMP
的PHP
对PATH VARIABLE
中.bash_profile
export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH
b.install Composer
-go to http://www.getcomposer.org/->getting started ->globally copy and execute the following commands at the terminal…
湾 安装-Composer
转到http://www.getcomposer.org/-> 入门 -> 全局复制并在终端执行以下命令...
cd ~
curl -sS https:/?getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
c.install Laravel
in MAMP/htdocs
folder using composer
,
at the terminal…
C。使用, 在终端安装Laravel
在MAMP/htdocs
文件夹中composer
...
cd /Applications/MAMP/htdocs
composer create-project laravel/laravel neji --prefer-dist
**where neji is the name of your website/project
**其中 neji 是您的网站/项目的名称
d.edit /private/etc/hosts
d. 编辑 /private/etc/hosts
sudo nano /private/etc/hosts
add 127.0.0.1 neji
at the buttom of the file. save and exit
添加127.0.0.1 neji
在文件的底部。保存并退出
e.using any textEditor edit /Applications/MAMP/conf/apache/httpd.conf
uncomment by removing the #
before include… on the virtual hosts, see below where...
e. 使用任何 textEditor/Applications/MAMP/conf/apache/httpd.conf
通过删除#
虚拟主机上的 before include... 来编辑取消注释,请参见下面的...
# Virtual Hosts
#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
becomes...
变成……
# Virtual Hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
f.using any textEditor edit /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
add the following text at the bottom
F。使用任何 textEditor 编辑/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
在底部添加以下文本
# I am not sure about this since DocumentRoot does not points to the public folder
# but I still added it and it's working, maybe someone will clarify this part
<VirtualHost *:80>
ServerAdmin localhost
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
ServerAlias www.localhost
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
# this one, I think is the code that makes it work bec the DocumentRoot points to public folder
<VirtualHost *:80>
ServerAdmin neji.dev
DocumentRoot "/Applications/MAMP/htdocs/neji/public/"
ServerName neji.dev
ServerAlias www.neji
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
** 2 things to note
** 2 件事要注意
1st, set ServerName to your projectName(neji.dev)
1、将 ServerName 设置为您的 projectName(neji.dev)
2nd, set DocumentRoot to the public folder
2、将 DocumentRoot 设置为公用文件夹
g.open your project using your fav browser
G。使用您最喜欢的浏览器打开您的项目
neji.dev/
**don't forget the /
at the end
**不要忘记/
最后
You should see the laravel
welcome page.
您应该会看到laravel
欢迎页面。
Then after a few days switch to VM
:)
然后几天后切换到VM
:)
回答by kofi
Sounds like you're missing the dependencies.
听起来您缺少依赖项。
The installation documentationis pretty clear:
安装文档很清楚:
Once Composer is installed, download the latest version of the Laravel framework and extract its contents into a directory on your server. Next, in the root of your Laravel application, run the
php composer.phar install
(or composer install) command to install all of the framework's dependencies. This process requires Git to be installed on the server to successfully complete the installation.
安装 Composer 后,下载最新版本的 Laravel 框架并将其内容解压缩到服务器上的目录中。接下来,在 Laravel 应用程序的根目录中,运行
php composer.phar install
(或 composer install)命令来安装框架的所有依赖项。此过程需要在服务器上安装 Git 才能成功完成安装。
You've already downloaded and and unzipped the Laravel files into your htdocs
folder, so now just run:
您已经将 Laravel 文件下载并解压缩到您的htdocs
文件夹中,所以现在只需运行:
php composer.phar install
in your terminal to install the dependencies.
在您的终端中安装依赖项。
That should fix the issue.
那应该可以解决问题。
And when you want to update Laravel, just run:
当你想更新 Laravel 时,只需运行:
php composer.phar update
Hope this helps!
希望这可以帮助!
回答by dcz.switcher
The problem is that when you "install" MAMP, the php command in terminal not use the PHP of MAMP but the default mac os one
问题是当你“安装”MAMP时,终端中的php命令没有使用MAMP的PHP而是默认的mac os one
Just type in terminal : which php it return : /usr/bin/php
只需输入终端:它返回哪个 php:/usr/bin/php
For install Laravel without extra params, just update your .bash_profile file to use the PHP of MAMP
要在没有额外参数的情况下安装 Laravel,只需更新您的 .bash_profile 文件以使用 MAMP 的 PHP
I wrote a doc (in french) here :
我在这里写了一个文档(法语):
https://docs.google.com/document/d/1eXaL8mAv7bGQ_xq_f6sO5jf23X7APuRwCDAexHN52mY/edit
https://docs.google.com/document/d/1eXaL8mAv7bGQ_xq_f6sO5jf23X7APuRwCDAexHN52mY/edit
regards
问候
回答by Philip Rowland
In addition to determining which version of php you're using:which php
and editing the path in .bash_profile (as others have already explained very well), be sure to check if php still exists in /usr/binls /usr/bin/php
and if so, then disable it by renaming it to something like php.bakcd /usr/bin
sudo mv php php.bak
In my case I had done all the resetting of the path variable in .bash_profile plus checking the permissions plus following up on a bunch of debates about other ways of configuring the path variable etc, but after all that my problems were solved by disabling the old php in /usr/bin altogether.
除了确定您使用的是哪个版本的 php:which php
并编辑 .bash_profile 中的路径(其他人已经解释得很好),请务必检查 /usr/bin 中ls /usr/bin/php
是否仍然存在 php,如果存在,则禁用它通过将其重命名为 php.bak 之类的东西cd /usr/bin
sudo mv php php.bak
在我的情况下,我已经完成了 .bash_profile 中路径变量的所有重置,并检查了权限,并跟进了有关配置路径变量等其他方式的一系列辩论,但毕竟通过完全禁用 /usr/bin 中的旧 php 解决了我的问题。