مش لاقينى ……ببساطة

August 17, 2011

السلام عليكم ورحمة الله وبركته

من زمان مكتبتش

من زمان ونا بحاول كل يوم يعدى وبس

بحاول اخلينى على الشات اكبر وقت ممكن

وانام اكبر وقت ممكن

واهزر واضحك علشان اعدى  اكبر وقت ممكن

بس انا تعبت

انا فييييييييييين مش لاقينى !!!!!!!!

ببساطة تعالو ناخد الجوانب الاساسية فى حياة الانسان

وده حسب وصف الناس بتوع التنمية البشرية

- الجانب الدينى

-جانب العمل

-العلاقات الأسرية

-العلاقات الاجتماعية العامة

-علاقات العمل

وحاجة سادسة انا مش فاكرها

:D

المهم

ناخد جانب العمل

حتى الآن مش لاقى الحاجة اللى احس انى مش زهقان ونا بعملها

مش لاقى المتعة فى اى شغل

وحتى لو لقيته فى شغل شوية والاقى المتعة راحت

نستثنى من ذلك البرمجة

شوية حبيتها

بس مبحبش افضل اعمل ريسيرش على كل فنكشن

اعتقد ان لغة البرمجة اللى حبيتها بجد كانت السى

لانها كانت بتعتمد على استخدام الحاجات اللى فى ايديك وابنى انتا منها اللى انتا عايزه

البى اتش بى عجبنى لحد ما بدات اشتغل جملة

اتضايقت من احساس انى لسه حفضل اشوف كل فنكشن هما عملوها ليه وازاى استخدمها

بحب السيلز اوى بس بتخنق منه فى حاجات

الحاجة اللى مميزة فيا ومش عارف ازاى ممكن تتوظف انى بعرف اجيب افكار حلوة اوى لكل حاجة

جربتها مع مواقع الانترنت

كتير بعرف اجيب فكرة واحس انها  عبقرية وتنجح اوى

وبعد فترة حد ينفذ فكرتى

وتنجح

ويكسب من وراها

حاليا اتمنى انى انفذ اول فكرة جاية ان شاء الله

بس برده لسه مش لاقينى

طيب الجانب الدينى

ضااااااااااااايع

فين اسامة اللى كان بيصلى ال5 فروض فى المسجد وبيروح قرآن أحيانا وبيسمع خطب وبيذكر

فييييييييييييين؟؟

مش لاقيه

طيب العلاقات الاجتماعية

الحمد لله راضى عنها

بس مفتقد الصحبة الصالحة

نفسى فى الصاحب اللى يفكرنى بوقت الصلاة

اللى لما امشى معاه يفكرنى بربنا مش يبعدنى عنه

الصحبة الصالحة بمعنى الصحبة الصالحة

طيب

علاقات العمل

اول ما رجعت من اسكندرية كنت فعلا بكبرها

الواتى

ولااااااااااااا الهوا

العلاقات الاسرية

شاب اعزب نفسه يستقر ويتجوز

بس لسه فى معوقات

والبيت علاقتى بيهم طيبة بس مش مبسوط بيها برده

النتيجة

……………

بلاش نقول

سلسلة تعليم بى اتش بى

May 7, 2011

السلام عليكم ورحمة الله وبركاته

اليوم نبدأ أولى حلقات تعليم بى اتش بى

نرجو من الله تعالى أن تكون فى ميزان حسناتنا

نبدأ بالسؤال المهم

ما هى بى اتش بى ؟

server side programming language

أى لغة برمجة يتم تشغيلها على الجانب الخاص بالسيرفر

بمعنى آخر

يتم تنفيذ الأكواد الخاصة باللغة على السيرفر وليس على جهاز العميل

وهى أيضا

scripting language and not programming language

وده حنتكلم عنه بعدين

طيب أيضا لغة بى اتش بى هى لغة للويب

يعنى ايه برده ؟؟

ببساطة الويب كله شغال فى النهاية باتش تى ام ال

بمعنى

انا لما بدخل على أى سايت

