Πέμπτη 14 Απριλίου 2011

Setting Up the Apache Web Server Under Linux

Where To Get Apache

The obvious place to get the latest version of Apache is off of the Apache web site: http://www.apache.org. The source distribution file is apache_1.1.1.tar.gz while the Linux ELF binaries is apache_1.1-linux-ELF.tar.gz. Grab what you find is necessary...
If you are running Red Hat Linux 4.0 like I am, during the installation process you are allowed to select whether or not you want to install a web server. If you do, Red Hat 4.0 includes the latest Apache and installs everything automatically with a default configuration. This default configuration even RUNS correctly without any modifications! However, even in this case, please read my notes and preferences regarding installation in the next section.
Typically, unless you need to add special modules or features, the binary distribution or the default Red Hat installation should be fine. However, let's say you wanted to run Apache as a proxy server. In this case, you would need the source so you can compile the proxy module as part of the binary.
(Note: I have heard rumors that the binary included with Red Hat 4.0 has some bugs. I have yet to encounter any myself, so take that rumor with a big grain of salt.)


Installation

I'm not going to cover compiling Apache since it's actually a fairly painless process and pretty well documented. Given that, let's move on to actual installation...
Personally, I like to group all the web server files together in a centralized location. If you are installing this manually, then this is something you can do from the outset, and I highly suggest doing this since it will reduce administration headaches.
If you had Apache installed automatically as part of the Red Hat installation procedure, then things will NOT be centralized! In fact, I thought the file placement scheme was one of the most confusing I've ever encountered. Here's what the Red Hat installation does:
web server binaries /usr/sbin/httpd
/usr/sbin/httpd_monitor
config files /etc/httpd/conf/*
log files /etc/httpd/logs/*
web server root
(contains cgi, icons/images, and html files)
/home/httpd/*
I found this to be really disorganized, so I ended up putting mostly everything under one directory (I left the binaries in /usr/sbin):
mkdir /httpd
    mv /etc/httpd/conf /etc/httpd/logs /home/httpd/* /httpd
    rmdir /home/httpd
You should end up with:
/httpd/
          /cgi-bin
          /cgi-src
          /conf
          /html
          /icons
          /logs
And then to preserve the original Redhat file locations:
ln -s /httpd /home/httpd
    ln -s /httpd/conf /etc/httpd/conf
    ln -s /httpd/logs /etc/httpd/logs
Finally, I added this link since I felt that it made more sense:
ln -s /httpd/logs /var/log/httpd
If you are installing and compiling Apache manually, you may want to have the original source files also located under /httpd (or whichever directory you have).


Configuration

Apache has three main configuration files: access.conf, httpd.conf, and srm.conf. If you are running Red Hat 4.0, these files will already be set with the correct directory paths. If you centralized the locations of all these files, but made those symbolic links as I mentioned above, things will still be fine since the symbolic links preserves where Red Hat installed everything.
If you are doing a "generic" installation or have some other setup, then you will need to do the following:
In access.conf, change/update these directory entries:

    
In httpd.conf:
ServerRoot /httpd
In srm.conf:
DocumentRoot /httpd/html
    Alias /icons/ /httpd/icons/
    ScriptAlias /cgi-bin/ /httpd/cgi-bin/
Essentially, these are the necessary directives in the config files that need to be updated with the new "centralized" organization.
For further configuration options, I will have to give the standard statement, "Please refer to the docs." :)


Starting/Running the Web Server

To make a long story short, you simply to need to execute the binary "httpd". Typically, this is done when the system starts up, in one of the rc files.
In Red Hat 4.0, it has more of a System V'ish startup style. In /etc/rc.d/init.d resides httpd.init, which is the script used to start and stop httpd. You can also execute this by hand if you find the need.
For other systems (or a manual install), I suggest starting httpd after most other services have started (i.e.: put it in rc.local). A simple line such as
/usr/sbin/httpd &
will suffice.
Obviously, it must start after tcp/ip networking has been started. :)

Read more...

Τρίτη 12 Απριλίου 2011

simple linux commands part

Read more...

simple linux commands part

Read more...

Network Time Protocol (NTP) Server and Clients Setup in Ubuntu

The Network Time Protocol (NTP) is a protocol for synchronizing the clocks of computer systems over packet-switched, variable-latency data networks. NTP uses UDP port 123 as its transport layer. It is designed particularly to resist the effects of variable latency (Jitter).

Using NTP is a great way to keep your system clock set correctly. It works by contacting a number of servers around the world, asking them for the time and then calculating what the correct local time is from their responses.
If you have install ntpdate package before you need to uninstall using the following command
sudo aptitude remove ntpdate
Install NTP server in Ubuntu
sudo aptitude install ntp
This will install all the required packages for NTP.
Configure NTP Server
The configuration file for ntpd is located at /etc/ntp.conf. The default Ubuntu file probably requires some modification for optimal performance.You need to edit the /etc/ntp.conf file using the following command
sudo nano /etc/ntp.conf
do the following changes shown in this example
Example Configuration
You need to add a number of servers to the server list. The Debian default is pool.ntp.org which works but isn’t always amazingly accurate because it makes no attempt to use time servers near you. If you want more accuracy use the time servers either on your continent (for instance europe.pool.ntp.org) or your country (for instance uk.pool.ntp.org) one of your local country servers.The optimal number of servers to listen to is three but two will also give a good accuracy. If your ISP runs a time server for you it is worth including it in your server list as it will often be more accurate than the pooled servers and will help keep the load down on the pool.
I am using the following two servers for my configuration
server ntp0.pipex.net
server ntp1.pipex.net
Restrict the type of access you allow these servers. In this example the servers are not allowed to modify the run-time configuration or query your Linux NTP server.
restrict otherntp.server.org mask 255.255.255.255 nomodify notrap noquery
restrict ntp.research.gov mask 255.255.255.255 nomodify notrap noquery
The mask 255.255.255.255 statement is really a subnet mask limiting access to the single IP address of the remote NTP servers.
If this server is also going to provide time for other computers, such as PCs, other Linux servers and networking devices, then you’ll have to define the networks from which this server will accept NTP synchronization requests. You do so with a modified restrict statement removing the noquery keyword to allow the network to query your NTP server. The syntax is:
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
In this case the mask statement has been expanded to include all 255 possible IP addresses on the local network.
We also want to make sure that localhost (the universal IP address used to refer to a Linux server itself) has full access without any restricting keywords
restrict 127.0.0.1
Save the file and exit
Now you need to restart NTP server for these settings to take effect using the following command
sudo /etc/init.d/ntp restart

Determining If NTP Is Synchronized Properly

Use the ntpq command to see the servers with which you are synchronized. It provided you with a list of configured time servers and the delay, offset and jitter that your server is experiencing with them. For correct synchronization, the delay and offset values should be non-zero and the jitter value should be under 100.
sudo ntpq -np
In the output of above command A star by any one of the chosen server names means that the system clock is synchronising with the NTP clock. If you don’t have a star (as in the example above) it means that the clocks are unreachable, already synchronized to this server or has an outrageous synchronization distance. Try running ntpdate (you will need to stop the ntp server) with your first ntp server as an argument. This will set your system clock fairly accuratly and mean that the server will be able to choose a clock to synchronize with.
Firewall Configuration for NTP
NTP servers communicate with one another using UDP with a destination port of 123. Unlike most UDP protocols, the source port isn’t a high port (above 1023), but 123 also. You’ll have to allow UDP traffic on source/destination port 123 between your server and the Stratum 1/2 server with which you are synchronizing.

NTP Linux Client Configuration

If you want to configure ntp client you need to install the following packages
sudo aptitude install ntp ntp-simple ntpdate
Configuring NTP client
You need to edit the /etc/ntp.conf file you need to point the following settings to NTP server ip address
sudo nano /etc/ntp.conf
Server configuration settings
server 192.168.1.1
Restrict the type of access you allow these servers. In this example the servers are not allowed to modify the run-time configuration or query your Linux NTP server.
restrict default notrust nomodify nopeer
Localhost configuration
restrict 192.168.1.1
In this case the mask statement has been expanded to include all 255 possible IP addresses on the local network.
We also want to make sure that localhost (the universal IP address used to refer to a Linux server itself) has full access without any restricting keywords
restrict 127.0.0.1
Now you need to save and exit the file
Run ntpdate command against your server
sudo ntpdate 192.168.1.1
Restart ntp service using the following command
sudo /etc/init.d/ntp restart
Windows Clients Configuration
Windows machines use a simplified version of NTP called Simple Network Time Protocol (SNTP), and can synchronize with NTP servers. In order to synchronize with your new server, double click on the time and go to the “Internet Time” tab. Put the IP address of your server in the “Server” field.
or
You can download Automachron from here and install in your windows xp/2000 machines
Read more...

Δευτέρα 11 Απριλίου 2011

FREEBSD graphical enviroment

 GNOME

 About GNOME

GNOME is a user-friendly desktop environment that enables users to easily use and configure their computers. GNOME includes a panel (for starting applications and displaying status), a desktop (where data and applications can be placed), a set of standard desktop tools and applications, and a set of conventions that make it easy for applications to cooperate and be consistent with each other. Users of other operating systems or environments should feel right at home using the powerful graphics-driven environment that GNOME provides. More information regarding GNOME on FreeBSD can be found on the FreeBSD GNOME Project's web site. The web site also contains fairly comprehensive FAQs about installing, configuring, and managing GNOME.

 Installing GNOME

The software can be easily installed from a package or the Ports Collection:
To install the GNOME package from the network, simply type:
# pkg_add -r gnome2
To build GNOME from source, use the ports tree:
# cd /usr/ports/x11/gnome2
# make install clean
For proper operation, GNOME requires the /proc filesystem to be mounted. Add
proc           /proc       procfs  rw  0   0
to /etc/fstab to mount procfs(5) automatically during startup.
Once GNOME is installed, the X server must be told to start GNOME instead of a default window manager.
The easiest way to start GNOME is with GDM, the GNOME Display Manager. GDM is installed as part of the GNOME desktop, although it is disabled by default. It can be enabled by adding this line to /etc/rc.conf:
gdm_enable="YES"
Once you have rebooted, GDM will start automatically.
It is often desirable to start all GNOME services together with GDM. To achieve this, add the following line to /etc/rc.conf:
gnome_enable="YES"
GNOME may also be started from the command-line by properly configuring a file named .xinitrc. If a custom .xinitrc is already in place, simply replace the line that starts the current window manager with one that starts /usr/local/bin/gnome-session instead. If nothing special has been done to the configuration file, then it is enough simply to type:
% echo "/usr/local/bin/gnome-session" > ~/.xinitrc
Next, type startx, and the GNOME desktop environment will be started.
Note: If an older display manager, like XDM, is being used, this will not work. Instead, create an executable .xsession file with the same command in it. To do this, edit the file and replace the existing window manager command with /usr/local/bin/gnome-session:
% echo "#!/bin/sh" > ~/.xsession
% echo "/usr/local/bin/gnome-session" >> ~/.xsession
% chmod +x ~/.xsession
Yet another option is to configure the display manager to allow choosing the window manager at login time; the section on KDE details explains how to do this for kdm, the display manager of KDE.

KDE

 About KDE

KDE is an easy to use contemporary desktop environment. Some of the things that KDE brings to the user are:
  • A beautiful contemporary desktop
  • A desktop exhibiting complete network transparency
  • An integrated help system allowing for convenient, consistent access to help on the use of the KDE desktop and its applications
  • Consistent look and feel of all KDE applications
  • Standardized menu and toolbars, keybindings, color-schemes, etc.
  • Internationalization: KDE is available in more than 40 languages
  • Centralized, consistent, dialog-driven desktop configuration
  • A great number of useful KDE applications
KDE comes with a web browser called Konqueror, which is a solid competitor to other existing web browsers on UNIX® systems. More information on KDE can be found on the KDE website. For FreeBSD specific information and resources on KDE, consult the KDE on FreeBSD team's website.
There are two versions of KDE available on FreeBSD. Version 3 has been around for a long time, and is very mature. Version 4, the next generation, is also available in the Ports Collection. They can even be installed side by side.

 Installing KDE

Just as with GNOME or any other desktop environment, the software can be easily installed from a package or the Ports Collection:
To install the KDE3 package from the network, simply type:
# pkg_add -r kde
To install the KDE4 package from the network, simply type:
# pkg_add -r kde4
pkg_add(1) will automatically fetch the latest version of the application.
To build KDE3 from source, use the ports tree:
# cd /usr/ports/x11/kde3
# make install clean
To build KDE4 from source, use the ports tree:
# cd /usr/ports/x11/kde4
# make install clean
After KDE has been installed, the X server must be told to launch this application instead of the default window manager. This is accomplished by editing the .xinitrc file:
For KDE3:
% echo "exec startkde" > ~/.xinitrc
For KDE4:
% echo "exec /usr/local/kde4/bin/startkde" > ~/.xinitrc
Now, whenever the X Window System is invoked with startx, KDE will be the desktop.
If a display manager such as XDM is being used, the configuration is slightly different. Edit the .xsession file instead. Instructions for kdm are described later in this chapter.

More Details on KDE

Now that KDE is installed on the system, most things can be discovered through the help pages, or just by pointing and clicking at various menus. Windows® or Mac® users will feel quite at home.
The best reference for KDE is the on-line documentation. KDE comes with its own web browser, Konqueror, dozens of useful applications, and extensive documentation. The remainder of this section discusses the technical items that are difficult to learn by random exploration.

The KDE Display Manager

An administrator of a multi-user system may wish to have a graphical login screen to welcome users. XDM can be used, as described earlier. However, KDE includes an alternative, kdm, which is designed to look more attractive and include more login-time options. In particular, users can easily choose (via a menu) which desktop environment (KDE, GNOME, or something else) to run after logging on.
To enable kdm, different files need to be edited depending on the version of KDE.
For KDE3, the ttyv8 entry in /etc/ttys has to be adapted as follows:
ttyv8 "/usr/local/bin/kdm -nodaemon" xterm on secure
For KDE4, you have to add the following lines to /etc/rc.conf:
local_startup="${local_startup} /usr/local/kde4/etc/rc.d"
kdm4_enable="YES"

 Xfce

 About Xfce

Xfce is a desktop environment based on the GTK+ toolkit used by GNOME, but is much more lightweight and meant for those who want a simple, efficient desktop which is nevertheless easy to use and configure. Visually, it looks very much like CDE, found on commercial UNIX systems. Some of Xfce's features are:
  • A simple, easy-to-handle desktop
  • Fully configurable via mouse, with drag and drop, etc.
  • Main panel similar to CDE, with menus, applets and applications launchers
  • Integrated window manager, file manager, sound manager, GNOME compliance module, and more
  • Themeable (since it uses GTK+)
  • Fast, light and efficient: ideal for older/slower machines or machines with memory limitations
More information on Xfce can be found on the Xfce website.

 Installing Xfce

A binary package for Xfce exists (at the time of writing). To install, simply type:
# pkg_add -r xfce4
Alternatively, to build from source, use the Ports Collection:
# cd /usr/ports/x11-wm/xfce4
# make install clean
Now, tell the X server to launch Xfce the next time X is started. Simply type this:
% echo "/usr/local/bin/startxfce4" > ~/.xinitrc
The next time X is started, Xfce will be the desktop. As before, if a display manager like XDM is being used, create an .xsession, as described in the section on GNOME, but with the /usr/local/bin/startxfce4 command; or, configure the display manager to allow choosing a desktop at login time, as explained in the section on kdm.
Read more...