Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ampache.cfg.php" is not writable #81

Open
Slyke opened this issue Feb 5, 2022 · 7 comments
Open

"ampache.cfg.php" is not writable #81

Slyke opened this issue Feb 5, 2022 · 7 comments

Comments

@Slyke
Copy link

Slyke commented Feb 5, 2022

This could be related to #12

I have Ampache setup on Kubernetes home cluster.

On the second setup page I get 2 errors on these 2 points:

  • "ampache.cfg.php.dist" is readable
  • "ampache.cfg.php" is writable

The third step fails due to not being able to write the config file.

Running ls -ahl on the directory:

root@ampache-5cbc79c7b7-ghbj7:/var/www/config# ls -ahl
total 52K
drwxrwxrwx  1 www-data www-data   40 Feb  5 11:14 .
drwxrwxr-x 10 www-data www-data 4.0K Dec 16 21:35 ..
-rwxrwxrwx  1 www-data www-data  47K Feb  5 11:14 ampache.cfg.php.dist

Nothing interesting shows up in the pod logs. The /var/log/ampache directory is empty.

=> An empty or uninitialized MySQL volume is detected in
=> Installing MySQL ...
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following command:

'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

=> Done!
220205 11:40:51 mysqld_safe Logging to syslog.
220205 11:40:51 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql
=> Waiting for confirmation of MySQL service startup
=> Creating MySQL admin user with random password
=> Done!
========================================================================
You can now connect to this MySQL Server using:

    mysql -uadmin -pXXXXXXXXXXXXXX -h<host> -P<port>

Please remember to change the above password as soon as possible!
MySQL user 'root' has no password but only allows local connections
========================================================================
2022-02-05 11:41:03,236 INFO Set uid to user 0 succeeded
2022-02-05 11:41:03,245 INFO supervisord started with pid 1
2022-02-05 11:41:04,250 INFO spawned: 'apache2' with pid 200
2022-02-05 11:41:04,257 INFO spawned: 'cron' with pid 201
2022-02-05 11:41:04,264 INFO spawned: 'inotifywatch' with pid 202
2022-02-05 11:41:04,332 INFO spawned: 'mysql' with pid 204
2022-02-05 11:41:05,432 INFO success: apache2 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-02-05 11:41:05,434 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-02-05 11:41:05,435 INFO success: inotifywatch entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-02-05 11:41:05,436 INFO success: mysql entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

Here is my deployment. Note the initContainer setting permissions. Without this, it can't even read the ampache.cfg.php.dist file.

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ampache
  name: ampache
  namespace: entertainment
spec:
  progressDeadlineSeconds: 10
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app: ampache
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: ampache
    spec:
      initContainers:
      - name: setup-perms
        image: busybox
        command: ["/bin/sh", "-c", "chown -R 33:33 /media && chown -R 33:33 /var/lib/mysql && chown -R 33:33 /var/www/config && chown -R 33:33 /var/log/ampache && chmod -R 777 /var/www/config && chmod -R 777 /var/log/ampache"]
        volumeMounts:
        - mountPath: /media
          name: ampache-music
        - mountPath: /var/lib/mysql
          name: ampache-mysql
        - mountPath: /var/www/config
          name: ampache-config
        - mountPath: /var/log/ampache
          name: ampache-logs
      containers:
      - env:
        - name: ServerIP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        image: ampache/ampache:latest
        imagePullPolicy: IfNotPresent
        name: ampache
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        resources:
          requests:
            cpu: "10m"
            memory: "32Mi"
          limits:
            memory: "2Gi"
            cpu: "500m"
        volumeMounts:
        - mountPath: /media
          name: ampache-music
        - mountPath: /var/lib/mysql
          name: ampache-mysql
        - mountPath: /var/www/config
          name: ampache-config
        - mountPath: /var/log/ampache
          name: ampache-logs
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      terminationGracePeriodSeconds: 3
      volumes:
      - name: ampache-music
        persistentVolumeClaim:
          claimName: ampache-music-pvc
      - name: ampache-mysql
        persistentVolumeClaim:
          claimName: ampache-mysql-pvc
      - name: ampache-config
        persistentVolumeClaim:
          claimName: ampache-config-pvc
      - name: ampache-logs
        persistentVolumeClaim:
          claimName: ampache-logs-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: entertainment
  labels:
    app: ampache
  name: ampache-music-pvc
spec:
  storageClassName: ""
  volumeName: ampache-music-pv
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: entertainment
  labels:
    app: ampache
  name: ampache-mysql-pvc
spec:
  storageClassName: ""
  volumeName: ampache-mysql-pv
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: entertainment
  labels:
    app: ampache
  name: ampache-config-pvc
spec:
  storageClassName: ""
  volumeName: ampache-config-pv
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: entertainment
  labels:
    app: ampache
  name: ampache-logs-pvc
spec:
  storageClassName: ""
  volumeName: ampache-logs-pv
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
@Slyke
Copy link
Author

Slyke commented Feb 5, 2022

Executing a command as the www-data user works as expected:

root@ampache-59876cf8f-gspgg:/var/www/config# su -c "touch test" -s /bin/sh www-data
root@ampache-59876cf8f-gspgg:/var/www/config# ls -ahl
total 56K
drwxrwx--- 1 www-data www-data   48 Feb  5 11:59 .
drwxrwxr-x 1 www-data www-data 4.0K Dec 16 21:35 ..
-rwxrwx--- 1 www-data www-data  47K Feb  5 11:41 ampache.cfg.php.dist
-rw-r--r-- 1 www-data www-data    0 Feb  5 11:59 test

@Slyke
Copy link
Author

Slyke commented Feb 7, 2022

Messing around with the source code: https://github.com/ampache/ampache/blob/a93fe6a4bff4b003c98f3da7016183d03dc7e57c/src/Config/functions.php#L526

I've discovered that the is_writable function on is_writeable(__DIR__ . '/../../config/') is returning false. Still investigating as to why.

@xeruf
Copy link

xeruf commented Apr 3, 2022

Any progress on that? Note that this seems to be a duplicate of #22

@xeruf
Copy link

xeruf commented Apr 3, 2022

That check really weirds me out, even when 777 are the file permissions it reports issues...
Also, it reports a warning on the PHP max upload size even though I have configured it at 100MB, as if it wasn't reading the config properly...

@Neshura87
Copy link

Neshura87 commented Sep 12, 2022

@xeruf mounting a php.ini file with the following content as /etc/php/8.1/apache2/conf.d/custom-php.ini works for me.

[php]
max_upload_size = 100M

@TermeHansen
Copy link

TermeHansen commented Apr 9, 2023

I still have a similar issue using docker-compose as stated in you example, and yet still it complains with:

This test attempts to read config/ampache.cfg.php. If this fails the file is either not in the correct location,

from inside docker:

# ls -la /var/www/config/
total 104
drwxr-xr-x  2 www-data www-data  4096 Apr  9 20:21 .
drwxrwxr-x 10 www-data www-data  4096 Mar 28 05:24 ..
-rw-rw-rw-  1 www-data www-data 47806 Apr  9 20:21 ampache.cfg.php
-rw-r--r--  1 www-data www-data 47801 Apr  9 20:26 ampache.cfg.php.dist

using ampache/ampache:latest

What is the problem here?

Complete vanilla with no config I get stuck at :
image
image

@racoon-devel
Copy link

Have a same problem too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants