如何在 Laravel Homestead 盒子上设置 phpMyAdmin?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23788096/
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
How do I set up phpMyAdmin on a Laravel Homestead box?
提问by Nikos Grigoriadis
I installed it by running sudo apt-get install phpymyadmin
and then running
我通过运行sudo apt-get install phpymyadmin
然后运行来安装它
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html
and sudo service nginx restart
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html
和 sudo service nginx restart
but it's not working.
但它不起作用。
Note: I didn't select any of the apache2 or lighttpd options when installing.
注意:安装时我没有选择任何 apache2 或 lighttpd 选项。
回答by Nikos Grigoriadis
Option 1:
选项1:
This will install the latest version of PhpMyAdmin from a shell script I've written. You are welcome to check it out on Github.
这将从我编写的 shell 脚本安装最新版本的 PhpMyAdmin。欢迎您在 Github 上查看。
Run the following command from your code/projects directory:
curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | sh
从您的代码/项目目录运行以下命令:
curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | sh
Option 2:
选项 2:
This will install PhpMyAdmin (not the latest version) from Ubuntu's repositories. Assuming that your projects live in /home/vagrant/Code
:
这将从 Ubuntu 的存储库安装 PhpMyAdmin(不是最新版本)。假设您的项目位于/home/vagrant/Code
:
sudo apt-get install phpmyadmin
Do notselect apache2 nor lighttpd when prompted. Just hit tab and enter.sudo ln -s /usr/share/phpmyadmin/ /home/vagrant/code/phpmyadmin
cd ~/Code && serve phpmyadmin.test /home/vagrant/code/phpmyadmin
sudo apt-get install phpmyadmin
难道不是提示时选择的Apache2也不lighttpd的。只需点击选项卡并输入。sudo ln -s /usr/share/phpmyadmin/ /home/vagrant/code/phpmyadmin
cd ~/Code && serve phpmyadmin.test /home/vagrant/code/phpmyadmin
Note: If you encounter issues creating the symbolic link on step 2, try the first option or see Lyndon Watkins' answer below.
注意:如果您在第 2 步创建符号链接时遇到问题,请尝试第一个选项或查看下面 Lyndon Watkins 的回答。
Final steps:
最后步骤:
Open the
/etc/hosts
file on your main machine and add:127.0.0.1 phpmyadmin.test
/etc/hosts
在主机上打开文件并添加:127.0.0.1 phpmyadmin.test
回答by Jeff
Step 1:
第1步:
Go to the phpMyAdminwebsite, download the latest version and unzip it into your code directory
进入phpMyAdmin网站,下载最新版本并解压到你的代码目录
Step 2:
第2步:
Open up homestead.yaml
file and add these lines
打开homestead.yaml
文件并添加这些行
folders:
- map: /Users/{yourName}/Code/phpMyAdmin
to: /home/vagrant/Code/phpMyAdmin
sites:
- map: phpmyadmin.test
to: /home/vagrant/Code/phpMyAdmin
Step 3:
第 3 步:
Open your hosts file and add this line:
打开您的主机文件并添加以下行:
127.0.0.1 phpmyadmin.test
Step 4:
第四步:
You may need to run vagrant provision
to load the new configuration if vagrant is already running.
vagrant provision
如果 vagrant 已经在运行,你可能需要运行来加载新配置。
Thats it
就是这样
Go to http://phpmyadmin.test:8000. It should work from there. Great thing about this method is that if you ever need to destroy your box, you won't ever have to set up phpMyAdmin again so long as you keep your homestead.yaml file and phpMyAdmin in your code directory.
转到http://phpmyadmin.test:8000。它应该从那里工作。这种方法的好处在于,如果您需要销毁您的盒子,只要您将 homestead.yaml 文件和 phpMyAdmin 保留在您的代码目录中,您就不必再次设置 phpMyAdmin。
===========
============
Important update from DaneSoul:
DaneSoul 的重要更新:
I tried this instruction on Homestead 5.3 and have met a problem "No input file specified" when trying open http://phpmyadmin.test.
我在 Homestead 5.3 上尝试了此指令,但在尝试打开http://phpmyadmin.test时遇到了“未指定输入文件”的问题。
And finnaly I found solution:
最后我找到了解决方案:
You need unpack phpmyadmin to
你需要解压 phpmyadmin
/home/vagrant/Code/phpMyAdmin/public
And write in homestead.yaml
并写入 homestead.yaml
- map: phpmyadmin.test
to: /home/vagrant/Code/phpMyAdmin/public
So almost all the same, but this /public
directory in paths makes it working!
所以几乎都是一样的,但是/public
路径中的这个目录使它工作!
Also, in my configuration I use http://phpmyadmin.test, not http://phpmyadmin.test:8000.
另外,在我的配置中,我使用http://phpmyadmin.test,而不是 http://phpmyadmin.test:8000。
Update Note: Follow this articleto change your domain extension.
更新说明:按照本文更改您的域扩展名。
回答by Lyndon Watkins
The answer from Nikos Gr worked for me; however I needed to amend steps 2 and 3 as my host system has issues creating the symlink.
Nikos Gr 的回答对我有用;但是我需要修改第 2 步和第 3 步,因为我的主机系统在创建符号链接时出现问题。
I changed:
我变了:
sudo ln -s /usr/share/phpmyadmin/ /home/vagrant/Code/phpmyadmin
cd ~/Code && serve phpmyadmin.app /home/vagrant/Code/phpmyadmin
To:
到:
cd ~/Code && serve phpmyadmin.app /usr/share/phpmyadmin/
(Couldn't comment on the original solution as my rep isn't high enough!)
(无法评论原始解决方案,因为我的代表不够高!)
回答by asmmahmud
A simplified version of Jyeon's Answer. You don't need to share the ~/Code folder in the Homestead.yaml file:
Jyeon's Answer 的简化版本。您不需要共享 Homestead.yaml 文件中的 ~/Code 文件夹:
folders:
- map: /Users/{yourName}/Code/phpMyAdmin
to: /home/vagrant/Code/phpMyAdmin
Just download the latest version of PhpMyAdmin from PhpMyAdminand put the unzipped file in the ~/Code/phpMyAdmin
folder and just follow the 2 step here:
只需从PhpMyAdmin下载最新版本的 PhpMyAdmin并将解压缩的文件放在~/Code/phpMyAdmin
文件夹中,然后按照此处的 2 步骤操作:
Step 1:
Open up homestead.yaml
file and add these lines
第 1 步:打开homestead.yaml
文件并添加这些行
sites: - map: phpmyadmin.app to: /home/vagrant/Code/phpMyAdmin
站点: - 映射:phpmyadmin.app 到:/home/vagrant/Code/phpMyAdmin
Step 3: Open up your hosts file and add this line:
第 3 步:打开您的主机文件并添加以下行:
192.168.10.10 phpmyadmin.app
192.168.10.10 phpmyadmin.app
Now run the vagrant reload --provision command and you're good to go.
现在运行 vagrant reload --provision 命令,你就可以开始了。
Open up the phpmyadmin.app address in your browser and you'll see the phpmyadmin interface.
在浏览器中打开 phpmyadmin.app 地址,你会看到 phpmyadmin 界面。
回答by Laurence
Install phpMyAdmin
安装 phpMyAdmin
SSH into Homestead vagrant box with vagrant ssh and type the following command:
sudo apt-get install phpmyadmin
When prompted to select the Web server, select
apache2
and press Enter, just to get pass it.When prompted to config database for phpmyadmin with dbconfig-common, select
Yes
and press Enter.When prompted for Password of the database's administrative user, enter
secret
and press Enter.When prompted for MySQL application password for phpmyadmin, enter
secret
and press Enter.When prompted for Password confirmation, enter
secret
again and press Enter.
使用 vagrant ssh SSH 进入 Homestead vagrant box 并输入以下命令:
sudo apt-get install phpmyadmin
当提示选择 Web 服务器时,选择
apache2
并按 Enter,只是为了通过它。当提示使用 dbconfig-common 为 phpmyadmin 配置数据库时,选择
Yes
并按 Enter。当提示输入数据库管理用户的密码时,输入
secret
并按 Enter。当提示输入 phpmyadmin 的 MySQL 应用程序密码时,输入
secret
并按 Enter。当提示输入密码确认时,
secret
再次输入并按 Enter。
Then Create and config site for Nginx
然后为 Nginx 创建和配置站点
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html/phpmyadmin
cd /etc/nginx/sites-available
sudo cp homestead.app phpmyadmin.app
sudo sed -i 's/homestead.app/phpmyadmin.app/g' /etc/nginx/sites-available/phpmyadmin.app
sudo sed -i 's/home\/vagrant\/Code\/Laravel\/public/usr\/share\/nginx\/html\/phpmyadmin/g' /etc/nginx/sites-available/phpmyadmin.app
sudo ln -s /etc/nginx/sites-available/phpmyadmin.app /etc/nginx/sites-enabled/phpmyadmin.app
sudo service nginx restart
sudo service php5-fpm retart
Adding phpMyAdmin.app to your hosts file
将 phpMyAdmin.app 添加到您的主机文件
127.0.0.1 phpmyadmin.app
Navigate to http://phpmyadmin.app:8000and you should now see phpMyAdmin login page.
导航到http://phpmyadmin.app:8000,您现在应该会看到 phpMyAdmin 登录页面。
回答by Nick F
A variation on Nikos Gr's answerthat seemed a bit simpler (in that it doesn't require a new symbolic link for each project on your Homestead box) and worked for me.
Nikos Gr答案的一个变体似乎更简单(因为它不需要为 Homestead 盒子上的每个项目提供一个新的符号链接)并且对我有用。
- Inside the Homestead box, run
sudo apt-get install phpmyadmin
. Don't select any of the options during install. On your host machine, add the following lines to your
Homestead.yaml
file:- map: phpmyadmin.dev to: /usr/share/phpmyadmin
On your host machine, add the following line to your
hosts
file:192.168.10.10 phpmyadmin.dev
- 在 Homestead 框中,运行
sudo apt-get install phpmyadmin
. 在安装过程中不要选择任何选项。 在您的主机上,将以下行添加到您的
Homestead.yaml
文件中:- map: phpmyadmin.dev to: /usr/share/phpmyadmin
在您的主机上,将以下行添加到您的
hosts
文件中:192.168.10.10 phpmyadmin.dev
...and Homestead's phpMyAdmin will be available at phpmyadmin.dev
...和 Homestead 的 phpMyAdmin 将在 phpmyadmin.dev
回答by Emeka Mbah
You can install phpmyadmin automatically when you vagrant up
or provision
your homestead by adding the following snippet to your Homestead\scripts\homestead.rbfile after # Update Composer On Every Provision
您可以通过将以下代码段添加到Homestead\scripts\homestead.rb文件后,在您vagrant up
或provision
您的宅基地自动安装 phpmyadmin# Update Composer On Every Provision
# Install phpMyAdmin on every provision
config.vm.provision "shell" do |s|
s.inline = "curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | sh"
end
Your hoomestead.rb file should now look somehow like this
你的 homestead.rb 文件现在应该看起来像这样
class Homestead
def Homestead.configure(config, settings)
# Configure The Box
config.vm.box = "laravel/homestead"
config.vm.hostname = "homestead"
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
some other entries are truncated to keep this short
其他一些条目被截断以保持简短
# Update Composer On Every Provision
config.vm.provision "shell" do |s|
s.inline = "/usr/local/bin/composer self-update"
end
# Install phpMyAdmin on every provision
config.vm.provision "shell" do |s|
s.inline = "curl -sS https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh | sh"
end
# Configure Blackfire.io
if settings.has_key?("blackfire")
config.vm.provision "shell" do |s|
s.path = "./scripts/blackfire.sh"
s.args = [settings["blackfire"][0]["id"], settings["blackfire"][0]["token"]]
end
end
end
end
Save file and run vagrant destroy
then vagrant up
or just vagrant reload
保存文件并运行vagrant destroy
,然后vagrant up
或只vagrant reload
NB: This uses Nikos Gr script located here https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh
注意:这使用位于https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh 的Nikos Gr 脚本
回答by GregTaylor
Finally it worked for me, few things I had to fix:
最后它对我有用,我必须解决的几件事:
Homestead.yaml file:
Homestead.yaml 文件:
- map: phpmyadmin.test
to: /home/vagrant/code/phpmyadmin/
I had to delete /public
from the end. I installed phpmyadmin (after vagrant ssh
command from Homestead directory) into the 'code' folder where the other projects are. When 'code' is with lowercase, it has to be everywhere so (or other way around): folder name, yaml file or even after installation performing these commands:
我不得不/public
从最后删除。我将 phpmyadmin(在vagrant ssh
Homestead 目录中的命令之后)安装到其他项目所在的“代码”文件夹中。当“代码”为小写时,它必须无处不在(或其他方式):文件夹名称、yaml 文件,甚至在安装后执行以下命令:
sudo ln -s /usr/share/phpmyadmin/ /home/vagrant/code/phpmyadmin
cd ~/code && serve phpmyadmin.test /home/vagrant/code/phpmyadmin
回答by Sahil Jain
This is the most simple solution. No mapping and all needed.
这是最简单的解决方案。没有映射和所有需要。
Downloadlatest phpmyadmin version from here https://www.phpmyadmin.net/downloads
Make a folder named phpmyadmininside your main root/public folder and unzipphpmyadmin here.
Run yourwebsite.com/phpmyadmin
从这里下载最新的 phpmyadmin 版本https://www.phpmyadmin.net/downloads
在主根目录/公共文件夹中创建一个名为phpmyadmin 的文件夹,然后在此处解压缩phpmyadmin。
运行yourwebsite.com/phpmyadmin
回答by José Rodríguez
As I couldn't comment on the Jyeon solution as my rep isn't high enough, I contribute with this answer; worked for me in Linux (openSUSE Leap) with Vagrant 1.8.1 and laravel/homestead (virtualbox, 0.4.0):
由于我的代表不够高,我无法对 Jyeon 解决方案发表评论,因此我提供了这个答案;在 Linux (openSUSE Leap) 中使用 Vagrant 1.8.1 和 laravel/homestead (virtualbox, 0.4.0) 对我来说有效:
Step 1:
第1步:
Go to phpMyAdminwebsite, download the latest version and unzip it into your project directory.
转到phpMyAdmin网站,下载最新版本并将其解压缩到您的项目目录中。
Step 2:
第2步:
Add to your Homestead.yaml file the following lines:
将以下几行添加到 Homestead.yaml 文件中:
folders:
- map: ~/Code/phpMyAdmin
to: /home/vagrant/Code/phpMyAdmin
Sites:
- map: phpmyadmin.app
to: /home/vagrant/Code/phpMyAdmin
Step 3:
第 3 步:
Add to your hosts file the following line:
将以下行添加到您的主机文件:
192.168.10.10 phpmyadmin.app
Step 4:
第四步:
After start your vagrant environment and connects to machine via SSH, set your virtual host to work with phpMyAdmin with the command serve:
在启动你的 vagrant 环境并通过 SSH 连接到机器后,使用命令 serve 将你的虚拟主机设置为与 phpMyAdmin 一起工作:
cd ~/Code
serve phpmyadmin.app /home/vagrant/Code/phpMyAdmin/
Thats it!
就是这样!
Go to http://phpmyadmin.appit should work, and you can login with your user and password homestead default. The great thing about this method is that you can set up your phpmyadmin so long as you keep it in your Homestead.yaml file and phpMyAdmin in your Code directory.
转到http://phpmyadmin.app它应该可以工作,您可以使用您的用户名和密码 homestead 默认登录。这种方法的好处是你可以设置你的 phpmyadmin,只要你把它保存在 Homestead.yaml 文件中,并将 phpMyAdmin 保存在你的代码目录中。