النتيجة اللى بتوصل للجهاز عندى وبشوفها على البراوزر سواء كان فايرفوكس أو انترنت اكسبلورر أو  غيره هى صفحة مكتوبة باتش تى ام ال

المشكلة ان اتش تى ام ال لغة محدودة جدا ومش لغة برمجة كمان

لانها مجرد

markup language

ودى حنعرف معناها بعدين بس باختصار مجرد شوية تاجات بتعرض حاجات بشكل معين

لكن مفيهاش مثلا انى أشوف حاجة استقبلتها صح ولا غلط

مفيهاش انى أبص على قيمة اليوزر دخلها وأقارنها بواحدة تانية من قاعدة البيانات

بالتالى كان الحل انهم يعملو لغات بتوسع نطاق التعامل داخل الويب

ببساطة

لغة بتنفذ كل اللوجيك أو المنطق اللى احنا عايزينه وتحوله فى الآخر لصفحة اتش تى ام ال

يعنى ناخد مثال

يوزر دخل على سايت معين

السايت رد عليه بصفحة اتش تى ام ال وفيهم خانات فاضية يكتب فيهم اليوزر نيم والباسوورد بتاعه

اليوزر كتب اليوزرنيم والباسوورد بتوعه

بمجرد ما عمل انتر البراوزر بعت البيانات دى كلها للسايت

هنا السيرفر بيلاقى انه محتاج يعمل عمليات منطقية معينة ويقارن اليوزر نيم والباسوورد دول باللى عنده فى قاعدة البيانات وخلافه فبيبعت للجزء جواه الخاص باللغة اللى مكتوب بيها الكود ده اللى فى حالتنا حيكون بى اتش بى

الجزء اللى فى السيرفر أو البرنامج يعنى اللى بيشغل كود البى اتش بى بيستقبل الطلب وينفذه ويطلع نتيجة عبارة عن كلام مكتوب بالاتش تى ام ال

السيرفر بيضم الكلام ده على الصفحة الرئيسية ويرد بيهم على اليوزر

أوك حنلاقى هنا كتب كتير وفيديوهات كتير بتبدأ تتكلم عن تاريح اللغة دى وتتغزل فيها شوية أنا حخش فى الموضوع بسرعة أكبر شوية

طيب حضرتك الوأتى عايز تبدأ تستعمل بى اتش بى

لو انتا على جهاز ويندوز وده غالبا للأسف فحتتحاج تنزل حاجة اسمها وامب

wamp

واعمل لها تثبيت

بعدها مفروض ان فى مكان معين فى الجهاز لو حطيت فيه ملفات بى اتش بى

وبعدها

رحت فتحت البراوزر بتاعك على

http://127.0.0.1/filename.php

انه يفتح معاك

ولو عملت فى المكان ده فايل اسمه

index.php

حيشتغل معاك من غير ما تكتب اسم الفايل أساسا

لو موصلتش انك قادر تكتب كود بى اتش بى وتشوف نتيجته عندك فى البراوزر تقدر تبص على اللنك ده على يوتيوب

http://www.youtube.com/results?search_query=wamp&aq=f

الوأتى حنبدأ نشوف أشهر فنكشن فى البى اتش بى

phpinfo();

وده وظيفته اظهار معلومات عن الويب سيرفر والبى اتش بى

فى أمان الله والى اللقاء فى الحلقة التالية

Linux limits

March 23, 2011

Have you ever wander  about you linux system limitations ??

What if You tried to set the date to 1-1-100000000000000000000000 :D
will your system accept it ??

what is the maximum number of terminals You can open ??10000000 or more ??may be less …may be it is the memory limit no more …..

 

 

ok

 

I have no answer but I have the key …

/usr/include/limits.h

 

 

;) enjoooooooooooooy

how to install rkhunter on centos

March 22, 2011

1- go to http://packages.sw.be/rkhunter/

2-get the location /url of the needed package according to the version u use

3-wget [the url ]

4- yum install -Uvh [the package ]

5- if there is any dependcies it will tell You so take the package name and :

yum install [package_name]

6-repeate step 4  again

 

 

how to show cpu usage ,mem usage , uptime for a child processes of a process

February 14, 2011

SA

I was asked by a developer to make a small script that take the ppid as a parameter then print and log some info about any child processes that it will fork .

 

I used simply this line

ps -o etime,pcpu,pmem –ppid [parent process id ]

ps is a command that can be used to print some info about systems processes (Process State)

-o is a nice option which we tell what do we need to print about the process …

here I used:

etime : to show the up time

pcpu :  to show the cpu usage

pmem : to show the memory usage

 

all what I had to do next is to use this command in a simple script depending on our  requirements .

 

 

ياترى لسه فى أمان؟؟

January 8, 2011

السلام عليكم ورحمة الله وبركاته

بجد الناس كلها وحشتنى

اللى بتكلم معاهم تكنيكال والاصحاب اللى مش فى نفس المجال

كل الناس

 

النهارده حتكلم على حاجة معتقدش ان فى حد مجتش فى اله ولو مرات قليلة

 

اللى هوا الاحساس بالأمان

ياترى حاسين بيه؟؟

ياترى مستبعد انك تتخانق مع واحد ويطلع ظابط وتتشد على السجن وتتعذب وتتعامل معاملة غير آدمية؟؟

آمن على بيتك وعلى أمك وعلى مراتك وعلى بنتك

حاسس براحة البال ونتا مسافر على الطريق بعربيتك بعد الساعة 10 بالليل؟؟

حاسس ان لو بنتك ماشية فى الشارع وحد تعرض لها الناس حتحوش؟؟؟

بصراحة انا شخصيا خلاص بقيت حاسس اننا عايشين فى غابة

والمشكلة ان اللى مفروض انهم يطردو المجرمين من المجتمع اتحولو لمجرمين

 

كتير بقول المشكلة مش فى الواحد

بمعنى

……….

 

ان الواحد بيبقا نفسه ان يبقا تفكيره انه يفضل فى مصر مهما حصل علشان نصلح

وعلشان منبقاش بعنا بلدنا

بس المشكلة الحقيقية مش فيا

 

المشكلة ان فى يوم حكون مسئولة عن أسرة

بنى آدمة مفروض أحميها

وأطفال ضعاف فى وسط مجتمع متوحش

 

شخصيا مستعد رقبتى تتقطع علشان بلدى وشرف ليا

لكن لو حطو ان تقع قنبلة على مصر ويموت فيها 100 ألف بنى ادم فى كفة

وان حد يلمس شعره منها فى كفة

………

يمون ال 100 ألف وربنا يرحم الجميع

 

علشان كده بقول لكل الناس اللى ياااااما قلت لهم ان عمرى ما حطلع بره مصر انى خلاص مش مصر على القرار ده

how to backup your server files && database

April 28, 2010

I was asked at spirula to write a simple script that will backup my server’s files ,and backup my db too ,

The files’ backup script

well as I am still a trainee and my server is v v simple they told me to write a small script that even copy ,it doesn’t matter but I used rsync to synchornise the files instead of copying over .anyways this scripts has to

1- take a daily backup of the files

2-.tar.gz it

3-keep the last 6 days only backups and delete any before

db_bkp.scr files_bkp.scr
zakishan:~# cat scripts/files_bkp.scr
#!/bin/bash
#this script was writeen by usama el far [u.elfar@gmail.com]
#this script when put in corn and secheduled to run daily will backup directory with all its contents using sync instead of copying every time .keeping last 7 days’ backup files.,you just have to edit the next few lines and tell it the absolute path of both the directory which contain the files needed to be backed up and the directory which you want to backup your files to ,
#space needed is .tar.gz of your directory space*7 for storing + 1* your directory space for uncompressing and compressing
#please complete this
#the directory of the backup files
DIRECTORY=/home/usama/bkphere
cd $DIRECTORY
#the directory of the source files
BKP_DIR=’/home/usama/testbkp’

yester=`date –date=”1 days ago” “+%d_%m_%Y”`
today=`date “+%d_%m_%Y”`
yester=$yester

