YII2 assets directory permission denied - yii2

I have a project from git, what says:
Exception (Invalid Configuration) 'yii\base\InvalidConfigException'
with message 'The directory is not writable by the Web process:
/var/www/xxx.lh/web/assets'
In the web directory:
drwxr-sr-x 7 vaso vaso 4096 márc 31 08:22 .
drwxr-sr-x 17 vaso vaso 4096 márc 31 08:25 ..
drwxr-sr-x 2 vaso vaso 4096 márc 31 08:22 assets
drwxr-sr-x 2 vaso vaso 4096 márc 31 08:22 css
-rw-r--r-- 1 vaso vaso 318 márc 31 08:22 favicon.ico
drwxr-sr-x 2 vaso vaso 4096 márc 31 08:22 fonts
-rw-r--r-- 1 vaso vaso 199 márc 31 08:22 .htaccess
drwxr-sr-x 2 vaso vaso 4096 márc 31 08:22 images
-rw-r--r-- 1 vaso vaso 367 márc 31 08:22 index.php
-rw-r--r-- 1 vaso vaso 498 márc 31 08:22 index-test.php
drwxr-sr-x 3 vaso vaso 4096 márc 31 08:22 js
-rw-r--r-- 1 vaso vaso 23 márc 31 08:22 robots.txt
The nginx.conf starts with this:
user vaso vaso;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
....
Checking the processes:
ps -aux | grep nginx
root 13222 0.0 0.0 144508 3176 ? Ss 08:17 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
vaso 13223 0.0 0.1 147008 11256 ? S 08:17 0:00 nginx: worker process
vaso 13224 0.0 0.0 146804 7856 ? S 08:17 0:00 nginx: worker process
vaso 13225 0.0 0.0 146804 7856 ? S 08:17 0:00 nginx: worker process
vaso 13226 0.0 0.0 146804 7856 ? S 08:17 0:00 nginx: worker process
vaso 13227 0.0 0.0 146804 7856 ? S 08:17 0:00 nginx: worker process
vaso 13228 0.0 0.0 146804 7856 ? S 08:17 0:00 nginx: worker process
What can be the problem? Temporary I can set 777 for that directory, but that is not a solution, because in production 755 has set. 775 does not helps also.

Related

/var/lib/mysql shows files created by systemd-coredump for mysql volume

