How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

August 19, 2019

Docker COPY failed: stat

Filed under: Linux — Tags: , — admin @ 12:30 pm

Today I am trying to use docker and saw this problem

COPY failed: stat /var/lib/docker/tmp/docker-builder749895154/docker-directory/apache/project.conf: no such file or directory

The fix for this problem is to check your .gitignore file , and add a exception for that directory

!docker-directory/

February 12, 2019

Docker Command-line completion

Filed under: Linux — Tags: , — admin @ 1:51 pm

Today installed centos7 and then docker . Wanted to run something but docker TAB didn’t work to autocomplete.

The solution is to install the bash-completion

yum -y install bash-completion

February 5, 2019

How to exclude subfolder from password protection with .htaccess

Filed under: Linux — Tags: , , , , , — admin @ 1:38 pm

So if you want to protect a website with .htaccess and .htpasswd basically you will use

AuthType Basic
AuthName “Password Protected Area”
AuthUserFile /path/.htpasswd
Require valid-user

If you want a subdirectory to be excluded from auth like .well-known , for lets encrypt then a easy way it to create a .htaccess on .well-known directory and place in it

Satisfy any

Other version is to insert into vhosts

<Location /.well-known>
    Require all granted
</Location>

Another one is to add

SetEnvIf Request_URI “path/to/excluded/directory/” allow
SetEnvIf Request_URI “path/to/excluded/file” allow
Order allow,deny
Allow from env=allow
Satisfy any

And anothe one is to add

Require expr %{REQUEST_URI} =~ m#^/.well-known/acme-challenge/#

Before require valid user

January 24, 2019

Ubuntu rc-local

Filed under: Linux — Tags: , — admin @ 11:55 am

On a ubuntu 18 I try to reboot a service after it start so I was try to use rc.local but this is no longer there .

So you create this file

/etc/systemd/system/rc-local.service

You add into it this

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Then make the file chmod +x /etc/rc.local

and add

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0

Final step is to enable the service

systemctl enable rc-local

January 16, 2019

How to deny execution of php on some directory

Filed under: Linux — Tags: , , , — admin @ 1:12 pm
Just add this on your .htaccess in that directory and php will not be executed.
# Kill PHP Execution
<Files ~ "\.ph(?:p[345]?|t|tml)$">
deny from all
</Files>
« Newer PostsOlder Posts »

Powered by WordPress