您好,登錄后才能下訂單哦!
本篇內容介紹了“如何搭建PHP虛擬機開發環境”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
鏈接:https://pan.baidu.com/s/1fJ-8CUJXdKUrwJQQIkta0A 提取碼:vjdr
鏈接:https://pan.baidu.com/s/1xLrLLbfVpnC97Zhw4rjJ1Q 提取碼:7m7z
鏈接:https://pan.baidu.com/s/1VlEbl5VbI5wbjyI6YyCVyQ 提取碼:zy8c 解壓lt-homestead-3-0-0-2017082400.zip,并進入目錄(不能有中文),執行 vagrant box add metadata.json 注意事項 vagrant box list 列出全部盒子 vagrant global-status --prune 查看活躍盒子 vagrant destroy (id:a1b2c3d4) # 銷毀活躍盒子 vagrant box remove laravel/homestead --box-version 3.0.0 刪除盒子
> cd D:/ > git clone https://github.com/laravel/homestead.git Homestead > cd Homestead > bash init.sh
--- ip: "192.168.10.10" memory: 2048 cpus: 2 provider: virtualbox #虛擬機平臺,用virtualbox裝的一定要確認這里是virtualbox authorize: ~/.ssh/id_rsa.pub #ssh的公鑰 keys: - ~/.ssh/id_rsa #ssh的私鑰,配置了ssh以后,登錄虛擬機可以直接在終端輸入homestead ssh進入 folders: #設置文件夾機映射關系 - map: E:/www #本地文件夾 to: /home/vagrant/code #虛擬機文件夾 sites: #設置域名和網站的映射關系 - map: laravel8.com #域名 to: /home/vagrant/code/laravel8/public php: "7.3" - map: tp6.com #域名 to: /home/vagrant/code/tp6/public php: "7.3" - map: devscibox.com #域名 to: /home/vagrant/code/Scibox/public php: "7.3" databases: - laravel8 - tp6 - scibox_nankai_online - scibox_bit_online features: - mysql: true - mariadb: false - postgresql: false - ohmyzsh: false - webdriver: false #services: # - enabled: # - "postgresql@12-main" # - disabled: # - "postgresql@11-main" # ports: # - send: 50000 # to: 5000 # - send: 7777 # to: 777 # protocol: udp
檢查 ls -al ~/.ssh,存在就不需要生成 生成 ssh-keygen -t rsa -C "your_email@example.com"
192.168.10.10 laravel8.com (注意ip)
vagrant up(如果啟動不了,就在virtualBox軟件里手動刪除)
命令行 | 說明 |
---|---|
vagrant init | 初始化 vagrant |
vagrant up | 啟動 vagrant |
vagrant halt | 關閉 vagrant |
vagrant ssh | 通過 SSH 登錄 vagrant(需要先啟動 vagrant) |
vagrant provision 或者vagrant reload --provision | 重新應用更改 vagrant 配置 |
vagrant destroy | 刪除 vagrant |
update-alternatives --display php 查看所有 php 版本和當前版本 sudo update-alternatives --config php 執行后,會列出當前 php 所有版本和編號,輸入編號,切換到執行的版本
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/(阿里) composer config -g repo.packagist composer https://packagist.org(官方)
進入/etc/nginx/sites-available 設置同域名文件,可寫sudo chmod -R 777 ./devscibox.com vim修改轉發為 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } 重啟nginx sudo service nginx restart
select @@GLOBAL.sql_mode 查詢sql_mode SET GLOBAL sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; 在navicat里設置 sudo service mysql restart 重啟mysql
$ cd ~/code (此目錄等效于本地www目錄) $ composer create-project laravel/laravel dirname --prefer-dist "8.*.*"
ssh 用戶名:vagrant 密碼:vagrant mysql軟件連接 host: 127.0.0.1 user: homestead pass: secret port: 33060 mysql網站連接 host: 127.0.0.1 user: homestead pass: secret port: 3306
http://laravel8.com/
######安裝netstat
sudo apt-get install net-tools
xon
######查詢網關ip
sudo netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10
php --ini | grep 'xdebug' sudo chmod -R 777 /etc/php/7.3/cli/conf.d/20-xdebug.ini (開啟寫入權限)
zend_extension=xdebug.so xdebug.mode=debug xdebug.discover_client_host=1 xdebug.client_port = 9001 xdebug.max_nesting_level = 512 xdebug.scream=0 xdebug.cli_color=1 xdebug.show_local_vars=1 xdebug.remote_enable=1 xdebug.remote_autostart=1 xdebug.remote_host=10.0.2.2 xdebug.remote_host=9001 xdebug.start_with_request = yes
sudo service php7.3-fpm restart sudo nginx -s reload
{ "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9001 }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 9001 }, { "name": "Listen for XDebug on Homestead", "type": "php", "request": "launch", "pathMappings": { "/home/vagrant/code/Scibox": "E:\\www\\Scibox" }, "port": 9001 } ] }
sudo chmod -R 777 /etc/apt/sources.list sudo vim /etc/apt/sources.list
清華 https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
sudo apt-get update
查看可安裝的包 apt-cache search mysql | grep mysql-server
“如何搭建PHP虛擬機開發環境”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。