/var/lib/mysql shows files created by systemd-coredump, while running mysql 8.0.31 docker image. Is this an issue, not sure if the database is created properly in the first place?
volumes:
- ./data/keycloak/mysql:/var/lib/mysql
ls -l data/keycloak/mysql/
total 87400
-rw-r----- 1 systemd-coredump systemd-coredump 196608 Oct 19 17:25 '#ib_16384_0.dblwr'
-rw-r----- 1 systemd-coredump systemd-coredump 8585216 Oct 19 15:42 '#ib_16384_1.dblwr'
drwxr-x--- 2 systemd-coredump systemd-coredump 4096 Oct 19 17:23 '#innodb_redo'
drwxr-x--- 2 systemd-coredump systemd-coredump 4096 Oct 19 17:34 '#innodb_temp'
-rw-r----- 1 systemd-coredump systemd-coredump 56 Oct 19 15:42 auto.cnf
-rw-r----- 1 systemd-coredump systemd-coredump 3026699 Oct 19 15:42 binlog.000001
-rw-r----- 1 systemd-coredump systemd-coredump 180 Oct 19 15:48 binlog.000002
-rw-r----- 1 systemd-coredump systemd-coredump 180 Oct 19 15:55 binlog.000003
-rw-r----- 1 systemd-coredump systemd-coredump 180 Oct 19 15:58 binlog.000004
-rw-r----- 1 systemd-coredump systemd-coredump 180 Oct 19 17:22 binlog.000005
-rw-r----- 1 systemd-coredump systemd-coredump 180 Oct 19 17:34 binlog.000006
-rw-r----- 1 systemd-coredump systemd-coredump 96 Oct 19 17:23 binlog.index
-rw------- 1 systemd-coredump systemd-coredump 1676 Oct 19 15:42 ca-key.pem
-rw-r--r-- 1 systemd-coredump systemd-coredump 1112 Oct 19 15:42 ca.pem
-rw-r--r-- 1 systemd-coredump systemd-coredump 1112 Oct 19 15:42 client-cert.pem
-rw------- 1 systemd-coredump systemd-coredump 1680 Oct 19 15:42 client-key.pem
-rw-r----- 1 systemd-coredump systemd-coredump 3540 Oct 19 17:34 ib_buffer_pool
-rw-r----- 1 systemd-coredump systemd-coredump 12582912 Oct 19 17:34 ibdata1
drwxr-x--- 2 systemd-coredump systemd-coredump 4096 Oct 19 15:42 mysql
-rw-r----- 1 systemd-coredump systemd-coredump 31457280 Oct 19 17:23 mysql.ibd
lrwxrwxrwx 1 systemd-coredump systemd-coredump 27 Oct 19 17:23 mysql.sock -> /var/run/mysqld/mysqld.sock
drwxr-x--- 2 systemd-coredump systemd-coredump 4096 Oct 19 15:42 performance_schema
-rw------- 1 systemd-coredump systemd-coredump 1680 Oct 19 15:42 private_key.pem
-rw-r--r-- 1 systemd-coredump systemd-coredump 452 Oct 19 15:42 public_key.pem
-rw-r--r-- 1 systemd-coredump systemd-coredump 1112 Oct 19 15:42 server-cert.pem
-rw------- 1 systemd-coredump systemd-coredump 1676 Oct 19 15:42 server-key.pem
drwxr-x--- 2 systemd-coredump systemd-coredump 4096 Oct 19 15:42 sso#002dkeycloak
drwxr-x--- 2 systemd-coredump systemd-coredump 4096 Oct 19 15:42 sys
-rw-r----- 1 systemd-coredump systemd-coredump 16777216 Oct 19 17:25 undo_001
-rw-r----- 1 systemd-coredump systemd-coredump 16777216 Oct 19 17:25 undo_002
I had some trouble, binlog.* can be deleted and also you need to configure logs size in mysql config, like
expire_logs_days=10
# from MySql 8
# binlog_expire_log_seconds=864000
max_binlog_size=1024M
You can set those parameters in docker-compose file in command parameter like
mysql:
image: mysql:8
container_name: "my-mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
volumes:
- mysql-volume:/var/lib/mysql
command: ['--default-authentication-plugin=mysql_native_password', '--binlog-row-event-max-size=1024M', '--binlog_expire_logs_seconds=864000']
and then re-build container.

Unable to remove a container using machinectl

I pulled a nixos container and now want to remove it.
I enter:
sudo machinectl remove nixos-21-tar
But the return message is:
Could not remove image: Access denied
If I list the images I get:
$ machinectl list-images
NAME TYPE RO USAGE CREATED MODIFIED
debian directory no n/a n/a n/a
nixos-21-tar directory no n/a n/a n/a
EDIT:
I think the image has been corrupted and the owner/group is wrong:
sudo tree /var/lib/machines/nixos-21-tar/
/var/lib/machines/nixos-21-tar/
└── var
└── empty
sudo ls -alR /var/lib/machines/nixos-21-tar/
/var/lib/machines/nixos-21-tar:
total 12
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 .
drwxrwxrwx 4 root root 4096 Apr 21 17:23 ..
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 var
/var/lib/machines/nixos-21-tar/var:
total 12
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 .
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 ..
dr-xr-xr-x 2 root root 4096 Mar 11 17:29 empty
/var/lib/machines/nixos-21-tar/var/empty:
total 8
dr-xr-xr-x 2 root root 4096 Mar 11 17:29 .
drwxrwxrwx 3 699334656 699334656 4096 Apr 18 18:38 ..

Ownership of datadir is reset to mysql:mysql after every reboot

