Showing posts with label freebsd. Show all posts
Showing posts with label freebsd. Show all posts

Monday, May 7, 2012

Reverse Copy

I nearly forget about reverse copy. Yasterday sis Salina have problem to copy file for Server Source to Server Destination.

Here is the way where we can pull the data ( reverse copy )
Normal copy ( copy command at source server ) source -> destination
Reverse copy ( copy command at destination server ) destination  <- source

For example you want to copy DATA from Server S (source) to Server D (destination):

Normally at Server S
# scp /path/to/DATA aminah@ipServerD:   -> file akan ada kat home/aminah/
# scp /path/to/copyDATA aminah@ipServerD:/path/to/save/  -> file akan ada kat /path/to/save/

But for reverse copy, we copy DATA to our home at server S.
-> so at server S we have /home/aminah/DATA

At Server D 
# scp aminah@ServerS.contoso.com.my:DATA ./

Reverse SCP for amazon
#scp -i mykey.pem root@ec2-184-73-72-150.compute-1.amazonaws.com:/file/path/filename ./

./ -> mean current directory 

Normal SCP for amazon
#scp -i mykey.pem filename root@ec2-184-73-72-150.compute-1.amazonaws.com:/path/to/save/ 



hehehe... done..  

Tuesday, April 24, 2012

Move / Copy files with exception in UNIX.

The syntax :
mv [!filename]* target.
ie:
In directory "y" you have these files :
-rw-r--r-- 1 sirap sirap 0 2010-03-25 11:40 1
-rw-r--r-- 1 sirap sirap 0 2010-03-25 11:40 2 
-rw-r--r-- 1 sirap sirap 0 2010-03-25 11:40 3
-rw-r--r-- 1 sirap sirap 0 2010-03-25 11:40 4 

 You want to move all files except file "4" to directory "z".
The syntax should look like this :
# mv [!4]* ../z/ Done.

Friday, April 13, 2012

howto install FreeBSD9 CAS Server


The steps was given by sifu zaman..


1. Download latest diablo-jdk-freebsd and cp to /usr/ports/distfiles
2. Download latest tzupdater and cp to /usr/ports/distfiles
3. cd /usr/ports/java/diablo-jdk16/ && make install clean
4. cd /usr/ports/www/tomcat6/ && make install clean
5 install apache2
6 install mod_jk (connector used by appche to connect to servlet container)
7 install and configure Apache SSL (HTTPS) - refer to apache documentation

edit /usr/local/etc/apache/httpd.conf

change this parameter -> Listen 80 to Listen 443

make sure this module load at apache start

add this in httpd.conf -> LoadModule jk_module          libexec/apache22/mod_jk.so

add this in httpd.conf ->  Include etc/apache22/mod_jk.conf

create new file

ee /usr/local/etc/apache22/mod_jk.conf

and add this



        JkWorkersFile /usr/local/etc/apache22/workers.properties
        JkLogFile  /var/log/jk.log
        JkShmFile  /var/log/jk-runtime-status
        JkLogLevel error



save mod_jk.conf

create new file

ee /usr/local/etc/apache22/workers.properties

and add this

worker.list=co-t-newsso01

worker.co-t-newsso01.port=8009
worker.co-t-newsso01.host=colo-vst-newsso01
worker.co-t-newsso01.type=ajp13
worker.co-t-newsso01.lbfactor=1

save workers.properties

note :  please change all "colo-vst-newsso01" with your own server name


edit /usr/local/etc/apache22/extra/httpd-ssl.conf


disable Listen 443

add this (bottom of file before )

