PearProject 在 WSL 下的開發環境部署教程

cnguu 發表於 2019-08-22

簡介

專案管理系統:PearProject

部署環境

  • WSL(Ubuntu18.04)
  • Nginx1.16.0
  • PHP7.2
  • MySQL5.7.26
  • Redis5.0.3

專案依賴

  • PDO PHP Extension
  • PHP Igbinary
  • PHP Redis

部署過程

後端

$ cd /www/wwwroot
$ sudo git clone https://github.com/a54552239/pearProjectApi.git
$ cd pearProjectApi
$ sudo composer install
$ sudo chown cnguu:cnguu -R ../pearProjectApi
$ mkdir runtime
$ chmod 777 runtime

前端

cnguu 是使用者名稱

$ sudo chown -R $USER:$(id -gn $USER) /home/cnguu/.config
$ cd /www/wwwroot
$ sudo git clone https://github.com/a54552239/pearProject.git
$ cd pearProject
$ sudo npm install
$ sudo chown cnguu:cnguu -R ../pearProject

修改 vue.config.js

const DEV_URL = 'http://p1.test';
module.exports = {
    devServer: {
        disableHostCheck: true,
    }
}

Nginx 配置

先配置 hosts

PearProject 在 WSL 下的部署教程

再配置 Nginx

server
{
    listen 80;
    server_name p1.test;
    index index.php;
    root /www/wwwroot/pearProjectApi;

    include enable-php-72.conf;

    location / {  
        try_files $uri $uri/ /index.php$is_args$query_string;  
    }  

    #禁止訪問的檔案或目錄
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log off;
        access_log /dev/null;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log off;
        access_log /dev/null; 
    }
    access_log  /dev/null;
    error_log  /www/wwwlogs/p1.test.error.log;
}

server
{
    listen 80;
    server_name p2.test;
    index index.html;
    root /www/wwwroot/pearProject;

    error_page 405 =200 $uri;

    location /
    {
        proxy_pass http://127.0.0.1:8045;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header REMOTE-HOST $remote_addr;
    }

    access_log  /dev/null;
    error_log  /www/wwwlogs/p2.test.error.log;
}

愛護牙齒