if test -f $yester.tar.gz
then
echo “founded yesterday’s backp and now copying it to begin sync”

tar xzvf $yester.tar.gz
cp -r $yester $today

echo “copy done”
else
echo “did not found previous bkps ,so i will create a new from now”
fi
rsync -av $BKP_DIR $today
tar czvf $today.tar.gz $today

if test $? -eq 0
then
rm -r $today
else
echo “I couldn’t tar and gzip it so I left the directory without removing”
fi

from7=`date –date=”7 days ago” “+%d_%m_%Y”`

echo “now i am searching for previos backups from more than 1 week and remove it”

#ls -l $from7.tar.gz >/dev/null 2>/dev/null

if test -f $from7.tar.gz
then
echo “found the backup from 1 week and removing now”
rm $from7.tar.gz
else
echo “i did not found backups from 7 days ago to delete”
fi

The database backup script

Now lets go to the database part …

simply there is a single line command we can use to backup our db

which is

mysqldump –opt -Q -u [DB_USERNAME]  -p[DB_PASSWORD]  [DB_NAME] >[DBKP_FILE_NAME].sql

to restore we use

mysql -u root -p[MYSQL_ROOT_PASSWORD]  [DB_NAME]<[DBKP_FILE_NAME].sql

lemp server[Linux nginx mysql php]+wordpress+port forwarding + dynamic dns{2nd spirula task}

April 25, 2010

I would like to inform at the first that I wrote this after I finished my work and i couldn’t revise it well ,so fell free to ask,use ,or even correct whatever you want .Actually I mentioned the use/the reason for every single command here to give you the needed concept to search for the reason if it didn’t work/gave you un expecteded o/p .

I would like too to mention that this tutorial helped me aloot even in writing this http://interfacelab.com/nginx-php-fpm-apc-awesome/

ok now i will write a fast How-to for my second task

I was asked to do the foloowing :

-Install a LEMP server {Linux nginx mysql php }

-choose any open source bloging project and install it {choosed wordpress}

-configure my ADSL router to port forward any requests to my server {http , ssh}

-install dynamic dns  client on my server and make it update my free sub-domian reserved at dyndns.net continously

Some notes && background :

-nginx is a very powerfull web server which is well known with its great performance .although it is well known too that it dont have many modules and options like other web servers{apache …etc}.It is v v light though you can use it as a reversed proxy {This is actually one of the common uses for it }

-nginx dont handle php scripts from modules but the only way is to use fast cgi {http://en.wikipedia.org/wiki/FastCGI}as a concept .We can here use spawn-fgci or php-fpm .at the first i used spwn but later I moved to php-fpm .because it has less errors and better performance .

-php-fpm is actually a patching to the php source code no more .

-I choosed wordpress as I am using a P3 machine in my office,and wordpess is +performance than drupal{although drupal has many and many added options }

-I have a repotec ADSL router {will find the model and wirte it here later inshallah}.please note that there is some brands/models of ADSL modems+routers{including mine } don’t  provide the port forwarding in a stable way .and there is others that don’t work at all .

-As i don’t have a static IP in my ADSL line I have to setup a dynamic dns client that will update a sub dmoain registered for free on dyndns.net so that any time i want to access my server i will find that it has updated the real ip of my adsl line and binded it to my-sub-dmain.dyndns.net

Notes:

-Installation was not smooth at all .There was many and may depencies I had to reolve ,many errors to handle and so .For sorry I couldn’t take snapshots of all of them but :-I will try to remeber and search 2-You are welcomed to leave a comment/send me asking {actually I prefer to comment to let others see the question and the answer }

Now lets see the work plan

-install some depencies

-download php {i used 5.2.13 }

-download php-fpm {note that every php version has its php-fpm }

-compile,make,make install php

-some modules

-edit some php configuration files

-installing mysql

-install php5-mysql

-downloading and installing nginx

-configuring a default site for nginx

-starting &&testing

-adding them to startup

Step-by-step

apt-get install make bison flex gcc patch autoconf subversion loca

apt-get install libxml2-dev libbz2-dev libpcre3-dev libssl-dev zlib1g-dev libmcrypt-dev libmhash-dev libmhash2 libcurl4-openssl-dev libpq-dev libpq5 libsyck0-dev
#To me I found later many and many other depencies .
cd /usr/local/src/
#now you have to download php .choose a mirror from here ,copy its link location then wget it[http://www.php.net/get/php-5.2.13.tar.gz/from/a/mirror]..this is for php 5.2.13 which i used,feel free to choose any other version you want,just make sure you can find its php-fpm from here [http://php-fpm.org/downloads/]
tar zxvf  [php tarball name ]
#download its php-fpm from here [http://php-fpm.org/downloads/]
wget  [php-fpm source ]
#patch
gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1
#compile & install php
./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-pgsql --with-curl --disable-debug --enable-pic --disable-rpath --enable-inline-optimization --with-bz2 --with-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex --with-mysql
#at the last command you can have a look and remove any options you are sure you will not need it ..BUT ….please take care .To me I didn’t add –with-mysql at the first .this led me to many troubles ..{I will talk about this later inshallah}
#now installing
make all install
#I dunno why this command but it is found in all How-Tos I used
strip /usr/local/bin/php-cgi
#installing some modules
pecl install memcache

pecl install apc
pecl install syck-beta
cp /usr/local/src/php-5.2.8/php.ini-recommended /usr/local/lib/php.ini
mkdir /etc/php/

ln -s /usr/local/lib/php.ini /etc/php/php.ini
ln -s /usr/local/etc/php-fpm.conf /etc/php/php-fpm.conf
#now we have to edit /etc/php/php-fpm.conf to set the user and group options
<value name="owner">www-data</value>

<value name="group">www-data</value>
<value name="user">www-data</value>
<value name="group">www-data</value>
#now its time for nginx,feel free to choose the vesrion you want
cd ..

sudo tar zxvf nginx-0.6.35.tar.gz
sudo rm -f nginx-0.6.35.tar.gz
cd nginx-0.6.35
sudo ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module
sudo make && sudo make install
#lets make it easier to reach config file
ln -s /usr/local/nginx/conf /etc/nginx
#at /etc/nginx/fastcgi_params we have to add some parameters for fast cgi
fastcgi_connect_timeout 60;

fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
#now we have to make a startup file called /etc/init.d/nginx like this :  note that I have added a comment to inform you with the end of the file
#! /bin/sh

### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi

set -e

case “$1″ in
start)
echo -n “Starting $DESC: “
start-stop-daemon –start –quiet –pidfile /usr/local/nginx/logs/$NAME.pid \
–exec $DAEMON — $DAEMON_OPTS
echo “$NAME.”
;;
stop)
echo -n “Stopping $DESC: “
start-stop-daemon –stop –quiet –pidfile /usr/local/nginx/logs/$NAME.pid \
–exec $DAEMON
echo “$NAME.”
;;
restart|force-reload)
echo -n “Restarting $DESC: “
start-stop-daemon –stop –quiet –pidfile \
/usr/local/nginx/logs/$NAME.pid –exec $DAEMON
sleep 1
start-stop-daemon –start –quiet –pidfile \
/usr/local/nginx/logs/$NAME.pid –exec $DAEMON — $DAEMON_OPTS
echo “$NAME.”
;;
reload)
echo -n “Reloading $DESC configuration: “
start-stop-daemon –stop –signal HUP –quiet –pidfile /usr/local/nginx/logs/$NAME.pid \
–exec $DAEMON
echo “$NAME.”
;;
*)
N=/etc/init.d/$NAME
#echo “Usage: $N {start|stop|restart|force-reload}” &gt;&2
exit 1
;;
esac

exit 0

#——————This is the end of the file ————————————-#

mkdir /usr/local/nginx/sites-enabled

sudo ln -s /usr/local/nginx/sites-enabled /etc/sites

#And now let’s add a conf file for our default site at /etc/sites/default.conf. The contents:,note that this some times this is in different file .