JkMount /* co-t-newsso01
JkMount /*.jsp co-t-newsso01


note :  please change all "co-t-newsso01" with your own server name

cd /usr/local/apache-tomcat-6.0/conf

ee server.xml

make sure you add or enable this



               connectionTimeout="20000"
               redirectPort="8443" />



               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />

save server.xml

8. Edit /etc/rc.conf and add this line

apache22_enable="YES"
tomcat60_enable="YES"

save rc.conf

start apache and tomcat

test access tomcat (non secure using http://servername:8080)
then try access secure connection https using https://servername:8080


9. Install apache MAVEN - cd /usr/ports/devel/maven && make install clean ; rehash
10. Download latest JASIG CAS Server from http://downloads.jasig.org/cas/ and save in your home directory
11. Extract downloaded CAS Server


for example if latest version is cas-server-3.4.11-release.tar.gz

tar -xzf cas-server-3.4.11-release.tar.gz

cd cas-server-3.4.11/cas-server-webapp

ee pom.xml  and add this line

       
             ${project.groupId}
             cas-server-support-ldap
             ${project.version}
       

save file

run this command in cas-server-3.4.11/cas-server-webapp directory

mvn clean package

12. Replace all content in /usr/local/apache-tomcat-6.0/webapps/ROOT/ with content from cas-server-3.4.11/cas-server-webapp/target/cas-server-webapp-3.4.11/

Run this command in cas-server-3.4.11/cas-server-webapp/target/cas-server-webapp-3.4.11/

stop apache tomcat

cp -Rp * /usr/local/apache-tomcat-6.0/webapps/ROOT/


ee /usr/local/apache-tomcat-6.0/webapps/ROOT/WEB-INF/deployerConfigContext.xml

make sure you configure this parameter same like this






and put this in ldap server parameter

ldap://XXX.XX.XXX.XX/

Start apache tomcat

Now you should able to access you CAS server

https://servername/login

Done.


Wednesday, March 28, 2012

Basic freeBSD to copy, move files

Copy to same server

cp -rp {path file} {path }

Cannot SCP your file to another server

Usually.. I have no problem to scp my file to another server.. But today it giving me below error :

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:11
RSA host key for 1XX.1X.XX0.xX0 (ip) has changed and you have requested strict checking.
Host key verification failed.

-----
So, here is the step to resolved this problem
#cd /root/
#ee .ssh/known_hosts
pastu ctrl-k semua line dalam tuh..
save..

Actually this .ssh/known_hosts file keep cache of previous access ssh command.

Then ok.. :) paham2..

Thursday, February 23, 2012

Drupal Multisite

Hoyee... finally sis salina and i did it :)

Here is the step:
1. Install Drupal 7 the normal way
2. Create DNS name eg: MainSite.example.com Site1.example.com Site2.example.com
3. Configure the web server so that the second site's domain points to the same directory.
Different web hosting providers has a different procedure for this (usually adding an add-on domain and changing its root directory to your Drupal installation root directory), If, however, you are working on your local server, supposing it is Apache, just add the second site's domain to ServerAlias directive. (or if you need separate logs, you can make a new virtual host with the same DocumentRoot)
Here is an example of Apache configuration..


4.Make a new directory with name equal to the second site's domain (Site1.example.com) under Drupal's sites directory.
Suppose you have uploaded Drupal files in a folder named "drupal" so there is "drupal/includes/","drupal/misc/","drupal/modules",..etc. now your new directory should be "drupal/sites/my-second-domain.com". (the folder name is "my-second-domain.com")

5.Copy default.settings.php to the new directory renaming it to settings.php and make a new directory called files there then change permissions so that both are changeable by everyone.
Following what we previously supposed, you will copy the default.settings.php file (found in drupal/sites/default/) to /drupal/sites/my-second-domain.com/ and rename it to settings.php then change its permissions to 666 (make it changeable by everyone) and then make a new directory under /drupal/sites/my-second-domain.com/ and name it "files" then change permissions of it to 777.
In Linux (if you are working on your own local server or have SSH access to your host) this can be done as follows :

6.Navigate to the second site's domain and install Drupal normally.
Just like the first step above.


Problem that we are facing where the pcre 8.30 are not compatible to drupal7.
It will give warning



With help by Sifu Zaman.. we finally success downgrade to pcre8.21 but the problem is this pcre are dependence to other package such apache22. So, we decide to maintain the pcre 8.30 since it is only giving warning not error :)


You can add how many sites you want.. and you can do the same thing as above steps.

make sure the file name for setting.php is "SETTINGS.PHP" with 's' .. that is my problem when i did the third sites where in the beginning it is not working.

Tuesday, February 14, 2012

Intergrate CAS, LDAP with Drupal

Today I and Sis Salina successfully connect cas, ldap with our new drupal 7.
ALHAMDULILLAH :)

Actually this in not the actual objective that we want to do. Our first plan is to integrate cas, ldap with wordpress as per requested by our webmaster. The problem is, the configuration in wordpress are to complicated. Because of that we doing underground project which we intergrate it to drupal 7. Ha.. and then it is working..Hoyeee..

Here is the pros and cons; drupal can easily integrate with cas, ldap and it also have multisite features. While wordpress have problem during integrate with cas and ldap... where the we cannot login to wp-admin. Some more, we also have problem to setup multisite which need complex configuration and manual things... and really make myself headache.. Houuhh.. Hope our Web master do understand on this plan B.

Ok let move to another topic where is problem that we are facing during intergrate Ldap and Cas with ldap.

1. Install Drupal
a. The problem that we are facing here where we cannot see the mysql setting gui.
REMINDER: read the prerequisite so that you will not be crazy because cannot see the setting.
Solution : 1. Drupal 7: MySQL 5.0.15 or higher with PDO, SQLite 3.3.7 or higher
php5-pdo_mysql-5.3.10 (install this then the setting will come out)

2. Configure cas and ldap
a. Password for ldapadmin are wrong. Thanks to Sifu Zaman for his expertise in troubleshoot the password validity.
b. Cas need php-curl (extention)






Thursday, February 2, 2012

Date Problem... cannot login

php error at date.time zone
A. # cd usr/local/etc/
# ee php.ini
--> search date.time format
setting : http://www.php.net/manual/en/timezones.asia.php
then change add "eg: date.timezone = "Asia/Kuala_Lumpur""

Checking date in server
#date

if not same you have to setting up using this command
#ntpdate asia.pool.ntp.org

Thanks for sifu John...

for changing setting at php.ini (8. php error at date.time zone) : need to restart apache.

How to restart apache but will not disturbe the connection?
#/usr/local/etc/rc.d/apache graceful

Monday, January 30, 2012

Copy, Remove, Tar, Change Owner, Change mod, Clear History

How to check size folder
#du -h
#df -h

tar files
#tar -cjvf sha.tar.bz2 fold1 fold2 fold3 fold4
c- create j-tar.bz2 v-show process f-files
# tar cvzf archive_name.tar.gz dirname/


copy file tar to another server
#scp sha.tar.bz2 shariha@162.12.12.22:
ni dia akan pi ke home shariha di server 162.12.12.22

untar
#tar -xjvf sha.tar.bz2
#tar -zxvf sha.tgz
#tar -xvzf sha.tar.gz

katakan nak move file tuh ke /data/mms
#cd /data/mms
#mv /home/shariha/sha.tar.bz2 ./
./ means current path

Change ownership
#chown -R www-data:www-data fold1 fold2 fold3 fold4

Change mod
#chmod -R 755 fold1 fold2 fold3
| 7 | 5 | 5 |
|rwx|r-x|r-x|
|owner|group|world|

Copy
#cp -rp /home/shariha/sha.tar.bz2 /data/mms

copy name folder start from 3** (30, 300, 301, 321..etc)
#cp -rp /../data/3* ./
so dia akan copy apa2 yang foldername start 3... kepada current path

Clear History
#history -c
kalu laa tertype password.. leh argh nak clearkan.. 

Find / Whereis 
#find /path/want/to/search -name mysong.php (ubuntu)
or
#find /path/want/to/search -name *.php
or
#whereis

Sunday, January 29, 2012

Problem cannot ping hostname but can ping ip

Setting /etc/rc.conf
ifconfig_dco="DHCP"
hostname="fw.company.com"
defaultrouter="192.168.1.1"

Setting /etc/resolv.conf
search carolina.rr.com
nameserver 24.25.5.60
naemserver 24.25.5.61

Setting /etc/hosts
::1 localhost.company.com localhost
127.0.0.1 localhost.company.com localhost

Tapi tak leh ping jugak... pelik2.. Sifoo solution... Idupkan deamon
Caranya.. tambahkan kat /etc/rc.conf
named_enable="YES"
Pastu... idupkan dengan # /etc/rc.d/named start

Dan tiba2 ia idup... hoyeee... five star for sifu zaman..


Tuesday, January 10, 2012

Create Multisite Setup for Wordpress

I feel like crazy to setup wordpress with multisite features. Wargh.. :(

First step is almost done.. But still facing big problem where i cannot change the ip to domain name. It is not simple as setting up at vhost and it is also not simple as register to dns.. Huuhh.. There is a lot of thing to learn.. keep learning and keep learning..

Here is some step to setup multisite in Wordpress.


Wednesday, January 4, 2012

FreeBSD Security Advisories

FreeBSD Security Advisories has announced multiple remote and local vulnerabilities recently . Kindly take necessary action to prevent our server from become a victim of these vulnerabilities. Your cooperation are highly appreciated . Thanks and regards.

http://security.freebsd.org/advisories/FreeBSD-SA-11:06.bind.asc

http://security.freebsd.org/advisories/FreeBSD-SA-11:10.pam.asc

http://security.freebsd.org/advisories/FreeBSD-SA-11:08.telnetd.asc

http://security.freebsd.org/advisories/FreeBSD-SA-11:09.pam_ssh.asc

http://security.freebsd.org/advisories/FreeBSD-SA-11:07.chroot.asc



cth laa...

so.. ikut jerk step dia..

buat folder patch kat mana2..

#mkdir patch

#cd /patch

# fetch (link yang dia kasi)
pastu pi kat /usr/src

#cd /usr/src

#patch < /path/to/patch8888

*************

(----) mean file yang lama yang akan di buang

(++++) mean file yang baru yang akan di tambah

done.. :)

Monday, December 12, 2011

Var in Freebsd is full

when you #df -h
if show var is 108%... but when you check at folder /var it seem only have file 40-50M only..

What should i do?
1. already try to restart apache22 but cannot resolve
2. restart deamon.. cannot work
3. finally.. i restart the server.. hehehe.. done ;) but actually need to search what is the problem.

---- janji selesai ;)---- nnti study smula

Thursday, December 8, 2011

Make Link at Freebsd

ln -- make links
ln [-fs] source_file [target_file]
-f    Unlink any already existing file, permitting the link to occur.  
-s    Create a symbolic link.
So, kalu kita upgrade port moodle tuh.. dia akan direct ke /data/training (kat mana kita simpan data)...
eg: #ln -s /data/training moodle

Tuesday, December 6, 2011

Install New Server Freebsd

1. boot the OS and install
  • select non-boot -> 1 OS
2. Start to install port
  • install apache, php ngan application ( eg: moodle)
3. Install dulu apache..
  • #cd /usr/ports/www/apache22 -> path apache22
  • #make config -> nih utk option dalam package
  • #ee /usr/ports/www/apache22/Make file -> nih utk tgk version
  • #make install clean ->nih untuk install
4. Install php
  • #cd /usr/ports/lang/php5
  • #make config ->jangan lupa select (X) apache (by default tak tick)
  • #make install clean
  • lepas install ;
-> akan kasitau "make sure index.php is a part of your Directory Index
AddType application/x-httpd-php.php
AddType application/x-httpd-php-source.php

1-> so, kena pi kat # ee /usr/local/etc/apache22/https.conf
^y (search = DirectoryIndex)
DirectoryIndex index.html index.php
2-> ^y (search = AddType)
pastekan AddType application/x-httpd-php.php
AddType application/x-httpd-php-source.php

---dsb (php.extension, moodle, ...etc)---

5. tukar few setting yek
1-> setting host
#ee /etc/hosts
ip servername@domain.edu.my servername
2-> setting virtual host
#cd /usr/local/etc/apache22/extra/httpd-vhost.conf
ServerAdmin username@domain.edu.my
DocumentRoot "/data/foldername"
ServerName servername.mediu.edu.my
ErrorLog "/var/log/httpd-error-form.log"
CustomLog "/var/log/httpd-access-form.log" common


6. Start Apache
# /usr/local/etc/rc.d/apache22 start -> utk start apache
restart -> utk restart
graceful -> utk update, so apache tak mati.

7. Few error troubleshoot
-> error forbidden
* tukar directory root (# ee /usr/local/etc/apache22/httpd.conf)
# This should be changed to whatever you set DocumentRoot to.
#
# "/usr/local/www/apache22/data">
-> tukar kat path yang kita letak shariha.php

->if there is anychange need to setup such as
Add the following to your Apache configuration, and restart the server:
### Add the AcceptPathInfo directive only for Apache 2.0.30 or later.
Alias /moodle /usr/local/www/moodle/
AcceptPathInfo On
AllowOverride None
Order Allow,Deny
Allow from all
AllowOverride None
Order Allow,Deny
Deny from all
this is need to be added either at httpd.conf or /usr/local/etc/apache22/extra/httpd-vhost.conf



8. Shared object libpcre.so.0 not found required by httpd
1. check httpd path 
# whereis httpd
2. check link shortcut already listed
#ldd /usr/local/sbin/httpd

eg :  libpcre.so.0 => not found

have to change this -> libpcre.so -> libpcre.so.3 to libpcre.so.0 -> libpcre.so.3

# ln -s libpcre.so.3 libpcre.so.0

Then ok.. :) 


Monday, December 5, 2011

Patching FreeBSD server

1. cvsup : is a software package for updating collections of files across a
network.
Firstly, we have to update all the files;
# cvsup -h cvsup.freebsd.org -g -L2 /usr/share/examples/cvsup/ports-supfile - NO LONGER (Deprecated)

portsnap : is a fast and user-friendly tool for retrieving the Ports Collection, the preferred choice for most users.
1. Download a compressed snapshot of the Ports Collection

# portsnap fetch
2.When running Portsnap for the first time, extract the snapshot
# portsnap extract
3. #cd
-> since it will reset your node point.

2. portaudit: provides a system to check if installed ports are listed in a
database of published security vulnerabilities.
# portaudit -Fda
Secondly, we can check which ports and packages that need to upgrade;

3. To find out version that currently be used;
# pkg_info

4. To find out updated version that currently available;
# ee {path of the ports}
eg: ee /usr/ports/www/apache22/Makefile ; easy editor (ee) ->utility is a simple screen oriented text editor

5. To find out where is the path of package or port.
# whereis {package name}
eg: # whereis perl
p/s: sometimes it cannot search... so you have to check it by yourself.

6. portupgrade: is a tool set for working with ports and packages.
It enhances abilities of system tools and adds many new ones.
# portupgrade {path of the package}
eg: # portupgrade /var/db/pkg/sudo ;eg for upgrade sudo

7. If cannot upgrade: read the error occur;
eg:
A. need to reinstall;
pwd at the package;
i. # make config
to find out the custom option of configuration.
ii. # make install or # make reinstall
to install the package

B. need to delete the package before reinstall;
pwd at the package;
i. # make deinstall
to deinstall the pakage.

C. cannot fetch the new package;
pwd at the package;
i. # fetch {http://...}

8. php error at date.time zone
A. # cd usr/local/etc/
# ee php.ini
--> search date.time format
setting : http://www.php.net/manual/en/timezones.asia.php
then change add "eg: date.timezone = "Asia/Kuala_Lumpur""

9. Find folder
eg: if you want to search php folder
# ls -d php*