# 快速部署

目前市面上有很多常用的服务部署工具,如 PhpStudy宝塔Xampp 等等,原理都是一样的,大家可以根据自己的实际情况选择自己熟悉的工具安装部署服务即可,Xampp 是目前框架开发过程中所用到的工具,如需要安装使用可以到群文件中自行下载,下面我们详细说明工具部署方法;

# 工具安装

本案例以 xampp 工具为切入点,安装在D盘,安装后目录结构如下图所示:

Xampp服务

此时为了方便更多项目的管理,我们需要对 apache 配置文件进行优化配置, 打开目录 D:\xampp\apache\conf 并新建虚拟主机存放目录 vhost,接着打开当前目录下的配置文件 httpd.conf 将前面新建的目录进行配置,如下图所示:

Xampp服务

参数配置如下所示:

Xampp服务

将解压的框架目录直接拷贝值 host 目录中,如下图所示:

Xampp服务

# 项目部署

  • Apache部署

下面我们将解压后的项目框架 RXThinkCMF_EVL8_PRO 完整的拷贝到工具的 host 目录中,如下图所示:

Xampp服务

项目框架的入口文件为 public 目录下的 index.php 文件,因为我们需要配置一个虚拟主机指向此入口文件即可,我们在目录 D:\xampp\apache\conf\vhost 下新建文件名为 evl8.pro.conf 的虚拟主机配置文件,具体配置内容如下:

<VirtualHost *:80>
   ServerAdmin rxthinkcmf@163.com
   ServerName evl8.pro
   ServerAlias admin.evl8.pro
   DocumentRoot "E:\RXThinkCMF\RXThinkCMF_EVL8_PRO\public"
   ErrorLog "logs/evl8.pro-error.log"
   CustomLog "logs/evl8.pro-access.log" common
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin rxthinkcmf@163.com
   ServerName images.evl8.pro
   DocumentRoot "E:\RXThinkCMF\RXThinkCMF_EVL8_PRO\public\uploads"
   ErrorLog "logs/evl8.pro-error.log"
   CustomLog "logs/evl8.pro-access.log" common
</VirtualHost>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  • Nginx部署
server {
    listen       80;
    server_name  admin.evl8.pro;
    root    /xxx/evl_web/public;
    index   index.php;
    charset utf-8;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
        root   html;
    }
    error_log /www/logs/nginx/admin.evl8.pro.error.log;
    access_log /www/logs/nginx/admin.evl8.pro.access.log;


    if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=$1  last;
        break;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1: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
    location ~ /\.ht {
        deny  all;
    }
}

# 后端服务图片域名
server {
    listen 80;
    server_name  images.evl8.pro;
    root /xxx/evl_web/public/uploads;
    location ~ \.ico|jpg|JPG|PNG|GIF|JPEG|jpeg|gif|png|js|css|woff2|ttf$ {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Request-Methods GET,POST,PUT,DELETE,OPTIONS;
        #expires 1h;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

至此后端服务相关配置基本实现,后端服务配置包括两部分,一部分 服务域名图片域名,分别负责后端服务的访问和图片的访问;