forked from helloxz/Docker-LNMP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangyaxian
committed
Jan 26, 2021
1 parent
a4d9270
commit 3729ba8
Showing
9 changed files
with
107 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
# @auther <1822581649@qq.com> | ||
# @auther <wangyaxiandev@gmail.com> | ||
|
||
/usr/sbin/init | ||
/usr/sbin/crond | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,63 @@ | ||
# 如何新建一个站点 | ||
|
||
比如部署一个Yii2项目 https://github.com/duiying/Yii2-Admin , 并且可以通过 http://frontend.yii2.test 访问 | ||
比如部署一个 Lumen 项目,并且可以通过 http://lumen-app.com 访问: | ||
|
||
#### 1. 配置Nginx | ||
```shell | ||
# Docker-LNMP/docker/config/proxy/conf.d 目录下新建一个配置文件 yii2-docker.conf | ||
[root@localhost Docker-LNMP]# vim docker/config/proxy/conf.d/yii2-docker.conf | ||
``` | ||
yii2-docker.conf 内容如下: | ||
``` | ||
server { | ||
**1、配置 Nginx** | ||
|
||
listen 80; | ||
Docker-LNMP/docker/config/proxy/conf.d 目录下新建一个配置文件 lumen-app.conf,lumen-app.conf 内容如下: | ||
|
||
server_name frontend.yii2.test; | ||
root /data/www/Yii2-Admin/frontend/web; | ||
index index.php index.html index.htm; | ||
``` | ||
server { | ||
listen 80; | ||
server_name lumen-app.com; | ||
root /data/www/lumen-app/public; | ||
index index.html index.htm index.php; | ||
location / { | ||
# Redirect everything that isn't a real file to index.php | ||
try_files $uri $uri/ /index.php$is_args$args; | ||
} | ||
# deny accessing php files for the /assets directory | ||
location ~ ^/assets/.*\.php$ { | ||
deny all; | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
location ~ \.php$ { | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_pass cgi:9000; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
try_files $uri =404; | ||
} | ||
location ~* /\. { | ||
deny all; | ||
} | ||
} | ||
``` | ||
|
||
#### 2. 克隆项目 | ||
**2、安装 Lumen 项目** | ||
|
||
```shell | ||
# Docker-LNMP/www 目录下安装 https://github.com/duiying/Yii2-Admin , 安装过程如下: | ||
[root@localhost Docker-LNMP]# cd www | ||
[root@localhost www]# ls | ||
index.php | ||
[root@localhost www]# git clone https://github.com/duiying/Yii2-Admin.git | ||
[root@localhost www]# ls | ||
index.php Yii2-Admin | ||
# Docker-LNMP/www 目录下安装 Lumen 框架,安装过程如下: | ||
|
||
# 更改目录权限 | ||
[root@localhost www]# chmod -R 777 Yii2-Admin/ | ||
$ cd www | ||
$ ls | ||
index.php | ||
$ composer create-project laravel/lumen lumen-app "5.7.*" | ||
``` | ||
|
||
#### 3. 修改本地hosts | ||
**3、修改本地 hosts** | ||
|
||
``` | ||
# 192.168.246.128是虚拟机IP地址 | ||
192.168.246.128 frontend.yii2.test | ||
# 这里本地用的是 Macbook,所以这里填的是 127.0.0.1,如果你用的是虚拟机,需要将 127.0.0.1 改成虚拟机的 IP 地址, | ||
127.0.0.1 lumen-app.com | ||
``` | ||
|
||
#### 4. 重启Nginx | ||
**4、重启 Nginx** | ||
|
||
```shell | ||
[root@localhost Docker-LNMP]# docker restart proxy | ||
$ docker restart proxy | ||
proxy | ||
``` | ||
|
||
#### 5. 浏览器访问 | ||
http://frontend.yii2.test | ||
**5、浏览器访问** | ||
|
||
访问 http://lumen-app.com,可以看到页面显示出下面欢迎内容: | ||
|
||
``` | ||
Lumen (5.7.8) (Laravel Components 5.7.*) | ||
``` | ||
|
||
 | ||
至此,一个 Lumen 项目部署完成。 |