server {
listen *:80;
location / {
root   /var/www/default/pub;
index index.php;
# if file exists return it right away
if (-f $request_filename) {
break;
}
# otherwise rewrite the fucker
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php$1 last;
break;
}
}
# if the request starts with our frontcontroller, pass it on to fastcgi
location ~ ^/index.php
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/default/pub$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}
}
#now start
php-fm start

/etc/init.d/nginx start
#then  test
-create a html file called index.htm which just contain any sentense  like hi this is my server …
-open a browser then write the ip address of the server …you must see the sentense
-delete the first file and create another one called index.php and copy& paste these lines into it
<?php
echo “if i saw ONLY this sentense ,then webserver and php are running “;
?>
-you must see this only “if i saw ONLY this sentense ,then webserver and php are running “
#ok ,now congratulations ,your server is running ,just we have to make it startup with  the system startup automaticlly
update-rc.d nginx defaults
#this will add the script we created before {/etc/init.d/nginx } to the directories that control the run levels so that it start with the system startup
#now we have to create a nother 1 for php-fpm
vi /etc/php-fpm
#then add this line
php-fpm $1
#then add it to startup
update-rc.d php-fpm
#note: this didn’t work with me so i edited /etc/init.d/nginx and added the line
php-fpm start
and
php-fpm stop at the two condition parts
Port forwarding
simply  configuring port forwarding on my ADSL modem+routr means that I am telling my router to redirect requests that come to defined ports to a local machine that is connected to the lan card .
Simply we will need to port-foward 2 ports :
- 80 which the web server use
- 22 which ssh use {you may prefer ot to add it if you dont ssh your server from any other network}
port forwarding is pretty easy ,you can find the instructions for your router model from [www.portforward.com]
it is some times called virtual server too
dynamic dns
#ok ,now we have a problem ,which is ……every time I restart my router it is granted a new ip address fromt he isp so if i found that this is myu ip today [x.x.x.x] then tried after the next reboot to use it  iw ill find that it has changed ….so as we are having a dynamic changing of ip addresses we will solve it with dynamic dns :D
…simsply i will reserve a free sub domain then install a small program called dynamic dns client on my server ..this client will have to update my subdomain with the new ip address every time it is changed …so i can access my server through this sub domain
#go to www.dyndns.com
create a free account
choose to add a host
create a sub domain
then
#install inadyn
apt-get install inadyn
now use this command
inadyn –username [username u reserved at dyndns] –password [your password ] –update_period_sec 600 –alias [your sub domain name] &
#try to access your server from internet …PLEASE note that if you tried from the local network you MUST use any online proxy
#finally we have to create a /etc/init.d file for inadyn
#here is mine {note that i will tell you in a comment that this is the end if the file }
#!/bin/sh

case “$1″ in
“start”)inadyn –username zakishan –password master77 –update_period_sec 600 –alias zakishan.dnsalias.net &
;;
“stop”)
x=`pgrep inadyn`
kill -9 $x
;;
*)echo enter valid start/stop
esac

#finally add it to the system startup using update-rc.d
update-rc.d inadyn defaults
#reboot your server ,check your log files ,test your server again and …..get ready to install the word press …..
Word press installation
#You can easily follow this [http://codex.wordpress.org/Installing_WordPress],I just quoted some of its instructions
#simply wordpress will use our mysql database so we have to
-create a username and password for it to use
-create a databse
-grant the user privileges on this DB
-edit the wordpress configuration files and tell him what user ,pass and db will it use
-run the installation script which will create the tables the application need  and set the configuration entries
ok .now lets begin with mysql
mysql -u root -p
#it will ask you about the password you entered when you installed it
now
create user [username] identfied by [password ];
then
create database [db-name];
then
grant [username] *.* on [db-name]
#now we have to download the wordpress project tarball
wget http://wordpress.org/latest.tar.gz
#extract it to the path you want inside the root directory of the site you created before#Rename the wp-config-sample.php file to wp-config.php
#edit it ,find these lines  and give it the username/password/db
#now from your browser access the install.php file inside the wp-admin directory which you can found in your extracted folder of wordpress inside the root /whatever where you placed it
……
congratulaitions