I'm using MariaDB 10.5.9-1 on Manjaro 5.10.23-1.
I initialized mariadb database directory using this command:
$ sudo mariadb-install-db --user=shaouai --basedir=/usr --datadir=/var/lib/mysql
After data directory initialization, permissions and ownership of /var/lib/mysql:
$ ls -ld /var/lib/mysql
drwx------ 5 shaouai root 4096 Apr 10 00:08 mysql
$ ls -lh /var/lib/mysql
total 109M
-rw-rw---- 1 shaouai shaouai 24K Apr 10 00:08 aria_log.00000001
-rw-rw---- 1 shaouai shaouai 52 Apr 10 00:08 aria_log_control
-rw-rw---- 1 shaouai shaouai 972 Apr 10 00:08 ib_buffer_pool
-rw-rw---- 1 shaouai shaouai 12M Apr 10 00:08 ibdata1
-rw-rw---- 1 shaouai shaouai 96M Apr 10 00:08 ib_logfile0
drwx------ 2 shaouai shaouai 4.0K Apr 10 00:08 mysql
drwx------ 2 shaouai shaouai 4.0K Apr 10 00:08 performance_schema
drwx------ 2 shaouai shaouai 4.0K Apr 10 00:08 test
And there's one another directory /run/mysqld, which file mysqld.sock resides in by default when server is up and running, has permissions and ownership:
$ ls -ld /run/mysqld/
drwxr-xr-x 2 shaouai shaouai 60 Apr 10 08:31 /run/mysqld/
I have no idea when /run/mysqld was created, maybe the first time server started successfully.
mysqld_safe --datadir=/var/lib/mysql can start server successfully.
But the problem is, after every reboot, the permissions and ownership of /var/lib/mysql and /run/mysqld was reset to mysql:mysql :
$ ls -ld /var/lib/mysql
drwx------ 5 mysql mysql 4096 Apr 10 00:08 mysql
$ ls -lh /var/lib/mysql
total 109M
-rw-rw---- 1 shaouai shaouai 24K Apr 10 00:08 aria_log.00000001
-rw-rw---- 1 shaouai shaouai 52 Apr 10 00:08 aria_log_control
-rw-rw---- 1 shaouai shaouai 972 Apr 10 00:08 ib_buffer_pool
-rw-rw---- 1 shaouai shaouai 12M Apr 10 00:08 ibdata1
-rw-rw---- 1 shaouai shaouai 96M Apr 10 00:08 ib_logfile0
drwx------ 2 shaouai shaouai 4.0K Apr 10 00:08 mysql
drwx------ 2 shaouai shaouai 4.0K Apr 10 00:08 performance_schema
drwx------ 2 shaouai shaouai 4.0K Apr 10 00:08 test
$ ls -ld /run/mysqld/
drwxr-xr-x 2 mysql mysql 60 Apr 10 08:31 /run/mysqld/
Thus due to various "permission denied", MariaDB server failed to start.
There's one question totally the same as mine.
Here is full output of systemctl cat mariadb.service.
I'm not sure why you changed the user. It may not be a good idea. But assuming there is a good reason, below explains your situtation:
It looks like the mysqld_safe may have changed the permissions. If you start this way for testing add --user=shaouai to the arguments.
To allow systemd to default start as the user shaouai
systemctl edit mariadb.service
Add:
[Service]
User=shaouai
Group=shaouai
Then:
chown -R shaouai: /var/lib/mysql /run/mysqld/
Then systemctl restart mariadb.service.
This will start the service as this user instead of the default mysql user.

Can't connect to local MySQL Server with homebrew

