Sunday, March 21, 2010

Configuring samba server on Ubuntu (from command line)

This is a basic tutorial which aims to configure samba on an Ubuntu (debian) machine and create a network user for it. Later when I am not as lazy, I will probably elaborate on this, but for the moment this will atleast get you started.


Run the following commands to install and configure samba server. Each command is preceded by the description for it.

Install samba server and dependencies

sudo apt-get install samba

add a default group for accessing samba
sudo groupadd samba-group

create an user for accessing samba and add it to the group created earlier (this will prompt for a password which will be your samba password)
sudo useradd --gid samba-user --shell /bin/false samba-group --home /nonexistent

add the user to the samba password file
sudo smbpasswd -a samba-user

change to your home (cd also works)
cd $HOME

create the share folder
mkdir shared-folder

change the ownership for the share folder and give apt permissions
sudo chown YourUserNameHere:samba-group shared-folder

sudo chmod 775 shared-folder
sudo chmod g+s shared-folder

edit the samba configuration file (i just happen to like vim, but you can use any editor)
sudo vim /etc/samba/smb.conf

in this file

  • Delete the ; in front of security = user, i.e. change to -

security = user,

  • Add the following to the end of the "Share Definitions" section.
    (You will need to change: path = /home/YourUserNameHere/shared-folder).

[sharer]

path = /home/YourUserNameHere/shared-folder

valid users = samba-user

read only = No

create mask = 0777

directory mask = 0777


Now we are done. You should be able to access the samba share from windows system by giving the IP/shared-folder (for e.g. type \\192.168.0.120\shared-folder in start->run). Use the username/password as samba-user/.

Saturday, March 20, 2010

Install PHP-Oracle bridge in Linux

Note: These instructions are for 32-bit ubuntu 9.0.4 machine. Make sure you download the appropriate packages according to system.

Install the instantclient and configure it

Download the Basic and the SDK packages for oracle from:

Now run the following commands on the shell. Descriptions for each command precede them:


Create a folder to unzip the files

# mkdir -p /opt/oracle/instantclient


Go to the created folder

# cd /opt/oracle/instantclient


Unzip the basic and sdk zip files

# unzip instantclient-basic-linux32-10.2.0.1-20050713.zip

# unzip instantclient-sdk-linux32-10.2.0.1-20050713.zip

Add instant-client information to ldconfig

# echo /opt/oracle/instantclient/instantclient_10_2 >> /etc/ld.so.conf

# ldconfig


Go to the unzipped instantclient folder

# cd /opt/oracle/instantclient/instantclient_10_2


Manually create symlinks named libclntsh.so and libocci.so as mentioned below.

# ln -s libclntsh.so.10.1 libclntsh.so

# ln -s libocci.so.10.1 libocci.so


Download the oci8 module with pear.

Pear is in the php5-pear package. You need php5-dec package for phpize

# sudo apt-get install php5-pear php5-dev

Create a folder to install oci8

# mkdir -p /usr/local/src

Change to the created folder

# cd /usr/local/src

Download the oci8 module

# wget http://pecl.php.net/get/oci8-1.3.5.tgz


Extract the tar contents

# tar xzvf oci8-1.3.5.tgz

Change to the extracted folder

# cd oci8-1.3.5

Run phpize

# phpize

Configure oci8 with instantclient, make and make install

# ./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient/instantclient_10_2/

# make

# make install


To enable the oci8 module for php, edit /etc/php5/apache2/php.ini

and put this line after the examples starting with ;extension

[OCI8]

extension=oci8.so

Restart Apache.

# sudo service apache2 restart

You should be able to see the oci8 module in the output of phpinfo().