window10裡面子系統ubuntu安裝nginx,php7.2,swoole,composer,hyperf
阿新 • • 發佈:2020-12-13
技術標籤:Swoolecomposerubuntuswoole
ubuntu版本18.04.7,預設最新php版本7.2
安裝php最新版本,則用命令
sudo apt-get install php nginx使用php需要安裝php7.2-fpm, 和一些php外掛 sudo apt-get install php7.2-mysql php7.2-fpm php7.2-curl php7.2-xml php7.2-gd php7.2-bcmath php7.2-mbstring php-memcached php7.2-zip 如果使用 sudo whereis php.ini 查不到檔案位置,可以使用phpinfo(),來檢視php.ini來檢視
安裝Nginx
sudo apt install nginx
sudo service nginx status #檢視狀態
nginx配置檔案:/etc/nginx/sites-available/default
命令
啟動php-fpm,nginx
sudo service php7.2-fpm restart 重啟php
sudo service php7.2-fpm status php狀態
sudo service php7.2-fpm start 開啟php
sudo service nginx restart
安裝swoole
sudo pecl install swoole 把安裝的擴充套件加到php.ini檔案裡面
安裝redis
sudo apt-get install redis-server
把安裝的擴充套件加到php.ini檔案裡面
安裝composer
下載composer.phar
sudo wget https://getcomposer.org/composer.phar
或者 sudo curl -O https://getcomposer.org/composer.phar
重新命名檔案composer.phar 為 composer
sudo mv composer.phar composer
sudo chmod +x composer
現在可以通過./composer 命令執行composer,但這隻僅限於在當前目錄執行。要想全域性使用,composer ,要設定把它為全域性變數。找到composer檔案,把它移到/usl/local/bin 目錄,這樣就可以在全域性使用composer 命令。
在終端輸入$ composer 會有如下顯示,表明安裝成功
安裝hyperf
更換為阿里雲映象(不更換映象,導致下載失敗)
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# 通過 Composer 安裝 hyperf/hyperf-skeleton 專案
composer create-project hyperf/hyperf-skeleton
# 進入安裝好的 Hyperf 專案目錄
cd hyperf-skeleton
# 啟動 Hyperf
php bin/hyperf.php start
因ubuntu是window10子系統,所以IP是同一個,為了可以訪問ubuntu裡面專案,可以把nginx配置檔案監聽埠80,改成自己需要的如8081,然後通過127.0.0.1:8081訪問。