bfabiszewski / ulogger-server

μlogger • web viewer for tracks uploaded with μlogger mobile client
GNU General Public License v3.0
522 stars 85 forks source link

Blank page when invoking PHP files #146

Closed dancesWithCycles closed 3 years ago

dancesWithCycles commented 3 years ago

Hi there, I just followed the installation procedure to setup the ulogger server on a freshly installed LAMP Debian 10 server. Can you imagine a reason why I receive blank pages when I invoke either index.php or scripts/setup.php in a web browser?

I am calling the PHP scripts the following way:

http://192.168.1.181/scripts/setup.php or http://192.168.1.181/index.php

Here is my setup:

I copied the archive to /var/www/ulogger-server and extracted the content.

I created the virtual host configuration file /etc/apache2/sites-available/ulogger-server.conf with the following content:

<VirtualHost *:80> ServerName ulogger-server ServerAlias www.ulogger-server ServerAdmin webmaster@localhost DocumentRoot /var/www/ulogger-server ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

I called the following instructions to configure apache.

sudo mkdir /var/www/ulogger-server sudo chown -R $USER:$USER /var/www/ulogger-server sudo vi /etc/apache2/sites-available/ulogger-server.conf sudo a2ensite ulogger-server sudo a2dissite 000-default sudo apache2ctl configtest sudo systemctl reload apache2

The setup.php is enabled.

I made sure that Linux, Apache, MariaDB and PHP are up, running and can interact.

Obviously, I missed something or I am blind to the mistake. Do you have an idea? I thank you very much and remain with

Best regards

peteman52 commented 3 years ago

Try sudo chown -R www-data:www-data /var/www/ulogger-server I don't think your $USER equals www-data

dancesWithCycles commented 3 years ago

Hi peteman52, how are you doing? Indeed, the directory was configured to a different user. Thank you very much to pointing me on this particular situation. How come, you figured that out using my issue description?

I changed to properties to those you suggested. Sadly, the behavior of those two PHP scripts is still the same. I end up with blank pages.

I'll go on studying this situation. Anyone, please feel free to share your thoughts in the meantime.

Cheers!

peteman52 commented 3 years ago

Just to be sure, did you do these steps: Create database and database user (at least SELECT, INSERT, UPDATE, DELETE privileges, CREATE, DROP for setup script, SEQUENCES for postgreSQL) Create a copy of config.default.php and rename it to config.php. Customize it and add database credentials

bfabiszewski commented 3 years ago

Also check your logs:

${APACHE_LOG_DIR}/error.log
${APACHE_LOG_DIR}/access.log

And make sure you installed apache mod-php extension.

dancesWithCycles commented 3 years ago

Hi guys, I appreciate your help very much. I have a gut feeling, that we are getting closer. Here are the commends I called when setting up the database:

sudo mysql_secure_installation CREATE DATABASE ulogger_database; GRANT ALL ON ulogger_database.* TO 'ulogger_user'@'localhost' IDENTIFIED BY 'ulogger_user' WITH GRANT OPTION; FLUSH PRIVILEGES;

I think you are right in terms of the privileges.I need the follwoing, right?

SELECT, INSERT, UPDATE, DELETE, CREATE, DROP

I hope underscores are allowed as identifiers. Is there a particular command to create a user apart from GRANT ALL ON?

Thank you again very much for making me aware of the Apache error log files. It looks like something is not OK with my configuration. This is my configuration for /var/www/ulogger-server/config.php

// PDO data source name, eg.: mysql:host=localhost;port=3307;dbname=ulogger_database;charset=utf8 mysql:unix_socket=/tmp/mysql.sock;dbname=ulogger_database;charset=utf8 // pgsql:host=localhost;port=5432;dbname=ulogger_database // sqlite:/tmp/ulogger_database.db $dbdsn = "";

// Database user name $dbuser = "ulogger_user";

// Database user password $dbpass = "ulogger_user";

// Optional table names prefix, eg. "ulogger_"

[Wed Oct 21 13:54:56.284173 2020] [php7:error] [pid 10802] [client 192.168.1.170:60090] PHP Parse error: syntax error, unexpected '=' in /var/www/ulogger-server/config.php on line 26

Line 26 is the line starting with mysql. Do you have any idea what I did wrong or what I missed? I thank you very much for you help.

Cheers!

peteman52 commented 3 years ago

Hello, frankly i'm out of touch with the newest sql-commands. But years ago this worked for me to create database and db-user:

mysql -u root -p CREATE DATABASE ulogger; CREATE USER ulogger@localhost; SET PASSWORD FOR 'ulogger'@'localhost' = PASSWORD("yoursecretpassword"); GRANT ALL PRIVILEGES ON ulogger.* TO 'ulogger'@'localhost' IDENTIFIED BY 'yoursecretpassword'; FLUSH PRIVILEGES; EXIT;

As for config.php again this works for me:

$dbdsn = "mysql:host=localhost;dbname=ulogger;charset=utf8"; $dbuser = "ulogger"; // database user $dbpass = "yoursecretpassword"; // database pass // If you have a db prefix (I think you don't) $dbprefix = "yourprefix"; // optional table names prefix, eg. "ulogger_"

Good luck!

dancesWithCycles commented 3 years ago

I have the same behavior with the configuration from peteman52 above. I double checked the mariadb settings. User and database exit with the necessary privileges everything using the "ulogger" identifier.

I still receive a blank page. Is it possible that my Apache virtual host setup is wrong? Here it comes:

cat /etc/apache2/sites-available/ulogger-server.conf <VirtualHost *:80> ServerName ulogger-server ServerAlias www.ulogger-server ServerAdmin webmaster@localhost DocumentRoot /var/www/ulogger-server ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

dancesWithCycles commented 3 years ago

It might be a PHP parsing issue. Apache error log shows this line:

[Thu Oct 22 10:09:08.093628 2020] [php7:error] [pid 759] [client 192.168.1.175:48700] PHP Parse error: syntax error, unexpected '=' in /var/www/ulogger-server/config.php on line 26

This is line 26 in the config.php file:

26 mysql:host=localhost;port=3307;dbname=ulogger;charset=utf8

Can you see anything suspicious?

peteman52 commented 3 years ago

Okay, at line 26 a ending ";" is missing and I don't know if you need the portnumber.

Furthermore I think your Apache-configuration won't work. A servername e.g. mostly looks like this www.youtube.com or more general subdomain.domain.top-level-domain or in your case maybe ulogger-server.\<some-domain>.\<some-top-level-domain>

Your servername should look like above So as guess, your configuration won't work.

But you should first add the missing semicolon and test again.

dancesWithCycles commented 3 years ago

You probably see that I am new to Apache, Mariadb and PHP. However, I guess lines 26 and 27 in the ulogger config.php file are supposed to be documentation. After I put the two slashes back into place in the way you see it in the default config file, I have access to the PHP setup script.

I set up the server and I am now able to login to the server and use it.

Again, I thank you very much helping me to access the PHP setup script. I agree, the Apache virtual host configuration will not work in real life with communication through the Internet. However, at the moment my test system is running in a local private network using IP addresses instead of domain names. Maybe I run into this problems when I try to synchronize tracks from my mobile. I hope you guys are well until then.

Cheers!