I have installed the MySQL-Server with homebrew before on another User on my Macbook Pro, but I must change the User and now I can't start the MySQL server:
$ mysql.server start
Starting MySQL
./usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 144:
/usr/local/var/mysql/Stefans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 144:
/usr/local/var/mysql/Stefans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 198:
/usr/local/var/mysql/Stefans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/5.7.22/bin/mysqld_safe: line 144:
/usr/local/var/mysql/Stefans-MacBook-Pro.local.err: Permission denied
ERROR! The server quit without updating PID file
(/usr/local/var/mysql/Stefans-MacBook-Pro.local.pid).
The User "Stefan" doesn't exist anymore. Maybe the rights on /usr/local/var/mysql are not correct, but I am unsure about what I can do to fix it.
The rights are:
$ sudo ls -lah /usr/local/var/mysql/
Password:
total 221392
drwxr-xr-x 20 501 admin 640B 25 Apr 15:47 .
drwxrwxr-x 8 501 admin 256B 20 Apr 10:12 ..
-rw-r----- 1 501 admin 60K 25 Apr 15:47 Stefans-MacBook-Pro.local.err
-rw-r----- 1 501 admin 56B 20 Apr 10:12 auto.cnf
-rw------- 1 501 admin 1,6K 20 Apr 10:12 ca-key.pem
-rw-r--r-- 1 501 admin 1,1K 20 Apr 10:12 ca.pem
-rw-r--r-- 1 501 admin 1,1K 20 Apr 10:12 client-cert.pem
-rw------- 1 501 admin 1,6K 20 Apr 10:12 client-key.pem
-rw-r----- 1 501 admin 464B 25 Apr 15:47 ib_buffer_pool
-rw-r----- 1 501 admin 48M 25 Apr 15:47 ib_logfile0
-rw-r----- 1 501 admin 48M 20 Apr 10:12 ib_logfile1
-rw-r----- 1 501 admin 12M 25 Apr 15:47 ibdata1
drwxr-x--- 77 501 admin 2,4K 20 Apr 10:12 mysql
drwxr-x--- 90 501 admin 2,8K 20 Apr 10:12 performance_schema
-rw------- 1 501 admin 1,6K 20 Apr 10:12 private_key.pem
-rw-r--r-- 1 501 admin 452B 20 Apr 10:12 public_key.pem
-rw-r--r-- 1 501 admin 1,1K 20 Apr 10:12 server-cert.pem
-rw------- 1 501 admin 1,6K 20 Apr 10:12 server-key.pem
drwxr-x--- 108 501 admin 3,4K 20 Apr 10:12 sys
drwxr-x--- 25 501 admin 800B 20 Apr 12:00 textspinner
I have also tried to reinstall MySQL server but it doesn't work.
How can I fix this?
Ok, with this post i could fix this:
https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks

apache webserver don't manage static files

