addet php and nginx option
This commit is contained in:
parent
72d02eb3c0
commit
2545e917d5
1 changed files with 50 additions and 11 deletions
47
.zshrc
47
.zshrc
|
@ -233,17 +233,56 @@ _alias(){
|
|||
alias dc="docker compose"
|
||||
alias appupdate="docker compose pull && docker compose up -d --force-recreate"
|
||||
drweb() {
|
||||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
||||
echo "Usage: drweb [directory] [port]"
|
||||
drweb_help() {
|
||||
echo "Usage: drweb <server_type> [directory] [port]"
|
||||
echo " server_type: Type of server to use (nginx or php)"
|
||||
echo " directory: Directory to serve (default: current directory)"
|
||||
echo " port: Port to use (default: 8080)"
|
||||
return
|
||||
}
|
||||
|
||||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
||||
drweb_help
|
||||
return
|
||||
fi
|
||||
|
||||
local dir="${1:-./}"
|
||||
local port="${2:-8080}"
|
||||
local server_type="$1"
|
||||
local dir="${2:-./}"
|
||||
local port="${3:-8080}"
|
||||
|
||||
if [[ ! -d "$dir" ]]; then
|
||||
echo "Error: Directory $dir does not exist"
|
||||
drweb_help
|
||||
return 1
|
||||
fi
|
||||
|
||||
case "$server_type" in
|
||||
nginx)
|
||||
if [[ -f "$dir/index.html" || -f "$dir/index.php" ]]; then
|
||||
docker run -p "$port:80" -v "$dir:/usr/share/nginx/html:ro" nginx:alpine
|
||||
echo "Nginx is serving $dir on port $port"
|
||||
else
|
||||
echo "Error: No index.html or index.php found in $dir"
|
||||
drweb_help
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
php)
|
||||
if [[ -f "$dir/index.php" || -f "$dir/index.html" ]]; then
|
||||
docker run -p "$port:80" -v "$dir:/var/www/html" php:7.4-apache
|
||||
echo "PHP Apache is serving $dir on port $port"
|
||||
else
|
||||
echo "Error: No index.php or index.html found in $dir"
|
||||
drweb_help
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Error: Unsupported server type '$server_type'"
|
||||
drweb_help
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue