diff --git a/config/apache2/sites-available/000-default.conf b/config/apache2/sites-available/000-default.conf index 341a39d..b2d2d17 100644 --- a/config/apache2/sites-available/000-default.conf +++ b/config/apache2/sites-available/000-default.conf @@ -1,12 +1,5 @@ - # The ServerName directive sets the request scheme, hostname and port that - # the server uses to identify itself. This is used when creating - # redirection URLs. In the context of virtual hosts, the ServerName - # specifies what hostname must appear in the request's Host: header to - # match this virtual host. For the default virtual host (this file) this - # value is not decisive as it is used as a last resort host regardless. - # However, you must set it for any further virtual host explicitly. - ServerName + _ServerName_ ServerAdmin webmaster@localhost DocumentRoot /var/www/html diff --git a/database_init.php b/database_init.php index 61905f3..bca3e83 100644 --- a/database_init.php +++ b/database_init.php @@ -4,6 +4,7 @@ include_once "globals.php"; // csatlakozás az adatbázis szervezhez, // a konkrét adatbázist még nem adjuk meg, mert lehet még nem létezik $dbconn = mysqli_connect(SQL_IP, SQL_USER, SQL_PASS); +$use_database_query = 'USE ' . SQL_DB . ';'; if (PHW_DB_GRANTED) { $create_database_query = 'CREATE DATABASE IF NOT EXISTS ' . SQL_DB . ';'; @@ -12,6 +13,8 @@ if (PHW_DB_GRANTED) { } else { echo "Hiba az adatbázis létrehozása során: " . mysqli_error($dbconn) . PHP_EOL; } +} else { + mysqli_query($dbconn, $use_database_query); } // az adatbázis kiválasztása diff --git a/entrypoint.sh b/entrypoint.sh index b7af46b..db10816 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh # generate revisor's password hash -PHW_REVIS_PWD_HASH=$(php -r "echo password_hash("${PHW_REVIS_PWD}", PASSWORD_DEFAULT);") +PHW_REVIS_PWD_HASH=$(php -r "echo password_hash('${PHW_REVIS_PWD}', PASSWORD_DEFAULT);") # generate globals.php from environment variables cd /var/www/html @@ -20,7 +20,7 @@ chown -R www-data:www-data ARTWORKS cat /database_init.php | php -d display_errors=on -d error_reporting=-1 # substitute server name -sed -i "s|ServerName|ServerName ${PHW_SERVER_NAME}|g" /etc/apache2/sites-available/000-default.conf +sed -i "s|_ServerName_|ServerName ${PHW_SERVER_NAME}|g" /etc/apache2/sites-available/000-default.conf # remove index.html rm /var/www/html/index.html