Ubuntu监控目录
234 words
One minute
注意
1
| sudo apt-get install inotify-tools nginx -y
|
- 将docker项目保存nginx配置的目录挂载到主机,主机目录需要777权限
相关文件,根目录为 root
1
2
3
4
5
6
7
8
9
| #!/bin/bash
dir=$1
dir2=$2
sleep 1
cp "$dir/$dir2/default.conf" "/etc/nginx/sites-enabled/$dir2-my-laravel-project.com"
service nginx restart
|
1
2
3
4
5
6
7
8
9
10
11
12
| #!/bin/sh
# 监视的文件或目录
filename=$1
# 监视发现有增、删、改时执行的脚本
script=$2
inotifywait -mq --format '%f' -e create $filename | while read line
do
bash $script $filename $line
done
|
1
2
3
4
5
6
7
8
9
10
| server {
listen 10001;
# server_name ~^(?<subdomain>.+)\.test_domain\.com$;
# root "/$subdomain";
root "/home/laravel-project/storage/app/websites/1";
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
|
1
| bash web-dir-monitor.sh /home/laravel-project/storage/app/websites build-web.sh
|