I have migrated my site to new server using Akeeba Backup.
The environment of new server is Ubuntu 16.04 LTS + nginx 1.10.0 + Joomla 3.4.8 + PHP 5.6
I can see my site running well and I can also login to admin tool, which means nginx, php-fpm, and mysql are running well.
However all files/folders in System Information -> Folder Permission are all Unwritable.
I have tried any possible solutions I can figure out, can anyone help?
php-fpm and nginx is run by www-data.
$ ps aux|grep fpm
root 1293 0.0 3.4 249700 20592 ? Ss 06:27 0:00 php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)
www-data 3397 0.2 7.5 259964 45384 ? S 06:57 0:04 php-fpm: pool www
www-data 3403 0.2 7.5 259952 45244 ? S 06:57 0:04 php-fpm: pool www
www-data 3405 0.2 9.0 269948 54716 ? S 06:57 0:03 php-fpm: pool www
$ ps aux|grep nginx
root 1348 0.0 0.2 125192 1500 ? Ss 06:27 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 1349 0.0 1.1 125584 6840 ? S 06:27 0:00 nginx: worker process
All files are 644 and folder are 775 under /usr/share/nginx/html
-rw-r--r-- 1 www-data www-data 15 May 22 15:18 404.html
-rw-r--r-- 1 www-data www-data 15 May 22 15:18 50x.html
drwxrwxr-x 10 www-data www-data 4096 May 22 15:18 administrator/
drwxrwxr-x 2 www-data www-data 4096 May 22 15:18 bin/
drwxrwxr-x 4 www-data www-data 4096 May 22 15:18 cache/
drwxrwxr-x 2 www-data www-data 4096 May 22 15:18 cli/
drwxrwxr-x 33 www-data www-data 4096 May 22 15:18 components/
-rw-rw-r-- 1 www-data www-data 3240 May 24 07:18 configuration.php
-rw-r--r-- 1 www-data www-data 586 May 24 06:59 dir.php
-rw-r--r-- 1 www-data www-data 2915 May 22 15:18 htaccess.txt
drwxrwxr-x 6 www-data www-data 4096 May 22 15:18 images/
drwxrwxr-x 2 www-data www-data 4096 May 22 15:18 includes/
-rw-r--r-- 1 www-data www-data 1211 May 22 15:18 index.php
-rw-r--r-- 1 www-data www-data 20 May 22 15:18 info.php
-rw-r--r-- 1 www-data www-data 1873 May 22 15:18 joomla.xml
drwxrwxr-x 6 www-data www-data 4096 May 22 15:18 language/
drwxrwxr-x 5 www-data www-data 4096 May 22 15:18 layouts/
drwxrwxr-x 15 www-data www-data 4096 May 22 15:18 libraries/
-rw-r--r-- 1 www-data www-data 18092 May 22 15:18 LICENSE.txt
drwxrwxrwt 2 www-data www-data 4096 May 23 14:46 logs/
drwxrwxr-x 32 www-data www-data 4096 May 22 15:18 media/
drwxrwxr-x 36 www-data www-data 4096 May 22 15:18 modules/
drwxrwxr-x 29 www-data www-data 4096 May 22 15:18 plugins/
-rw-r--r-- 1 www-data www-data 53 May 22 15:18 README.md
-rw-r--r-- 1 www-data www-data 4213 May 22 15:18 README.txt
-rw-r--r-- 1 www-data www-data 296 May 22 15:18 robots.txt
-rw-r--r-- 1 www-data www-data 842 May 22 15:18 robots.txt.dist
drwxrwxr-x 9 www-data www-data 4096 May 22 15:18 templates/
drwxrwxrwt 2 www-data www-data 4096 May 22 15:18 tmp/
-rw-r--r-- 1 www-data www-data 1690 May 22 15:18 web.config.txt
I also write PHP script to check the permission and it shows files under /usr/share/nginx/html/ are still not writable.
<?php
$root = getcwd();
echo exec('whoami')." ";
echo "$root ";
echo is_readable("/usr/share/nginx/html") ? 'yes ' : 'no ';
echo is_writable("/usr/share/nginx/html") ? 'yes ' : 'no ';
echo is_writable("/tmp") ? 'yes ' : 'no ';
?>
The result shows "www-data /usr/share/nginx/html yes no yes" even the owner is www-data:www-data and mode is 755 on /usr/share/nginx/html
If you create a test php file in your root directory with just
<?php echo exec('whoami'); ?>
and then access it with a browser, do you see www-data or is it something else?
Related
I am trying to set the permissions of my test webpage to run injunction with my nginx container. When I execute:
$ docker exec test_site_app php artisan storage:link
I get this permission error:
The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied
When I execute a $ docker exec test_site_app ls -la command on my app, I see that the permissions are:
drwxr-xr-x 15 www-data www-data 4096 Jan 20 00:33 .
drwxr-xr-x 1 root root 4096 Dec 11 07:16 ..
-rw-r--r-- 1 www-data www-data 220 Jan 20 00:33 .editorconfig
-rw-r--r-- 1 www-data www-data 829 Jan 20 00:33 .env
-rw-r--r-- 1 www-data www-data 811 Jan 20 00:33 .env.example
drwxr-xr-x 8 www-data www-data 4096 Jan 20 00:33 .git
-rw-r--r-- 1 www-data www-data 111 Jan 20 00:33 .gitattributes
-rw-r--r-- 1 www-data www-data 191 Jan 20 00:33 .gitignore
-rw-r--r-- 1 www-data www-data 181 Jan 20 00:33 .styleci.yml
-rw-r--r-- 1 www-data www-data 7133 Jan 20 00:33 CHANGELOG.md
-rw-r--r-- 1 www-data www-data 3780 Jan 20 00:33 README.md
drwxr-xr-x 7 www-data www-data 4096 Jan 20 00:33 app
-rwxr-xr-x 1 www-data www-data 1686 Jan 20 00:33 artisan
drwxr-xr-x 3 www-data www-data 4096 Jan 20 00:33 bootstrap
-rw-r--r-- 1 www-data www-data 1646 Jan 20 00:33 composer.json
-rw-r--r-- 1 www-data www-data 267526 Jan 20 00:33 composer.lock
drwxr-xr-x 2 www-data www-data 4096 Jan 20 00:33 config
drwxr-xr-x 5 www-data www-data 4096 Jan 20 00:33 database
drwxr-xr-x 2 www-data www-data 4096 Jan 20 00:33 mysql
-rw-r--r-- 1 www-data www-data 473 Jan 20 00:33 package.json
drwxr-xr-x 2 www-data www-data 4096 Jan 20 00:33 php
-rw-r--r-- 1 www-data www-data 1202 Jan 20 00:33 phpunit.xml
drwxr-xr-x 2 www-data www-data 4096 Jan 20 00:33 public
drwxr-xr-x 6 www-data www-data 4096 Jan 20 00:33 resources
drwxr-xr-x 2 www-data www-data 4096 Jan 20 00:33 routes
-rw-r--r-- 1 www-data www-data 563 Jan 20 00:33 server.php
drwxr-xr-x 5 www-data www-data 4096 Jan 20 00:33 storage
drwxr-xr-x 4 www-data www-data 4096 Jan 20 00:33 tests
drwxr-xr-x 44 www-data www-data 4096 Jan 20 00:33 vendor
-rw-r--r-- 1 www-data www-data 559 Jan 20 00:33 webpack.mix.js
However, when I run whoami on each container (app and nginx) I see this:
$ docker exec test_site_app whoami
www
$ docker exec test_site_nginx whoami
root
I specifically created the user www in my app within my Dockerfile:
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
COPY . /var/www
COPY --chown=www:www . /var/www
USER www
However, my Nginx uses nobody within the nginx.conf because if I try to use www-data I get this error:
getpwnam("www-data") failed in /etc/nginx/nginx.conf:1 nginx: [emerg]
getpwnam("www-data") failed in /etc/nginx/nginx.conf:1
So already here I can see the permission issues but I really am not sure how to fix this. All of my Laravel files are chown -R www-data:www-data before I run $ docker-compose up --build -d.
To create my environment, here are my configurations hosted via Gist.
How can I fix this permission issue?
I am running Wordpress on a Debian Based (Raspbian Buster) LEMP server. For the most part, everything is working fine except some problems with uploading photos using the command line interface. I have many pictures in my servers ~/Pictures folder that I am trying to upload to wordpress using the command line interface.
I navigate to the root directory of my wordpress installation and run the following command:
wp media import ~/Pictures/*.jpg
To which I get the following errors:
Warning: Unable to import file '/home/Danran/Pictures/img_0754.jpg'. Reason: The uploaded file could not be moved to wp-content/uploads/2020/03.
for each corresponding file. I am fairly certain that this is some sort of permissions error, but because I am a noob, I don't want to risk tinkering around with permissions in my wordpress directory without some sort of guidance by a pro.
How can I get rid of this error and successfully import my photos to wordpressing using the wp-cli?
could you please verify that you have write permissions in the uploads directory?
if u are using apache, normally what I do is set the www-data group as the owner of that directory
chown -R www-data:www-data /var/www/wordpress/wp-content/uploads
but, if what you want is to know if it is a permissions problem, simply set the permissions to 777 of that directory, and try to upload the files again... if you succeed, then it is a problem permissions, and setting them to 777 grants the cli access to that folder.
chmod 777 /var/www/wordpress/wp-content/uploads
Once you upload all of your photos with the CLI, you can change the permissions back to their original with chmod -R 755 on the same uploads folder you originally modified.
However, I usually set the permissions as follows ..
Directories: 644
Files: 755
find /var/www/wordpress/ -type f -exec chmod 644 {} \;
find /var/www/wordpress/ -type d -exec chmod 755 {} \;
EDIT1
Compare it with yours:
/var/www/wordpress/
root#www:/var/www# ls -l
total 212
-rw-r--r-- 1 www-data nogroup 420 Nov 30 2017 index.php
-rw-r--r-- 1 www-data nogroup 19935 Jan 1 2019 license.txt
-rw-r--r-- 1 www-data nogroup 7368 Sep 2 2019 readme.html
-rw-r--r-- 1 www-data nogroup 6939 Sep 2 2019 wp-activate.php
drwxr-xr-x 9 www-data nogroup 4096 Dec 18 17:16 wp-admin
-rw-r--r-- 1 www-data nogroup 369 Nov 30 2017 wp-blog-header.php
-rw-r--r-- 1 www-data nogroup 2283 Jan 20 2019 wp-comments-post.php
-rw-r--r-- 1 www-data nogroup 2898 Jan 7 2019 wp-config-sample.php
-rw-r--r-- 1 www-data root 3310 Jan 7 11:54 wp-config.php
drwxr-xr-x 8 www-data nogroup 4096 Jan 7 15:17 wp-content
-rw-r--r-- 1 www-data nogroup 3955 Oct 10 18:52 wp-cron.php
drwxr-xr-x 20 www-data nogroup 12288 Dec 18 17:16 wp-includes
-rw-r--r-- 1 www-data nogroup 2504 Sep 2 2019 wp-links-opml.php
-rw-r--r-- 1 www-data nogroup 3326 Sep 2 2019 wp-load.php
-rw-r--r-- 1 www-data nogroup 47597 Dec 9 08:30 wp-login.php
-rw-r--r-- 1 www-data nogroup 8483 Sep 2 2019 wp-mail.php
-rw-r--r-- 1 www-data nogroup 19120 Oct 15 11:37 wp-settings.php
-rw-r--r-- 1 www-data nogroup 31112 Sep 2 2019 wp-signup.php
-rw-r--r-- 1 www-data nogroup 4764 Nov 30 2017 wp-trackback.php
-rw-r--r-- 1 www-data nogroup 3150 Jul 1 2019 xmlrpc.php
/var/www/wordpress/wp-content
root#www:/var/www/wp-content# ls -l
total 28
drwxr-xr-x 3 www-data www-data 4096 Jan 7 14:52 cache
-rw-r--r-- 1 www-data nogroup 28 Jan 8 2012 index.php
drwxr-xr-x 2 www-data www-data 4096 Jan 7 11:55 languages
drwxr-xr-x 11 www-data nogroup 4096 Jan 8 16:24 plugins
drwxr-xr-x 4 www-data nogroup 4096 Jan 7 13:51 themes
drwxr-xr-x 2 www-data www-data 4096 Jan 7 14:52 upgrade
drwxr-xr-x 6 www-data www-data 4096 Jan 7 14:50 uploads
I'm running a Laravel 5.7 app in the Ngnix server. All my files and directory permissions are set to www-data:www-data user:group. The problem is when I tried to run following PHP artisan command from the code using PHP exec() function, it is giving permission denied issue to create file under storage/log/ folder, which is already 777 and the queue was never executed.
$file_name = "queue-log";
exec('php artisan queue:work --tries=3 --stop-when-empty > storage/logs/'.$file_name.'.log &',$array);
When I simply try to do it by CLI, it works normally. My php.ini is not in safe mode and exec() is not under disabled functions list and exec("whoami") returns www-data when debugging from the browser.
Any clues what is going on?
The output of ls -la storage is
drwxrwxrwx 6 www-data www-data 4096 Jun 13 11:30 .
drwxrwxr-x 14 www-data www-data 4096 Jul 3 10:39 ..
drwxrwxrwx 5 www-data www-data 4096 Mar 22 14:58 app
drwxrwxrwx 2 www-data www-data 4096 Jul 19 07:04 debugbar
drwxrwxrwx 6 www-data www-data 4096 Jun 12 23:13 framework
drwxrwxrwx 2 www-data www-data 4096 Jul 23 04:40 logs
and the output of ls -la storage/logs
drwxrwxrwx 2 www-data www-data 4096 Jul 23 04:40 .
drwxrwxrwx 6 www-data www-data 4096 Jun 13 11:30 ..
-rwxrwxrwx 1 www-data www-data 96950 Jun 13 05:07 laravel-2019-06-13.log
I have deployed my Laravel application on DigitalOcean (without any third party packge usage). The application is functioning fine, except for uploading of files by the users.
I have installed LEMP stack by following the guide of DevMarketer (YouTube playlist).
Scenario:
I want to upload the file and store in my public directory. But, doing so, I get the error as Permission Denied.
Here's the code of directory that will get created it if not exist:
$path = public_path() . '/email-attachments/';
if (! file_exists($path)) {
mkdir($path, 0775, true);
}
On SSHing on to the server as root, I ran the following command to check the permission of the files and folders:
root#host-pc:~# ls -la /var/www/laravel
total 456
drwxrwsr-x 12 www-data www-data 4096 Aug 21 09:45 .
drwxrwsr-x 4 www-data www-data 4096 Aug 18 07:13 ..
-rwxrwxr-x 1 www-data www-data 665 Aug 21 08:23 .env
-rw-rwSr-- 1 www-data www-data 521 Aug 21 09:45 .env.example
-rw-rwSr-- 1 www-data www-data 111 Aug 21 09:45 .gitattributes
-rw-rwSr-- 1 www-data www-data 157 Aug 21 09:45 .gitignore
drwxrwsr-x 8 www-data www-data 4096 Aug 21 09:45 app
-rw-rwSr-- 1 www-data www-data 1646 Aug 21 09:45 artisan
drwxrwsr-x 3 www-data www-data 4096 Aug 21 09:45 bootstrap
-rw-rwSr-- 1 www-data www-data 1496 Aug 21 09:45 composer.json
-rw-rwSr-- 1 www-data www-data 150371 Aug 21 09:45 composer.lock
drwxrwsr-x 2 www-data www-data 4096 Aug 21 09:45 config
drwxrwsr-x 5 www-data www-data 4096 Aug 21 09:45 database
-rw-rwSr-- 1 www-data www-data 1063 Aug 21 09:45 package.json
-rw-rwSr-- 1 www-data www-data 1100 Aug 21 09:45 phpunit.xml
drwxrwsr-x 10 www-data www-data 4096 Aug 21 09:45 public
-rwxrwxr-x 1 www-data www-data 440 Aug 21 06:27 queue_worker.log
drwxrwsr-x 5 www-data www-data 4096 Aug 18 07:56 resources
drwxrwsr-x 2 www-data www-data 4096 Aug 21 09:45 routes
-rw-rwSr-- 1 www-data www-data 563 Aug 21 09:45 server.php
drwxrwsr-x 6 www-data www-data 4096 Aug 18 07:56 storage
drwxrwsr-x 4 www-data www-data 4096 Aug 21 09:45 tests
drwxrwsr-x 39 www-data www-data 4096 Aug 21 05:58 vendor
-rw-rwSr-- 1 www-data www-data 1439 Aug 21 09:45 webpack.mix.js
-rw-rwSr-- 1 www-data www-data 212974 Aug 21 09:45 yarn.lock
Following is the result of ps -ef | grep nginx
root#host-pc:~# ps -ef | grep nginx
root 14862 1 0 11:45 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 14863 14862 0 11:45 ? 00:00:00 nginx: worker process
root 15489 12952 0 12:19 pts/0 00:00:00 grep --color=auto nginx
Following is the result of ps -ef | grep php
root#host-pc:~# ps -ef | grep php
root 10173 9901 0 05:05 ? 00:00:16 php /var/www/laravel/artisan queue:work --tries=5
root 10174 9901 0 05:05 ? 00:00:15 php /var/www/laravel/artisan queue:work --tries=5
root 10175 9901 0 05:05 ? 00:00:16 php /var/www/laravel/artisan queue:work --tries=5
root 10176 9901 0 05:05 ? 00:00:16 php /var/www/laravel/artisan queue:work --tries=5
root 10177 9901 0 05:05 ? 00:00:15 php /var/www/laravel/artisan queue:work --tries=5
root 10178 9901 0 05:05 ? 00:00:15 php /var/www/laravel/artisan queue:work --tries=5
root 10179 9901 0 05:05 ? 00:00:15 php /var/www/laravel/artisan queue:work --tries=5
root 10180 9901 0 05:05 ? 00:00:16 php /var/www/laravel/artisan queue:work --tries=5
root 15251 1 0 11:50 ? 00:00:00 php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)
www-data 15255 15251 0 11:50 ? 00:00:02 php-fpm: pool www
www-data 15256 15251 0 11:50 ? 00:00:02 php-fpm: pool www
root 15495 12952 0 12:21 pts/0 00:00:00 grep --color=auto php
I don't know what is the mistake that I am doing (I know it must be a silly one), but I couldn't find the solution yet.
Please help me out with this. Thanks.
If you change this
$path = public_path() . '/email-attachments/';
To this
$path = public_path('email-attachments/');
Hopefully, This will help you.
$path = base_path() . '/public/email-attachments';
mkdir($path, 0755, true);
I recorded a video https://youtu.be/dmezVzASr5A
I have:
linux ubuntu 16.04 (Lubuntu)
nginx 1.10
php7.0-fpm
php7.0
mysql 5.7
I did:
created domain /etc/hosts (test2.test)
created virtual hosts withing sites-available folder (test2.test file)
restarted, reloaded nginx server (sudo service nginx stop...restart...reload)
created symlink ln -s /etc/nginx/sites-available/test2.test /etc/nginx/sites-enabled/
symlink proof:
dima#dima-Lenovo-G50-30:~/www/nginx/test2.ru$ ls -ls /etc/nginx/sites-enabled
total 0
0 lrwxrwxrwx 1 root root 34 май 21 16:33 default -> /etc/nginx/sites-available/default
0 lrwxrwxrwx 1 root root 37 май 21 16:44 test2.test -> /etc/nginx/sites-available/test2.test
Problem is when i try to open in browser http://test2.test, i get:
404 Not Found
nginx/1.10.0 (Ubuntu)
This files are not opening:
index.html
test.html
index.php
within /var/www/html i have info.php with content <?php echo phpinfo(); ?>. http://localhost/info.php successfully displays php info.
My permissions:
dima#dima-Lenovo-G50-30:~/www/nginx/test2.ru$ ls -la
total 44
drwxr-xr-x 2 www-data www-data 4096 май 21 16:59 .
drwxrwxr-x 4 dima dima 4096 май 21 13:14 ..
-rw-rw-r-- 1 www-data www-data 111 фев 21 13:34 index.html
-rw-rw-r-- 1 www-data www-data 26 май 21 13:15 index.php
-rwxr-xr-x 1 www-data www-data 5 май 21 16:59 test.html
dima#dima-Lenovo-G50-30:~/www/nginx/test2.ru$
My virtual hosts:
server {
listen 80;
listen [::]:80;
server_name test2.test;
root /home/dima/www/nginx/test2.ru;
index index.html;
location / {
try_files $uri $uri/ =404;
#autoindex on;
}
}
nginx logs:
error.log.1:
many errors like:
2016/05/26 08:46:28 [crit] 1066#1066: *1 stat() "/home/dima/www/nginx/test2.ru/" failed (13: Permission denied), client: 127.0.0.1, server: test2.test, request: "GET / HTTP/1.1", host: "test2.test"
ls -la:
dima#dima-Lenovo-G50-30:~/www/nginx$ ls -la
total 16
drwxrwxr-x 4 dima dima 4096 май 21 13:14 .
drwxrwxr-x 10 dima dima 4096 май 21 12:52 ..
drwxrwxr-x 5 dima dima 4096 май 21 12:52 test1.ru
drwxr-xr-x 2 www-data www-data 4096 май 21 16:59 test2.ru
dima#dima-Lenovo-G50-30:~/www/nginx$
within test2.ru folder:
dima#dima-Lenovo-G50-30:~/www/nginx/test2.ru$ ls -la
total 44
drwxr-xr-x 2 www-data www-data 4096 май 21 16:59 .
drwxrwxr-x 4 dima dima 4096 май 21 13:14 ..
-rw-rw-r-- 1 www-data www-data 111 фев 21 13:34 index.html
-rw-rw-r-- 1 www-data www-data 26 май 21 13:15 index.php
-rwxr-xr-x 1 www-data www-data 5 май 21 16:59 test.html
dima#dima-Lenovo-G50-30:~/www/nginx/test2.ru$
UPD I have fixed. It was permissions problem. I changed some permisisions and it worked, but i don't know and remvemebr exactly what i did, but it works
Maybe you can try to give execute access to the files in that /home/dima/www/nginx/test2.ru folder. Nginx needs to execute the php files, not only read the files.