本篇內(nèi)容介紹了“如何搭建PHP虛擬機(jī)開(kāi)發(fā)環(huán)境”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
灤州網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、APP開(kāi)發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開(kāi)發(fā),運(yùn)營(yíng)維護(hù)。成都創(chuàng)新互聯(lián)公司從2013年創(chuàng)立到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專(zhuān)注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)公司。
鏈接: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,并進(jìn)入目錄(不能有中文),執(zhí)行 vagrant box add metadata.json 注意事項(xiàng) vagrant box list 列出全部盒子 vagrant global-status --prune 查看活躍盒子 vagrant destroy (id:a1b2c3d4) # 銷(xiāo)毀活躍盒子 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 #虛擬機(jī)平臺(tái),用virtualbox裝的一定要確認(rèn)這里是virtualbox authorize: ~/.ssh/id_rsa.pub #ssh的公鑰 keys: - ~/.ssh/id_rsa #ssh的私鑰,配置了ssh以后,登錄虛擬機(jī)可以直接在終端輸入homestead ssh進(jìn)入 folders: #設(shè)置文件夾機(jī)映射關(guān)系 - map: E:/www #本地文件夾 to: /home/vagrant/code #虛擬機(jī)文件夾 sites: #設(shè)置域名和網(wǎng)站的映射關(guān)系 - 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(如果啟動(dòng)不了,就在virtualBox軟件里手動(dòng)刪除)
命令行 | 說(shuō)明 |
---|---|
vagrant init | 初始化 vagrant |
vagrant up | 啟動(dòng) vagrant |
vagrant halt | 關(guān)閉 vagrant |
vagrant ssh | 通過(guò) SSH 登錄 vagrant(需要先啟動(dòng) vagrant) |
vagrant provision 或者vagrant reload --provision | 重新應(yīng)用更改 vagrant 配置 |
vagrant destroy | 刪除 vagrant |
update-alternatives --display php 查看所有 php 版本和當(dāng)前版本 sudo update-alternatives --config php 執(zhí)行后,會(huì)列出當(dāng)前 php 所有版本和編號(hào),輸入編號(hào),切換到執(zhí)行的版本
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/(阿里) composer config -g repo.packagist composer https://packagist.org(官方)
進(jìn)入/etc/nginx/sites-available 設(shè)置同域名文件,可寫(xiě)sudo chmod -R 777 ./devscibox.com vim修改轉(zhuǎn)發(fā)為 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } 重啟nginx sudo service nginx restart
select @@GLOBAL.sql_mode 查詢(xún)sql_mode SET GLOBAL sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; 在navicat里設(shè)置 sudo service mysql restart 重啟mysql
$ cd ~/code (此目錄等效于本地www目錄) $ composer create-project laravel/laravel dirname --prefer-dist "8.*.*"
ssh 用戶(hù)名:vagrant 密碼:vagrant mysql軟件連接 host: 127.0.0.1 user: homestead pass: secret port: 33060 mysql網(wǎng)站連接 host: 127.0.0.1 user: homestead pass: secret port: 3306
http://laravel8.com/
######安裝netstat
sudo apt-get install net-tools
xon
######查詢(xún)網(wǎng)關(guān)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 (開(kāi)啟寫(xiě)入權(quán)限)
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虛擬機(jī)開(kāi)發(fā)環(huán)境”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!