ubuntu下docker环境、php环境以及laravel的安装
生活随笔
收集整理的這篇文章主要介紹了
ubuntu下docker环境、php环境以及laravel的安装
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
ubuntu下docker環境、php環境以及laravel的安裝
因為在學習laravel,需要搭建一個php7的開發環境,經常要反復卸載重新安裝各種軟件,多搞幾遍環境可能就被污染。所有想到了可以使用docker來安裝容器,還方便擴展。安裝步驟:
- ubuntu安裝git php composer docker
- ubutnu安裝laravel
- docker下載鏡像,啟動容器
- 修改docker nginx容器的配置文件
1. ubuntu安裝git php composer docker
- 安裝git
- 安裝php7.0
- 安裝docker
- 安裝composer
注意: 如果上述方法由于某些原因失敗了,你還可以通過 php >下載安裝器:
php -r "readfile('https://getcomposer.org/installer');" | php全局調用composer設置
sudo mv composer.phar /usr/local/bin/composer2. ubuntu安裝laravel
下載laravel安裝器
composer global require "laravel/installer"laravel命令加入環境變量,實現全局調用
sudo vim /etc/profile在文件底部加入
export PATH=~/.config/composer/vendor/bin:$PATH使環境變量生效
source /etc/profile建立文件夾,修改權限,進入目錄
sudo mkdir /var/www sudo chmod -R 777 /var/www cd /var/www用命令建立laravel項目
laravel new bolg or composer create-project --prefer-dist laravel/laravel blog修改項目文件里面的storage 和 bootstrap/cache 權限 777
cd /var/www/bolg chmod -R 777 storage chmod -R 777 bootstrap/cache3. docker下載鏡像,啟動容器
- 下載鏡像
- 啟動容器
4. 修改docker nginx容器的配置文件
進入nginx容器
sudo docker exec -it nginx /bin/bash apt-get update apt-get isntall vim vim /etc/nginx/conf.d/default.conf用下面文件替換
請注意fastcgi_pass,它的值是你php容器的域名或者ip。例如:172.17.0.3:9000;
server {listen 80;server_name localhost;#charset koi8-r;#access_log /var/log/nginx/log/host.access.log main;root /var/www/html;index index.php index.html index.htm;#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root $document_root;fastcgi_pass 172.17.0.3:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#} }轉載于:https://my.oschina.net/wms3001/blog/720041
總結
以上是生活随笔為你收集整理的ubuntu下docker环境、php环境以及laravel的安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS-应用生命周期
- 下一篇: LNMP_静态文件不记录日志,配置缓存