Friday, November 9, 2007

Installation of PHP-Screw 1.5 with Apache 2.2.6 and PHP-5.2.3

Apache 2.2.6 Installation
[root@myserver src]# pwd
/usr/local/src
[root@myserver src]# cd httpd-2.2.6
[root@myserver httpd-2.2.6]#

[root@myserver httpd-2.2.6]# ./configure --enable-so --prefix=/usr/local/apache2
[root@myserver httpd-2.2.6]# make
[root@myserver httpd-2.2.6]# make install

PHP-5.2.3 installation
[root@myserver src]# pwd
/usr/local/src
[root@myserver src]# cd php-5.2.3
[root@myserver php-5.2.3]#

[root@myserver php-5.2.3]# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib
[root@myserver php-5.2.3]# make
[root@myserver php-5.2.3]# make install

Configured Apache for PHP 5
# vi /usr/local/apache2/conf/httpd.conf
Added the following 3 lines

LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps


PHP Screw Installation
[root@myserver src]# pwd
/usr/local/src
[root@myserver src]# cd php_screw-1.5
[root@myserver php_screw-1.5]# phpize
[root@myserver php_screw-1.5]# ./configure
[root@myserver php_screw-1.5]# vi my_screw.h

Replaced
“pm9screw_mycryptkey” with “pm9screw_myownkey” . This is the encryption key that will be used by Screw for encryption

[root@myserver php_screw-1.5]# # make
/bin/sh /usr/local/src/php_screw-1.5/libtool --mode=compile gcc -I. -I/usr/local/src/php_screw-1.5 -DPHP_ATOM_INC -I/usr/local/src/php_screw-1.5/include -I/usr/local/src/php_screw-1.5/main -I/usr/local/src/php_screw-1.5 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/php_screw-1.5/php_screw.c -o php_screw.lo
mkdir .libs
gcc -I. -I/usr/local/src/php_screw-1.5 -DPHP_ATOM_INC -I/usr/local/src/php_screw-1.5/include -I/usr/local/src/php_screw-1.5/main -I/usr/local/src/php_screw-1.5 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/php_screw-1.5/php_screw.c -fPIC -DPIC -o .libs/php_screw.o
/usr/local/src/php_screw-1.5/php_screw.c: In function `pm9screw_ext_fopen':
/usr/local/src/php_screw-1.5/php_screw.c:30: error: `pm9screw_mycryptkey' undeclared (first use in this function)
/usr/local/src/php_screw-1.5/php_screw.c:30: error: (Each undeclared identifier is reported only once
/usr/local/src/php_screw-1.5/php_screw.c:30: error: for each function it appears in.)
make: *** [php_screw.lo] Error 1

Replaced the same “key” in php_screw.c
[root@myserver php_screw-1.5]# sed 's/pm9screw_mycryptkey/ pm9screw_myownkey/g' php_scre.c > php_screw.c.new
[root@myserver php_screw-1.5]# cat php_screw.c.new > php_screw.c

[root@myserver php_screw-1.5]# make
...
.....
Build complete.
Don't forget to run 'make test'.
Success

Copied the Screw Module to Apache modules directory
[root@myserver php_screw-1.5]# cp modules/php_screw.so /usr/local/apache2/modules/

[root@myserver php_screw-1.5]# vi /usr/local/lib/php.ini
extension=php_screw.so

Restarted Apache
[root@myserver php_screw-1.5]# /usr/local/apache2/bin/apachectl restart

Compilation of the encryption tool
[root@myserver php_screw-1.5]# cd tools/
[root@myserver tools]# make
gcc -o screw screw.c zencode.c -lz
screw.c: In function `main':
screw.c:16: error: `' undeclared (first use in this function)
screw.c:16: error: (Each undeclared identifier is reported only once
screw.c:16: error: for each function it appears in.)
make: *** [screw] Error 1

Replacement of encryption key
[root@myserver tools]# vi screw.c
replaced
pm9screw_mycryptkey
with
pm9screw_myownkey

[root@myserver tools]# make
gcc -o screw screw.c zencode.c -lz
[root@myserver tools]#

Success

[root@myserver tools]# ls
Makefile screw screw.c zencode.c

This "screw" is the encryptor

Copied it to a System PATH
[root@myserver tools]# cp screw /usr/local/bin/

Encrypting a PHP script
Please execute the following command.
screw "Path to the PHP script to be encrypted"
The above line creates the script file enciphered by the same name.
Moreover, a backup is created in the same directory by the name of script
file name .screw.

Executing a PHP script.
If the installation of php_screw.so went OK, encrypted PHP scripts can now
be copied to an appropriate directory and executed as if it was
unencrypted. That is: The encryption is transparent for the
user.


Encryption
[root@myserver tools]# screw /usr/local/apache2/htdocs/phpinfo.php
Success Crypting(/usr/local/apache2/htdocs/phpinfo.php)

Tested the page
# opera localhost/phpinfo.php

Failure. It displays encrypted page.

Solution
Replaced
extension_dir = "./"
with

extension_dir = "/usr/local/apache2/modules"
in /usr/local/lib/php.ini

Restarted Apache
# /usr/local/bin/apachectl restart

Checked from browser
# opera localhost/phpinfo.php
It woks.fine
Opened a normal PHP file also
# opera localhost/pure_php.php
Works

AT&T USA | Internet not working | Fix by custom APN

If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...