homestead
homestead copied to clipboard
We hope that we can create a website of webman framework in homestead.
Versions
- Vagrant: 2.2.19
- Provider: Virtualbox 6.1.32
- Homestead: v12.5.0
Host operating system
Windows 21H1 19043.1526
Homestead.yaml
sites:
- map: homestead.test
to: /home/vagrant/code/public
- map: webman.test
to: /home/vagrant/code/php/webman-test/public
php: "8.0"
type: webman
upstreamPort: 8788
Problem
Hope to add upstreamPort
to s.args
and add new site type for webman framework
can see this link: https://www.workerman.net/a/1287
The content of Homestead/scripts/site-types/webman.sh
is below:
#!/usr/bin/env bash
declare -A params=$6 # Create an associative array
declare -A headers=${9} # Create an associative array
declare -A rewrites=${10} # Create an associative array
paramsTXT=""
if [ -n "$6" ]; then
for element in "${!params[@]}"
do
paramsTXT="${paramsTXT}
fastcgi_param ${element} ${params[$element]};"
done
fi
headersTXT=""
if [ -n "${9}" ]; then
for element in "${!headers[@]}"
do
headersTXT="${headersTXT}
add_header ${element} ${headers[$element]};"
done
fi
rewritesTXT=""
if [ -n "${10}" ]; then
for element in "${!rewrites[@]}"
do
rewritesTXT="${rewritesTXT}
location ~ ${element} { if (!-f \$request_filename) { return 301 ${rewrites[$element]}; } }"
done
fi
if [ "$7" = "true" ]
then configureXhgui="
location /xhgui {
try_files \$uri \$uri/ /xhgui/index.php?\$args;
}
"
else configureXhgui=""
fi
block="upstream webman {
server 127.0.0.1:${11};
}
server {
listen ${3:-80};
listen ${4:-443} ssl http2;
server_name .$1;
root \"$2\";
index index.html index.htm index.php;
charset utf-8;
$rewritesTXT
location / {
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header Host \$host;
$headersTXT
if (!-f \$request_filename){
proxy_pass http://webman;
}
}
$configureXhgui
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/$1-error.log error;
sendfile off;
location ~ /\.ht {
deny all;
}
ssl_certificate /etc/ssl/certs/$1.crt;
ssl_certificate_key /etc/ssl/certs/$1.key;
}
"
echo "$block" > "/etc/nginx/sites-available/$1"
ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"
The content of homestead.rb
is below:
<...>
# Convert the site & any options to an array of arguments passed to the
# specific site type script (defaults to laravel)
s.path = script_dir + "/site-types/#{type}.sh"
s.args = [
site['map'], # $1
site['to'], # $2
site['port'] ||= http_port, # $3
site['ssl'] ||= https_port, # $4
site['php'] ||= '8.0', # $5
params ||= '', # $6
site['xhgui'] ||= '', # $7
site['exec'] ||= 'false', # $8
headers ||= '', # $9
rewrites ||= '', # $10 注意,这里要增加 ","
site['upstreamPort'] ||= '8787', # $11 这里是新增的
]
<...>