I wrote a bit of php code in my r-pi on which I installed raspbian. I would like know to protect this code from the possibility to being copied or read. I looking for a solution that crypt my directory (eg. /home/pi/myphpcode) from reading through raspbian and from reading through the SD insertion in a PC. Thanks.
You can store your home directory, or at least the encrypted program, using some
dm-crypt based technique.
dm-crypt will work on both physical devices (e.g. encrypted USB thumb drive) or a disk image, and since you are using Raspberry Pi you can use write a bit of code to store the cryptographic key in I2C EEPROM, sort of like a hardware decrypt dongle.
And if your code is not too big (<=2MB), you can store it in
dm-crypt-enabled SPI DataFlash chips also.