How do I set up phpMyAdmin on a Laravel Homestead box?

前端 未结 14 1275
无人共我
无人共我 2020-12-12 09:48

I installed it by running sudo apt-get install phpymyadmin and then running

sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html and

相关标签:
14条回答
  • 2020-12-12 10:08

    For another alternative that I found super simple and that worked right out of the box I set up a new Nginx site from inside the Homestead box using the serve.sh script:

    serve adminer.app /home/vagrant/Code/adminer/

    And then in there I dropped the one page successor to phpmyadmin, Adminer. I also renamed it to "index.php" to make it just work. Then after adding the adminer.app entry to my hosts file I was good to go.

    Had not used a web based MySQL interface in years since I just didn't like maintaining phpMyAdmin but this one is sweet. One file (plus an optional CSS file if you want a nicer theme) and that is all. Easy to maintain and update.

    0 讨论(0)
  • 2020-12-12 10:11

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

    Then Create and config site for 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

     127.0.0.1   phpmyadmin.app
    

    Navigate to http://phpmyadmin.app:8000 and you should now see phpMyAdmin login page.

    More info available here if you need it

    0 讨论(0)
  • 2020-12-12 10:12

    A simplified version of Jyeon's Answer. You don't need to share the ~/Code folder in the Homestead.yaml file:

    folders:
        - map: /Users/{yourName}/Code/phpMyAdmin
          to: /home/vagrant/Code/phpMyAdmin
    

    Just download the latest version of PhpMyAdmin from PhpMyAdmin and put the unzipped file in the ~/Code/phpMyAdmin folder and just follow the 2 step here:

    Step 1: Open up homestead.yaml file and add these lines

    sites: - map: phpmyadmin.app to: /home/vagrant/Code/phpMyAdmin

    Step 3: Open up your hosts file and add this line:

    192.168.10.10 phpmyadmin.app

    Now run the vagrant reload --provision command and you're good to go.

    Open up the phpmyadmin.app address in your browser and you'll see the phpmyadmin interface.

    0 讨论(0)
  • 2020-12-12 10:16

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

    Step 1:

    Go to phpMyAdmin website, download the latest version and unzip it into your project directory.

    Step 2:

    Add to your Homestead.yaml file the following lines:

    folders:
        - map: ~/Code/phpMyAdmin
          to: /home/vagrant/Code/phpMyAdmin
    
    Sites:
        - map: phpmyadmin.app
          to: /home/vagrant/Code/phpMyAdmin
    

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

    cd ~/Code
    serve phpmyadmin.app /home/vagrant/Code/phpMyAdmin/
    

    Thats it!

    Go to http://phpmyadmin.app it 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.

    0 讨论(0)
  • 2020-12-12 10:16

    In my case accepted solution works ok except:

    $ cd ~/Code && serve phpmyadmin.app /home/vagrant/Code/phpmyadmin
    dos2unix: converting file /vagrant/scripts/serve.sh to Unix format ...
     * Restarting nginx nginx                                                                                                                            [fail] 
    php5-fpm stop/waiting
    php5-fpm start/running, process 4112
    

    For an unknown reason serve command files creating configuration file as seen in:

    $ sudo tail -f /var/log/nginx/error.log 
    2015/03/18 11:54:16 [emerg] 3671#0: invalid number of arguments in "listen" directive in /etc/nginx/sites-enabled/phpmyadmin.app:2
    

    Edit config:

    $ editor /etc/nginx/sites-enabled/phpmyadmin.app
    

    and add 80 to Listen directive at line 2. Apply changes with:

    $ sudo service nginx reload
    
    0 讨论(0)
  • 2020-12-12 10:18

    You can install phpmyadmin automatically when you vagrant up or provision your homestead by adding the following snippet to your Homestead\scripts\homestead.rb file after # 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

    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

    NB: This uses Nikos Gr script located here https://raw.githubusercontent.com/grrnikos/pma/master/pma.sh

    0 讨论(0)
提交回复
热议问题