fix(web): blog & phpv8

This commit is contained in:
Baoshuo Ren 2022-03-17 16:19:43 +08:00
parent 7ddefd950e
commit e1631c09b5
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 8 additions and 5 deletions

View File

@ -66,7 +66,8 @@ class UOJContext {
if ($domain === null) { if ($domain === null) {
$domain = UOJConfig::$data['web']['main']['host']; $domain = UOJConfig::$data['web']['main']['host'];
} }
$domain = array_shift(explode(':', $domain)); $domain = explode(':', $domain);
$domain = array_shift($domain);
if (validateIP($domain) || $domain === 'localhost') { if (validateIP($domain) || $domain === 'localhost') {
$domain = ''; $domain = '';
} else { } else {

View File

@ -10,13 +10,15 @@ _judger_socket_password_=_judger_socket_password_
getAptPackage(){ getAptPackage(){
printf "\n\n==> Getting environment packages\n" printf "\n\n==> Getting environment packages\n"
#Update apt sources and install # Update apt sources and install
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
dpkg -s gnupg 2>/dev/null || (apt-get update && apt-get install -y gnupg) dpkg -s gnupg 2>/dev/null || (apt-get update && apt-get install -y gnupg)
echo "deb http://ppa.launchpad.net/stesie/libv8/ubuntu bionic main" | tee /etc/apt/sources.list.d/stesie-libv8.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D858A0DF echo "deb http://ppa.launchpad.net/stesie/libv8/ubuntu bionic main" | tee /etc/apt/sources.list.d/stesie-libv8.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D858A0DF
apt-get update && apt-get install -y vim ntp zip unzip curl wget apache2 libapache2-mod-xsendfile libapache2-mod-php php php-dev php-pear php-zip php-mysql php-mbstring php-gd php-intl php-xsl g++ make re2c libv8-7.5-dev libyaml-dev apt-get update && apt-get install -y git vim ntp zip unzip curl wget apache2 libapache2-mod-xsendfile libapache2-mod-php php php-dev php-pear php-zip php-mysql php-mbstring php-gd php-intl php-xsl g++ make re2c libv8-7.5-dev libyaml-dev
# Install PHP extensions # Install PHP extensions
printf "/opt/libv8-7.5\n\n" | pecl install v8js yaml yes | pecl install yaml
git clone https://github.com/phpv8/v8js.git --depth=1 /tmp/pear/download/v8js-master && cd /tmp/pear/download/v8js-master
phpize && ./configure --with-php-config=/usr/bin/php-config --with-v8js=/opt/libv8-7.5 && make install && cd -
} }
setLAMPConf(){ setLAMPConf(){
@ -45,7 +47,7 @@ UOJEOF
a2enmod rewrite headers && sed -i -e '172s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf a2enmod rewrite headers && sed -i -e '172s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
#Create UOJ session save dir and make PHP extensions available #Create UOJ session save dir and make PHP extensions available
mkdir --mode=733 /var/lib/php/uoj_sessions && chmod +t /var/lib/php/uoj_sessions mkdir --mode=733 /var/lib/php/uoj_sessions && chmod +t /var/lib/php/uoj_sessions
sed -i -e '865a\extension=v8js.so\nextension=yaml.so' /etc/php/7.2/apache2/php.ini sed -i -e '912a\extension=v8js.so\nextension=yaml.so' /etc/php/7.4/apache2/php.ini
} }
setWebConf(){ setWebConf(){