And now let’s add a conf file for our default site at /etc/sites/default.conf. The contents:

01.server {
02. listen *:80;
03.
04. location / {
05. root   /var/www/default/pub;
06. index index.php;
07.
08. # if file exists return it right away
09. if (-f $request_filename) {
10. break;
11. }
12.
13. # otherwise rewrite the fucker
14. if (!-e $request_filename) {
15. rewrite ^(.+)$ /index.php$1 last;
16. break;
17. }
18.
19. }
20.
21. # if the request starts with our frontcontroller, pass it on to fastcgi
22. location ~ ^/index.php
23. {
24. fastcgi_pass 127.0.0.1:9000;
25. fastcgi_param SCRIPT_FILENAME /var/www/default/pub$fastcgi_script_name;
26. fastcgi_param PATH_INFO $fastcgi_script_name;
27. include /usr/local/nginx/conf/fastcgi_params;
28. }
29.}

how to LVM on RAID +encrypted /home partition

April 20, 2010

Asslamo 3likom wara7matt Allah ,

I was asked by spirula[www.spirulasystems.com] as the 1st task in my training program to finish these tasks

1-prepare a small p2/3 p.c  with 3 hard disks

2- make the 3 HDs as the following :

-The 1st one as the root system

- The other 2 hard disks are in raid0 {mirrored }

-Create a volume group on the raid

-create a /home partition encrypted logical volume

- add it to fstab to make it be mounted with the system start up

Now we will begin

Installing the system

