niiknow / vestacp

Dockerized Vesta Control Panel aka vestacp
MIT License
148 stars 89 forks source link

[Question] How to reset Apache2 Template? #141

Closed LenKiMo closed 3 years ago

LenKiMo commented 3 years ago

I found my Apache2 or Nginx templates might be broken. When using default template, it might cause 500 Error, and there are only PHP72/73/74 templates, php 8.0 template doesn't exists in the list. I had tried re-install the docker, but it seems like the templates is following user backup, so it doesn't work though. How to reset/replace/rebuild the template, to making website using the latest php template?

LenKiMo commented 3 years ago

This is my my-startup.sh, I wonder is it too old?

#!/bin/sh
# restore current users
if [[ -f /vesta/etc-bak/passwd ]]; then
        # restore users
        rsync -a /vesta/etc-bak/passwd /etc/passwd
        rsync -a /vesta/etc-bak/shadow /etc/shadow
        rsync -a /vesta/etc-bak/gshadow /etc/gshadow
        rsync -a /vesta/etc-bak/group /etc/group
fi

# only if you run in privileged mode
# if [[ -f /etc/fail2ban/jail.new ]]; then
#     mv /etc/fail2ban/jail.local /etc/fail2ban/jail.local-bak
#     mv /etc/fail2ban/jail.new /etc/fail2ban/jail.local
# fi

# re-enable phpmyadmin and phppgadmin
 rsync -a /etc/apache2/conf-d/php*.conf /etc/apache2/conf.d

# required startup and of course vesta
cd /etc/init.d/
./disable-transparent-hugepages defaults \
&& ./apache2 start \
&& ./mysql start \
&& ./postgresql start \
&& ./nginx start \
&& ./vesta start

&& ./exim4 start \
&& ./dovecot start \
&& ./clamav-daemon start \
&& ./spamassassin start \
&& ./php7.0-fpm start \
# && ./fail2ban start \ # -- only if you run in privileged mode
LenKiMo commented 3 years ago

I found /sysprepz/home/admin/bin/my-startup.sh still using php7.2 php7.3, this is strange. I have replaced them by https://github.com/niiknow/vestacp/blob/master/rootfs/sysprepz/admin/bin/my-startup.sh and restart the container, but it seems doesn't work, Vesta still list php 72/73/74 templates.

noogen commented 3 years ago

Use the latest my-startup as < php7.3 no longer supported. Make sure you have everything backed up. Then try running this to update Vesta:

/bin/vesta-update.sh

Then in the UI, switch between different version of php7.3 to 7.4 and then back etc... This will cause restart of php and nginx in the correct order so it will work.

If you nginx is broken then you have to ssh in and run nginx -t to see what is broken.

Advance debug: Look at your web log to see what the 500 error is about. You should be doing this as the first step of any 500 error.

LenKiMo commented 3 years ago

Thanks, but I found another stupid answer. The default latest tag image in docker hub is not the latest iamge. I will re-install the 1.10.2 image and try again. Update later.

noogen commented 3 years ago

I suggest using the php-fpm template as I am not too familiar with Apache2 troubleshooting. Usually, Apache2 is easier to work with and simply just work for me. But I'm more familiar with nginx.

noogen commented 3 years ago

And yep, I don't always update latest image. I setup docker hub to auto build when I check in. Don't usually have time to pull down 5 gig image to tag latest.

LenKiMo commented 3 years ago

It seems works. But I found another problem.

If I using php73/74/80fpm for Apache2 and default for Nginx, it will cause site link Another site. When means when I access a.example.com, it actually load b.example.com.

If using default for Apache2 and default or php-fpm for Nginx, it can load the right site, but warning Imagick WEBP image type support is not enabled., which I can confirm webp is proxied by Nginx. Not relational.

The cross-site loading seems more critical, what situation might cause this problem?

noogen commented 3 years ago

If you're doing fpm for Apache2, then you want to pick php-fpm for nginx. If you do fcgi, then you can use default.

noogen commented 3 years ago

See my documentation here indicate that fpm must go with fpm: https://github.com/niiknow/vestacp/blob/master/docs/php-fpm.md

The other fpm can go with is Wordpress because I customize it.

LenKiMo commented 3 years ago

Seems resolve currently. Close the issue. Thanks for your help.