I'm installing Dolibarr istance for my company. I installed it with LAMP. Now, on localhost everything works fine and i have the classic interface.
After this. i Build a virtualhost like this, to point the site on erp.varesenext.it
<VirtualHost *:80>
# 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.
ServerAdmin webmaster#localhost
ServerName erp.varesenext.it
ServerAlias www.erp.varesenext.it
DocumentRoot /var/www/html/dolibarr1/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Then, i fix the /etc/hosts file:
40.71.186.112 erp.varesenext.it
to point that site on my webserver.
All works fine, but when i go to my browser, it shows me only text, without the app inter face...like this
Any help??
This is the folder dolibarr1 inside /var/www/html/dolibarr1
drwxrwxr-x 11 www-data www-data 4096 May 30 08:52 accountancy
drwxrwxr-x 9 www-data www-data 4096 May 30 08:52 adherents
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 admin
drwxrwxr-x 4 www-data www-data 4096 May 30 08:52 api
drwxrwxr-x 2 www-data www-data 4096 May 30 08:52 asterisk
drwxrwxr-x 2 www-data www-data 4096 May 30 08:52 barcode
drwxrwxr-x 4 www-data www-data 4096 May 30 08:52 bookmarks
drwxrwxr-x 19 www-data www-data 4096 Mar 11 22:40 build
drwxrwxr-x 9 www-data www-data 4096 May 30 08:52 cashdesk
drwxrwxr-x 4 www-data www-data 4096 May 30 08:52 categories
-rwxrwxr-x 1 www-data www-data 213138 Feb 2 01:24 ChangeLog
drwxrwxr-x 7 www-data www-data 4096 May 30 08:52 comm
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 commande
-rwxrwxr-x 1 www-data www-data 2072 Jan 24 13:32 composer.json
-rwxrwxr-x 1 www-data www-data 63478 Jan 24 13:32 composer.lock
drwxrwxr-x 16 www-data www-data 4096 May 30 08:52 compta
drwxrwxr-x 2 www-data www-data 4096 May 30 10:09 conf
drwxrwxr-x 4 www-data www-data 4096 May 30 08:52 contact
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 contrat
-rwxrwxr-x 1 www-data www-data 35147 Jan 24 13:32 COPYING
-rwxrwxr-x 1 www-data www-data 9700 Jan 24 13:32 COPYRIGHT
drwxrwxr-x 14 www-data www-data 4096 May 30 08:52 core
drwxrwxr-x 4 www-data www-data 4096 May 30 08:52 cron
drwxrwxr-x 2 www-data www-data 4096 May 30 08:52 custom
drwxrwxr-x 8 www-data www-data 4096 Mar 11 22:35 dev
drwxrwxr-x 5 www-data www-data 4096 Mar 11 22:35 doc
-rwxrwxr-x 1 www-data www-data 610 Jan 24 13:32 Dockerfile
-rwxrwxr-x 1 www-data www-data 6359 May 30 09:44 document.php
drwxrwxr-x 14 www-data www-data 4096 May 30 11:07 documents
drwxrwxr-x 7 www-data www-data 4096 Jan 24 17:47 dolibarr-4.0.4
drwxrwxr-x 6 www-data www-data 4096 May 30 08:52 don
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 ecm
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 expedition
drwxrwxr-x 7 www-data www-data 4096 May 30 08:52 expensereport
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 exports
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 externalsite
-rwxrwxr-x 1 www-data www-data 2238 May 30 09:44 favicon.ico
drwxrwxr-x 6 www-data www-data 4096 May 30 08:52 fichinter
-rwxrwxr-x 1 www-data www-data 17147 May 30 09:44 filefunc.inc.php
drwxrwxr-x 9 www-data www-data 4096 May 30 08:52 fourn
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 ftp
drwxrwxr-x 4 www-data www-data 4096 May 30 08:52 holiday
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 hrm
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 imports
drwxrwxr-x 26 www-data www-data 4096 May 30 08:52 includes
-rwxrwxr-x 1 www-data www-data 26543 May 30 09:44 index.php
drwxrwxr-x 7 www-data www-data 4096 May 30 08:52 install
-rwxrwxr-x 1 www-data www-data 91 Jan 24 13:32 INSTALL
drwxrwxr-x 83 www-data www-data 4096 May 30 08:52 langs
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 livraison
drwxrwxr-x 4 www-data www-data 4096 May 30 08:52 loan
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 mailmanspip
-rwxrwxr-x 1 www-data www-data 97173 May 30 09:44 main.inc.php
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 margin
-rwxrwxr-x 1 www-data www-data 11689 May 30 09:44 master.inc.php
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 multicurrency
drwxrwxr-x 6 www-data www-data 4096 May 30 08:52 opensurvey
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 paybox
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 paypal
drwxrwxr-x 4 www-data www-data 4096 May 30 08:52 printing
drwxrwxr-x 10 www-data www-data 4096 May 30 08:52 product
drwxrwxr-x 8 www-data www-data 4096 May 30 08:52 projet
drwxrwxr-x 13 www-data www-data 4096 May 30 08:52 public
-rwxrwxr-x 1 www-data www-data 6086 Jan 24 13:32 README-FR.md
-rwxrwxr-x 1 www-data www-data 6953 Mar 7 14:46 README.md
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 resource
-rwxrwxr-x 1 www-data www-data 115 May 30 09:44 robots.txt
drwxrwxr-x 15 www-data www-data 4096 Jun 5 2015 scripts
drwxrwxr-x 9 www-data www-data 4096 May 30 08:52 societe
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 supplier_proposal
drwxrwxr-x 2 www-data www-data 4096 May 30 08:52 support
drwxrwxr-x 5 www-data www-data 4096 May 30 08:52 theme
drwxrwxr-x 6 www-data www-data 4096 May 30 08:52 user
-rwxrwxr-x 1 www-data www-data 6936 May 30 09:44 viewimage.php
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 webservices
drwxrwxr-x 3 www-data www-data 4096 May 30 08:52 websites