-I used the Debian lenny net install cd .You can get it from here [http://www.debian.org/CD/netinst/]

-I will escape the installation part to make the topic more short but you can get the installation instructions from here [http://www.debian.org/releases/stable/i386/].For more short steps just use google and you will find many

RAID0 installation

-for more information about RAID .You can have a look at my post about it here [http://smartbasha.wordpress.com/2010/04/15/the-raid-technology/].It is totally quoted from its page on wikipedia

-Now the steps:

-apt-get update                                  #this will refresh the repositery

-apt-get upgrade                              #this will upgrade the installed packages

-apt-get install openssh-server  #I have to access the server remotely thats why i installed ssh

>Now I have hda formatted and have the / file system on it [including /home ].so I will begin working with hdb and hdc

-fdisk  /dev/hdb     #fdisk is the utitlity to edit the partition table for any H.D .Now I followed some steps and formatted the harddisk as 1 row partition{with no file system on it}

-fdisk /dev/hdc   #did the same with the 3rd H.D

>>Now I have to install mdadm .mdadm is the utitlity which we will use to initiate the raid array and create the raid0 .it has a previous name in old versions i dont remeber now

-apt-get install mdadm

>>now we have to create the raid0 array which contain hdb1 and hdc1 {the 2 partitions we got after fdisk the 2 H.Ds}

-mdadm -C /dev/md0 –level=raid0 –raid-devices=2 /dev/hdb1 /dev/hdc1

>>Lets check if it really worked and the system now has this array/no

-cat /proc/mdstat

>>we should have something like information about our raid array.Here we have successfully created the RAID part and have to go to the LVM part

LVM

pvcreate /dev/md0  #pvcreate initializes PhysicalVolume for later use by the Logical Volume
Manager (LVM).and told him to use md0

pvdisplay               #We should have here md0 listed

vgcreate vg0 /dev/md0

lvcreate –name homes –size 5G vg0  #now i have created a  logcial volume of 5 G.B using the vg0

Encryption

cryptsetup luksFormat /dev/vg0/homes                    #initializes a LUKS partition and sets the  initial  key,,we will be asked to enter a key to be used in the encryption
cryptsetup isLuks /dev/vg0/homes                   #this command for sorry I tried it with true and false arguments and in all times it give no answer .after search i found that the best way to make sure it was successed is to check its exit status

echo $?

>>it must give 0

cryptsetup luksOpen /dev/vg0/homes secureddev    #it creates a mapping to it as secureddev

dmsetup info secureddev             #get some info about

mkfs.ext3 /dev/mapper/secureddev     #format the encrypted volume with ext3 file system

mount -t ext3 /dev/mapper/secureddev /temp   #to mount it

>>ok,now i have to transfer all the /home to the new volume .

cp -rp /home/* /temp

>>final step is to make it be mounted with startup

>>After reading many articles about this I found this is the most simple here [http://www.howtoforge.com/automatically-unlock-luks-encrypted-drives-with-a-keyfile]

>>so ,I …………

cryptsetup luksAddKey /dev/vg0/[my_partition]    /etc/volume_key

>>now lets add this to the /etc/crypttab file

secureddev      /dev/vg0/homes  /etc/volume_key luks

>>then add this to /etc/fstab to make the system automatic mount it

/dev/mapper/secureddev  /home   ext3    defaults        0       2

>>now ,my task is done …rebooted ,tested ……every thinh is okay .thank you

The RAID technology

April 15, 2010

Asslamo 3likom ,

Today I am going to share some informatio about what I AM CURRENTLY TRYING TO GET CLOSER AND DO …these capital words is a warning that I don’t have a big experince about it but ….I am trying just to share here .this doesnt mean that questions or comments are not welcomed :D . and yes .. i will talk here about RAID 0,1 and 5 only

First :What is RAID ?

RAID is: Redundant Array of Inexpensive Disks …but later mrketrs changed it into Redundant Array of Independant Disks …{v  intelegant}

RAID has many schemes /architectures named by the word RAID then a number like RAID 0 ,1,…..etc

RAID various designs always try to enhance 1 of 2 things: Reliability / performance .

RAID array: when there is multiple disks are set up to use the RAID technology they are a RAID array ……….finally the computer will see this Array as a single disk .

well,We have now 2 choices for Implementing RAID .1 is the hardware solutions and the software solution.Think of it like hardware and software firewalls .You can have a firewall device in your network or you can have a machine with s/w installed on it to turn it into a Firewall .and the applications will be the only who don’t know anything about your RAID

if you choose the h/w your operating system will not even know that you are using raid .if you used the software solution you will have to learn how to make it using your OS .I am going to write a post about that v soon inshallah .

now ,please pay attention to these 3 concepts here :

1-Mirroring : having two disks mirrored means that you are writing identical data to more than one disk.

2-Striping: means splitting data across more than one disk

3-Error correction: simply ,there is a redundant data stored to allow problems to be detected and POSSIBLY repaired .

please again and again don’t continue reading this unless you understand these 3 words:mirroring,stripping and Error correction .if not go back /search …..and so

From here I will begin talking about RAID levels .open this link now and find the table which compares different levels of RAID ..don’t close it but keep it opened  in another tab in your browser and continue reading my words here

RAID 0   {Stripped disks} :

It distribues data across multiple disks ,so if we have disk0 and disk1 in RAID0 this means that the data is written to the 2 H.Ds in the same time which means  better performance .but this mean that we dont have another copy of data written here …if 1 of the 2 disks fail you lose ALL THE DATA ON THE 2 disks{ALL the data saved to the array simply}.

Now: Can I add additional hard disk to the this RAID0 ??yes ,logicically why not?? :D

RAID1:

RAID1 mirrors the contents of the disks {1:1}..the contents of each disk is identical .data written here,here and there …lets think here …do we have incresed perofrmance??no ..ok do we have better avaiablilty? efcourse yes ….look at the table in the posted before link .

RAIND5:

here You will need>2 disks .at least 3 .simply what happens in RAID5 is Strped set with ditributed parity or interactive parity This requires all drives but one to be present to operate .This maens that single disk failure wont be a problem .you can recover and replace later but…its failure will affect the performance .

Well .I have now to thank wikipedia v v v v much as it was my reference in writing this …actually you can say that this is just some quotes of the RAID page here [http://en.wikipedia.org/wiki/Redundant_array_of_independent_disks]

Now I am going to write a Topic about : Linux software RAID

thank you


Follow

Get every new post delivered to your Inbox.