You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
#!/bin/sh |
|
|
|
PORT=${PORT:-9876} |
|
if ! [ "$PORT" -ge 1 ] 2>/dev/null || ! [ "$PORT" -le 65535 ] 2>/dev/null; then |
|
echo "Warning: Invalid PORT '$PORT', using default 9876" |
|
PORT=9876 |
|
fi |
|
|
|
echo "Generating Apache configuration with PORT=$PORT" |
|
envsubst '${PORT}' < /usr/local/apache2/conf/httpd.conf.template > /usr/local/apache2/conf/httpd.conf |
|
|
|
echo "Testing Apache configuration..." |
|
if ! httpd -t; then |
|
echo "ERROR: Apache configuration test failed!" |
|
echo "Configuration file contents:" |
|
cat /usr/local/apache2/conf/httpd.conf |
|
exit 1 |
|
fi |
|
|
|
echo "Checking htdocs directory..." |
|
ls -la /usr/local/apache2/htdocs/ | head -20 |
|
echo "File count: $(find /usr/local/apache2/htdocs -type f | wc -l)" |
|
|
|
echo "Checking if port $PORT is available..." |
|
if ! netstat -tuln 2>/dev/null | grep -q ":$PORT "; then |
|
echo "Port $PORT appears to be available" |
|
else |
|
echo "WARNING: Port $PORT might be in use" |
|
fi |
|
|
|
echo "Starting Apache on port $PORT..." |
|
echo "Apache will run with PID: $$" |
|
# Run httpd in foreground with error logging, redirect stderr to stdout |
|
exec httpd -D FOREGROUND -e info 2>&1
|
|
|