Archive for the 'Server' Category

NFS file sharing

Here’s how you share files between two Linux machines, using NFS.


Installation

  • Go to the Synaptic Package Manager
  • Find nfs-kernel-server and install


Configuration in machine 1
(where the shared folder is)

  • Define the shares you want to provide
sudo vi /etc/exports
  • Add your shares to the file
/home/mach1user/Public *(ro,sync)
/home/mach1user/Documents 100.000.00.01(ro,sync,no_subtree_check)
/home/mach1user/Share 100.000.00.01/20(rw,sync,no_subtree_check)
  • Make your changes be known
sudo exportfs -a


Configuration in machine 2
(where the shared folder are going to be accessed)

  • Create a folder, where the share will be mounted
mkdir /home/mach2user/HomeNetwork/Public
mkdir /home/mach2user/HomeNetwork/Documents
mkdir  /home/mach2user/HomeNetwork/Share
  • Mount the shares (the IP is from machine 1)
sudo mount 100.000.0.05:/home/mach1user/Public /home/mach2user/HomeNetwork/Public
sudo mount 100.000.0.05:/home/mach1user/Documents /home/mach2user/HomeNetwork/Documents
sudo mount 100.000.0.05:/home/mach1user/Share /home/mach2user/HomeNetwork/Share
  • Make the shares available after rebooting
sudo vi /etc/fstab
  • Add to the file (the IP is from machine 1)
100.000.0.05:/home/mach1user/Public /home/mach2user/HomeNetwork/Public nfs ro,hard,intr 0 0
100.000.0.05:/home/mach1user/Documents /home/mach2user/HomeNetwork/Documents nfs ro,hard,intr 0 0
100.000.0.05:/home/mach1user/Share /home/mach2user/HomeNetwork/Share nfs ro,hard,intr 0 0

And that should do it.


Further reading

last updated: 01-05-2008

___________________________________________________________________________________________________

Apache, PHP and MySQL (updated)

Ok, setting up Apache, PHP and MySQL is super easy. I used this tip from Ubuntu Forum.
I also want to import my site and database from Windows.


Install

  • Go to System > Administration > Synaptic Package Manager
  • Now go to Edit > Mark Packages by Task
  • Choose LAMP Server (Linux/Apache/MySQL/PHP server)

In my case, the Ultimate Edition already had this installed :-)
I just updated Apache, MySQL and PHP using System > Administration > Update Manager.

Now I’m going to install PHPMyAdmin (very useful):

  • Go to System > Administration > Synaptic Package Manager
  • Find by phpmyadmin
  • Install


Get database and site from Windows

Ultimate Edition already had this installed as well :-)
I marked it to update though.

Now I need to install my Apache/MySQL/PHP solution I had under Windows.
How difficult (easy) will it be?

  • Get from Windows the PHP folder mysite
  • Get from Windows the MySQL database folder mydatabase
  • In the Terminal (this will open the default Apache site location)
sudo nautilus /var/www
  • Now copy the mysite folder here
  • In the Terminal (this will open the default MySQL database location)
sudo nautilus /var/lib/mysql
  • Now copy the mydatabase folder here
  • In the Terminal (this will change your admin password)
sudo mysqladmin -u root password NEWPASSWORD
-- NEWPASSWORD must be the same from your Windows config
  • In your favorite browser type
http://localhost/mysite

Still, there’s a problem. The database is read-only. But is easy to fix:

  • Go to http://localhost/myphpadmin and login as root
  • Select your database in the left pane
  • Go to Export
  • Select the Add DROP TABLE / DROP VIEW option
  • Click the Go button
  • Copy the generated script (it includes the insert statements) to your favorite text editor
  • Add the following to the script, before the first drop table statement, replacing mydatabase with your database name and save the script
USE mydatabase;
  • Delete the mydatabase folder copied from Windows
sudo rm -R /var/lib/mysql/mydatabase/
  • In myphpadmin go to the home page (first icon in the left pane)
  • Create a New Database with the same name from the previous, mydatabase
  • In myphpadmin go to the Query Window (third icon in the left pane)
  • In the Query Window go to Import and browse to your script file
  • Click the Go button and that’s it, your database is ready to go


Post Update

After upgrading to Hardy Heron I had to reinstall the LAMP server. After the installation, when I accessed my index.php file, Firefox tried to download it.

I had to link the PHP module files to the mods-enabled Apache directory in order to get it going:

  • Link the PHP modules do the mods-enabled Apache directory
cd /etc/apache2/mods-enabled/
sudo ln -s ../mods-available/php5.load .
sudo ln -s ../mods-available/php5.conf .
  • Restart Apache
sudo /etc/init.d/apache2 restart
  • Clean browser cache (Ctrl+Shift+Del in Firefox)

And that was it.

original post: 20-03-2008
last updated: 28-04-2008

___________________________________________________________________________________________________

Sharing Files with Windows

For sharing files with Windows you just have to follow this steps:

Got to System > Administration > Shared Folders

  • in the Shared Folders tab add the folders you wish to share
  • in the General Properties tab type the Workgroup of your Network (as in Windows)

In the Terminal add yourself as a Samba user:

sudo smbpasswd -a yourusername

That’s it. You can now access your shared folder using you Linux user.


Further reading

last updated: 21-03-2008

___________________________________________________________________________________________________