Thursday, 10 December 2015

Linux Boot Process


Linux Boot Process

 

In this article we are going to study “Linux Boot Process”. During booting time of Linux operating system, boot process have to go through six basic stages.

Boot Stage 1:

BIOS Checks: When a Linux server or desktop or laptop booted, The processor goes for Basic Input/Output System or BIOS program and runs it.The BIOS controls does not controll only the first step of the boot process, but BIOS also provides the lowest level interface to peripheral devices. It means during the BIOS initialization, all hardware peripheral devices checked out by BIOS. If BIOS found any hardware is faulty, you will get message on your screen.For this reason BIOS Process is written into read-only mode.The BIOS then loads into memory whatever program is residing in the first sector of this device, called the Master Boot Record or MBR. The MBR is only 512 bytes in size and contains machine code instructions for booting the machine, called a boot loader, along with the partition table. Once the BIOS finds and loads the boot loader program into memory,it yields control of the boot process to it.

Note: The default boot loader for Linux platform is GRUB.

Boot Stage 2:

First stage boot loader: The first stage of Boot Loader is a small machine code binary on MBR. The first stage boot loader loads itself into memory.first stage boot loader job is to find out the second stage boot loader and load the first part of it into memory.

Boot Stage 3:

Second stage boot loader: The second stage boot loader loads the kernel into memory, which in turn loads any necessary modules and mounts the root partition read-only. Once the second stage boot loader is in memory, it presents the user with a graphical screen showing the different operating systems or kernels that has been configured to boot. You can use Arrow keys to select your operating system for boot.

Stage 3.5: the Second Stage Bootloader loads the Linux Kernel and hands control to it. The Kernel takes control of the hardware. This includes taking control of the memory management hardware, timers, interrupts, etc. The processor is no longer in x86 16-bit mode like it was when the BIOS started. The kernel will start using other processors and/or additional cores within processors. Linux may have some modules pre-compiled into the kernal, and may also load some modules from disk as needed, such as device driver modules that apply to the actual hardware present on this system. Once the kernel is fully running, it starts a single user space process, which is the ancestor of all processes: /sbin/init. Up until this point, all Linux systems work very similarly. Once /sbin/init begins, this is where the major differences between distributions become highly visible.

Boot Stage 4:

INIT Program: The Linux operating system kernel transfers the control of the boot process to the /sbin/init program.The /sbin/init program  coordinates the rest of the boot process and configures the environment for the user.

Boot Stage 5:

User Environment Setup: The init program loads all services and user-space tools, and mounts all partitions listed in /etc/fstab. When the init command starts, it becomes the parent or grandparent of all of the processes that start up automatically on the system. First, it runs the /etc/rc.d/rc.sysinit script, which sets the environment path, starts swap, checks the file systems, and executes all other steps required for system initialization.The init command then runs the /etc/inittab script, which describes how the system should be set up in each SysV init runlevel.The init program starts all of the background processes by looking in the appropriate rc directory for the runlevel specified as the default in /etc/inittab. The rc directories are numbered to correspond to the runlevel they represent.

Note: By Default, run level 5 is defined in /ete/inittab file.

Boot Stage 6:

Login Screen: The user will get a login screen for the freshly booted Linux system.

 

Tuesday, 12 May 2015

Linux Interview Questions For Experienced

Why should you periodically update the kernel and package versions?
To enhance the security of system you should ensure that you are using the latest versions kernel and software packages that contain the most recent security updates.
During a recent strikes at office, several archive tapes of the system were damaged and ruined. What can you do to prevent the physical damage in future?
You should store them at offsite.
Why should you avoid the Telnet to administer a Linux system remotely?
Telnet use most insecure method for communication. It send data across the network in plain text format. Someone easily find out the password using the network tool.
A file is unable to be restored from tape due to several device and media errors. What is most likely the cause?
Media errors usually indicate that the tape media is damaged, or that the tape drive heads need cleaning.
Your FTP Server recently hacked. Due to the amount of damage, the entire server needs to be restored. How should you restore the original kernel system files?
You cannot restore the entire operating system from tap back up device. So you should reinstall the core operating system, and then restore system configuration files and user data from tape backup device.
Your company hire a contract employee for two months. What should the Linux administrator do to enhance security on the employee's account?
While creating new user account for this user, administrator should set the expiration date for his account, so that if the employee leaves or does not have their contract renewed, the account will be automatically disabled.
Which backup strategy only backs up files that have changed since the last full backup?
Differential backup will backup files that have changed since the last full backup.
Name a service which should you disable on a Linux Server which is acting as both a Web and FTP Server.
The finger service should be disabled because a remote user can get important information about the system by using that command.
Why it is recommended to store backup tapes to an offsite storage facility?
Because this will prevent the backup taps from being destroyed during a natural disaster at the server site. It also prevents the tapes from being stolen.
A newbie enabled the root session for FTP server. is it ok?
No, he has put the security of entire server on risk. You should disable to root session as soon as possible.
A user complains you that he is unable to set '123' as his password. Why would not the system allow this password?
There would be a minimum length rule for password, which is blocking user to use this password. Default minimum length rule for password is six characters. It means a user cannot have password less than six characters.
Your company is running Web Server. One dedicate account holder customer complains that his visitors are able to scan the directory tree. Which directive would you configure to stop web server from listing the directory?
You should remove / comment the "Options Indexes" directive from the main configuration file ' httpd.conf' of the web server. This is a security measure so that remote users can’t scan the directory tree of the server looking for security holes. Server won’t show directory listings if requested by a user.
What type of backup strategy can you use to fully back up a system every night?
You can use full backup strategy that will always perform a full backup of all files. This takes much more time and space than other methods, but is it the most complete method and allows for easy file restoration.
How can you enhance the security of password file?
Linux keep user account information in a text file called /etc/passwd. This file also store one way encrypted password. This file is accessed by several tools to get user information, so file need to world readable. This is a security risk. To minimize the security risk you can use shadow password format. This method save account information in regular file /etc/passwd. However, the password is stored as a single "x" character (not actually stored in this file). A second file, called "/etc/shadow", contains encrypted password as well as other information such as account or password expiration values, etc. The /etc/shadow file is readable only by the root account and is therefore less of a security risk
What command should be used to make a tar archive to a disk file system located in /mnt/backup?
The correct command is tar -cvf /mnt/backup. The /mnt/backup directory should be on another machine to be fully effective as a backup strategy.
You have just finished the installation of sever. This server is going to be use as file server. Default installation have send mail service running, while this server will never send any e-mails. How should you deal with send mail service?
You should disable the send mail service if server is not being used for mail purpose. Leaving them running can increase the chance of a security vulnerability being exploited, and unauthorized use of sendmail relay.
What command can you use to back up an entire file system most efficiently?
The easiest command to use to back up an entire file system is the dump command. Files can be restored from a dump operation by using the restore command.
Which necessary steps should you take to enhance the security of server just after the initial installation?
  • Kernel and packages should be upgraded to the latest versions.
  • Unnecessary services and daemons should be disable.
  • Enable and configure firewall
  • Set a complex password policy.
While auditing user accounts, an administrator notices that one of the users has a blank password. What should he do to the account?
To prevent further use of the account, which is an immediate security risk, disable it and set a temporary password for the user for the next time they login.
Which backup strategy backs up all files that have changed since the last backup?
An incremental backup will only back up files that have changed since the last backup.
Your company has terminated a server administrator. What is first thing as an administrator should you do to enhance the security?
Because the server administrator knows the root password for the server, it should be changed immediately to prevent them from tampering with the system.
You are setting up an FTP server. Only company employees are allowed to use the FTP services. What should you configure on the FTP server to enhance security?
You should disable the anonymous FTP account, so that only users with a username and password can access the system.
What is the location of system configuration files that should be backed up on a regular basis?
The /etc directory contains most of the Linux system configuration files.
Which permission allows a user to run an executable with the permissions of the owner of that file?
The Set-User-ID is a special permission that allows a user to run an executable with the permissions of the owner of that file.
What command can you use to make a tape archive file of a /home directory, and send it to the /dev/tape device?
The correct command is tar -cvf /dev/tape /home.
The -xvf option is used to extract files from an archive.
Employees at your company are lazy in changing the password. As a system administrator what can you do to minimize the security risk?
You can setup a password policy which enforce user to change his password after a specific time periods.
Which program should you use to connect a system remotely?
You should always use SSH to connect a system remotely. SSH is a secure method that encrypts the entire session.
To save disk space, an administrator wants to backup files, and then remove them from the server permanently. What kind of backup operation is this?
An archive operation will take the files, back them up to a device, and then remove the files from the original server.
What does firewall do?
Firewall is a device or service which can be used to protect the network or system from other outside networks.

Wednesday, 22 April 2015

linux interview questions FOR RHCE

Which version of RHEL officially supports LUKS encryption?

From version 6 or higher LUKS encryption is officially supported by RHEL.

What is the default virtualization technology for RHEL6 ?

Default virtualization technology is KVM.

Can you configure KVM Virtual machine on 32 bit system ?

No, KVM virtualization requires at least 64 bit system.

What is default mode of SELinux during the installation of RHEL ?

  • In RHEL5 you have to choose the mode which you want.
  • From RHEL6 default mode is Enforcing during the installation.
However you can change the mode of SELinux after installation, only difference between RHEL5 and RHEL6 is that in RHEL5 asks you to choose the mode while RHEL6 does not let you to choose the mode during the installation.

Which remote management service is allowed through the default firewall and by default installed in RHEL?

By default SSH is always installed in RHEL. SSH uses port 22 which is allowed through the default firewall rules.

Which standard directory is used by vsFTP server for file sharing ?

Default Standard directory for ftp is /var/ftp/pub.

Which standard directory is used by Apache web server for HTML files ?

standard directory for HTML files is /var/www/html

What is the default partition layout during the installation ?

Default partition Layout is the LVM.

Which necessary partition cannot be a part of logical volume group ?

boot partition cannot be a part of logical volume group. You must have create it as a regular partition.

Which partitions are recommended for custom layout of partition ?

  • /
  • /boot
  • /home
  • swap

What step during the installation could you take to prevent a program from creating temporary files that fill up the entire space ?

You can create a separate /tmp partition prevents a program from creating temporary files that fill up the entire filesystem.

What is the kickstart ?

kickstart is a installation method used in RHEL. A kickstart installation is started from a kickstart file, which contains the answers to all the questions in the installation program.

Name any of two third party distribution based on RHEL6 source code.

CentOS and Scientific Linux

Which Log file contains all installation message?

install.log.syslog file contains all messages that were generated during the installation.

Wednesday, 8 April 2015

linux interview questions 1

What is Kerberos used for?

Kerberos is used for secure network logon.
Which partition store system configuration files in Linux system?
/etc partition stores system configuration files in Linux.
What is the purpose of the MD5 option on passwords?
MD5 is an encryption method that encrypts the password before saving.
Name any four general password rules for user account.
  • Include at least eight total characters
  • Use the string in an unrepeated way
  • Avoid use words that can be found in the dictionary
  • Avoid use dates of significance, such as a birthday or anniversary
A better method of password security is to create difficult-to-break passwords that are easy for the users to remember.
What is the alternative method to a GUI installation in Linux ?
Linux provides text base installation as the alternative method of GUI installation.
What is the purpose of the swapon command ?
swapon command is used to activate a already created swap partition. It cannot be used to create a new swap partition.

What is gzip?

gzip is a compression utility created by the GNU project.

What is tar?

tar is an archive utility that is used to create tape backups.
Which is the standard command used to uncompress gzip files?
The standard command used to uncompress gzip files is gunzip.
What is the RPM switch for only installing packages?
The command line switch for installing an RPM is -i.
What is the command used to install an RPM package named demofilename2.2-2.i386.rpm?
The most common command used to install an RPM package is rpm -ivh. Following command will install the given package
#rpm -ivh demofilename2.2-2.i386.rpm
What is the command used to remove an RPM package named demofilename2.2-2.i386.rpm?
The most common command used to remove an RPM package is rpm -evh. Following command will remove the given package
#rpm -evh demofilename2.2-2.i386.rpm
What is the command used to update an RPM package named demofilename2.2-2.i386.rpm?
The most common command used to update an RPM package is rpm -Uvh. Following command will update the given package and remove the old.
#rpm -Uvh demofilename2.2-2.i386.rpm
Which command is used to see which RPM version of gzip was installed on the system?
#rpm -q gzip
Where are the automatically mounted file systems listed?
The automatically mounted file systems are listed in the file /etc/fstab.
While installing the new RPM what common steps should take ?
You should follow these common steps
  • Use RPM tools should be used to query or verify the installed packages to
  • confirm the installation of any previous packages.
  • Check the signature of new package
  • RPM should be installed or upgraded by first using the test mode to verify that it works, and then it should be installed
  • At the end query the RPM and verify the installation of RPM
Which organization controls the official releases and updates of the X Window System?
The X Consortium at www.x.org controls the official release and updating of the X Window System
PPP is most often used to create?
PPP is most often used to create serial point-to-point connections.
When attempting to connect to www.example.com you got unknown host message. Which service is most likely not functioning properly?
DNS
Samba is used to provide support for which protocol?
Samba is used to support the Microsoft SMB/CIFS systems.
What command is used to load a module into the kernel?
The insmod command is used to load a module into the kernel
Name one of the most secure method of remote access.
SSH is the most secure method of remote access
With respect to a Linux system’s RAM, how large should the swap file be?
Generally the size of the swap file should be twice the size of installed RAM.
How would you create a backup of the fstab file to the /backup folder?
Use cp command to create the backup.
#cp /etc/fstab /backup
What command is used to exit the edit mode of VI editor?
The [esc] key is used to exit from the edit mode of VI editor.
What key combination will exit from VI editor and not save the changes made?
Esc + q +! Key combination will exit VI without saving the changes.
What command would you use to create a file system on a new hard drive?
The mkfs command is used to create file systems.

What fstab file do?

The fstab file is used to automatically mount file systems.

What inittab file do?

The /etc/inittab file is used to perform the default state and terminal connections for a Linux system.
What command can you use to verify the current active shell?
The env command will display the current active shell.
Where is the file . bashrc located?
The . bashrc file is usually located in the /home/username directory.
What function does the .bash_profile file perform?
The function of the .bash_profile file is to provide login initialization commands.
What function does the .bash_logout file perform?
The function of the .bash_logout is to provide logout functions
What function does the .bashrc file perform?
The function of the .bashrc file is to provide shell configuration commands.

Wednesday, 7 January 2015

Install SquirrelMail to configure web-based mail


Install SquirrelMail to configure web-based mail transfer system like yahoo mail or hotmail.
 
www.server.world
- SquirrelMail installed Web Server

 
mail.server.world
- SMTP/IMAP Server
[1]
[2]
[3]
[4]
[5] Install SquirrelMail.
# install from EPEL

[root@www ~]#
yum --enablerepo=epel -y install squirrelmail
[root@www ~]#
wget http://www.squirrelmail.org/plugins/compatibility-2.0.16-1.0.tar.gz -P /usr/share/squirrelmail/plugins

[root@www ~]#
wget http://www.squirrelmail.org/plugins/empty_trash-2.0-1.2.2.tar.gz -P /usr/share/squirrelmail/plugins

[root@www ~]#
wget http://www.squirrelmail.org/plugins/secure_login-1.4-1.2.8.tar.gz -P /usr/share/squirrelmail/plugins

[root@www ~]#
tar zxvf /usr/share/squirrelmail/plugins/compatibility-2.0.16-1.0.tar.gz -C /usr/share/squirrelmail/plugins

[root@www ~]#
tar zxvf /usr/share/squirrelmail/plugins/empty_trash-2.0-1.2.2.tar.gz -C /usr/share/squirrelmail/plugins

[root@www ~]#
tar zxvf /usr/share/squirrelmail/plugins/secure_login-1.4-1.2.8.tar.gz -C /usr/share/squirrelmail/plugins

[root@www ~]#
rm -f /usr/share/squirrelmail/plugins/*.tar.gz

# run setup script

[root@www ~]#
/usr/share/squirrelmail/config/conf.pl

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color off
S Save data
Q Quit
Command >>
1
 
# select

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Organization Preferences
1. Organization Name
: SquirrelMail

2. Organization Logo
: ../images/sm_logo.png

3. Org. Logo Width/Height
: (308/111)

4. Organization Title
: SquirrelMail

5. Signout Page
:

6. Top Frame
: _top

7. Provider link
: http://squirrelmail.org/

8. Provider name
: SquirrelMail
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
5
 
# change log-out page
When users click the Sign Out button they will be logged out and
then sent to signout_page. If signout_page is left empty,
(hit space and then return) they will be taken, as normal,
to the default and rather sparse SquirrelMail signout page.
[]:
/webmail
   
# change log-out page

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Organization Preferences
1. Organization Name
: SquirrelMail

2. Organization Logo
: ../images/sm_logo.png

3. Org. Logo Width/Height
: (308/111)

4. Organization Title
: SquirrelMail

5. Signout Page
: /webmail

6. Top Frame
: _top

7. Provider link
: http://squirrelmail.org/

8. Provider name
: SquirrelMail
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
r
 
# back to main menu

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color off
S Save data
Q Quit
Command >>
2
 
# select

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: localhost

2. Invert Time
: false

3. Sendmail or SMTP
: Sendmail
A. Update IMAP Settings
: localhost:143 (uw)

B. Change Sendmail Config
: /usr/sbin/sendmail
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
1
 
# change to your domain name
The domain name is the suffix at the end of all email addresses. If
for example, your email address is jdoe.com, then your domain
would be example.com.
[localhost]:
server.world
 
# input your domain name

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: Sendmail
A. Update IMAP Settings
: localhost:143 (uw)

B. Change Sendmail Config
: /usr/sbin/sendmail

R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
3
 
# select
You now need to choose the method that you will use for sending
messages in SquirrelMail. You can either connect to an SMTP server
or use sendmail directly.
1. Sendmail
2. SMTP
Your choice [1/2] [1]:
2
 
# change to SMTP

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: SMTP
A. Update IMAP Settings
: localhost:143 (uw)

B. Change Sendmail Config
: localhost:25

R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
A
 
# select
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: SMTP
IMAP Settings
--------------
4. IMAP Server
: localhost

5. IMAP Port
: 143

6. Authentication type
: login

7. Secure IMAP (TLS)
: false

8. Server software
: uw

9. Delimiter
: /
B. Update SMTP Settings
: localhost:25

H. Hide IMAP Server Settings
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
4
 
# select
This is the hostname where your IMAP server can be contacted.
[localhost]:
mail.server.world
 
# specify your IMAP server

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: SMTP
IMAP Settings
--------------
4. IMAP Server
: mail.server.world

5. IMAP Port
: 143

6. Authentication type
: login

7. Secure IMAP (TLS)
: false

8. Server software
: uw

9. Delimiter
: /
B. Update SMTP Settings
: localhost:25

H. Hide IMAP Server Settings
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
8
 
# select
Each IMAP server has its own quirks. As much as we tried to stick
to standards, it doesn't help much if the IMAP server doesn't follow
the same principles. We have made some work-arounds for some of
these servers. If you would like to use them, please select your
IMAP server. If you do not wish to use these work-arounds, you can
set this to "other", and none will be used.
   bincimap
= Binc IMAP server

   courier
= Courier IMAP server

   cyrus
= Cyrus IMAP server

   dovecot
= Dovecot Secure IMAP server

   exchange
= Microsoft Exchange IMAP server

   hmailserver
= hMailServer

   macosx
= Mac OS X Mailserver

   mercury32
= Mercury/32

   uw
= University of Washington's IMAP server

   gmail
= IMAP access to Google mail (Gmail) accounts

   other
= Not one of the above servers

[uw]:
dovecot
 
# select Dovecot

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: SMTP
IMAP Settings
--------------
4. IMAP Server
: mail.server.world

5. IMAP Port
: 143

6. Authentication type
: login

7. Secure IMAP (TLS)
: false

8. Server software
: dovecot

9. Delimiter
: /
B. Update SMTP Settings
: localhost:25

H. Hide IMAP Server Settings
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
9
 
# select
This is the delimiter that your IMAP server uses to distinguish between
folders. For example, Cyrus uses '.' as the delimiter and a complete
folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would
look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'
but if you are sure you know what delimiter your server uses, you can
specify it here.
To have it autodetect the delimiter, set it to 'detect'.
[/]:
detect
 
# specify detect

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: SMTP
IMAP Settings
--------------
4. IMAP Server
: mail.server.world

5. IMAP Port
: 143

6. Authentication type
: login

7. Secure IMAP (TLS)
: false

8. Server software
: dovecot

9. Delimiter
: detect
B. Update SMTP Settings
: localhost:25

H. Hide IMAP Server Settings
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
B
 
# select
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: SMTP
SMTP Settings
-------------
4. SMTP Server
: localhost

5. SMTP Port
: 25

6. POP before SMTP
: false

7. SMTP Authentication
: none

8. Secure SMTP (TLS)
: false

9. Header encryption key
:
A. Update IMAP Settings
: mail.server.world:143 (dovecot)

H. Hide SMTP Settings
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
4
 
# select
This is the hostname of your SMTP server.
[localhost]:
mail.server.world
 
# specify SMTP server

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: SMTP
SMTP Settings
-------------
4. SMTP Server
: mail.server.world

5. SMTP Port
: 25

6. POP before SMTP
: false

7. SMTP Authentication
: none

8. Secure SMTP (TLS)
: false

9. Header encryption key
:
A. Update IMAP Settings
: mail.server.world:143 (dovecot)

H. Hide SMTP Settings
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
7
 
# select
If you have already set the hostname and port number, I can try to
automatically detect the mechanisms your SMTP server supports.
Auto-detection is *optional* - you can safely say "n" here.
Try to detect auth mechanisms? [y/N]:
y
 
# yes (auto)

Trying to detect supported methods (SMTP)...
Testing none: SUPPORTED
Testing login: SUPPORTED
Testing CRAM-MD5: NOT SUPPORTED
Testing DIGEST-MD5: NOT SUPPORTED
What authentication mechanism do you want to use for SMTP connections?
none - Your SMTP server does not require authorization.
login - Plaintext. If you can do better, you probably should.
cram-md5 - Slightly better than plaintext.
digest-md5 - Privacy protection - better than cram-md5.
*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***
If you don't understand or are unsure, you probably want "none"
none, login, cram-md5, or digest-md5 [none]:
login
 
# select login

SMTP authentication uses IMAP username and password by default.
Would you like to use other login and password for all SquirrelMail
SMTP connections? [y/N]:
n

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain
: server.world

2. Invert Time
: false

3. Sendmail or SMTP
: SMTP
SMTP Settings
-------------
4. SMTP Server
: mail.server.world

5. SMTP Port
: 25

6. POP before SMTP
: false

7. SMTP Authentication
: login (with IMAP username and password)

8. Secure SMTP (TLS)
: false

9. Header encryption key
:
A. Update IMAP Settings
: mail.server.world:143 (dovecot)

H. Hide SMTP Settings
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
r
 
# back to main menu

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color off
S Save data
Q Quit
Command >>
10
 
# select

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Language preferences
1. Default Language
: en_US

2. Default Charset
: iso-8859-1

3. Enable lossy encoding
: falsev
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
1
 
# select
SquirrelMail attempts to set the language in many ways. If it
can not figure it out in another way, it will default to this
language. Please use the code for the desired language.
[en_US]:
ja_JP
 
# specify your lang

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Language preferences
1. Default Language
: ja_JP

2. Default Charset
: iso-8859-1

3. Enable lossy encoding
: false
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
2
 
# select

This option controls what character set is used when sending
mail and when sending HTML to the browser.
This option is used only when default language is 'en_US'.
[iso-8859-1]:
iso-2022-jp
 
# specify your lang

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Language preferences
1. Default Language
: ja_JP

2. Default Charset
: iso-2022-jp

3. Enable lossy encoding
: false

R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
r
 
# back to main menu

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color off
S Save data
Q Quit
Command >>
4
 
# select

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
General Options
1. Data Directory
: /var/lib/squirrelmail/prefs/

2. Attachment Directory
: /var/spool/squirrelmail/attach/

3. Directory Hash Level
: 0

4. Default Left Size
: 150

5. Usernames in Lowercase
: false

6. Allow use of priority
: true

7. Hide SM attributions
: false

8. Allow use of receipts
: true

9. Allow editing of identity
: true

Allow editing of name
: true

Remove username from header
: false

10. Allow server thread sort
: true

11. Allow server-side sorting
: true

12. Allow server charset search
: true

13. Enable UID support
: true

14. PHP session name
: SQMSESSID

15. Location base
:
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
7
 
# select

Hide SM attributions (y/n) [n]:
y
 
# Yes

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
General Options
1. Data Directory
: /var/lib/squirrelmail/prefs/

2. Attachment Directory
: /var/spool/squirrelmail/attach/

3. Directory Hash Level
: 0

4. Default Left Size
: 150

5. Usernames in Lowercase
: false

6. Allow use of priority
: true

7. Hide SM attributions
: true

8. Allow use of receipts
: true

9. Allow editing of identity
: true

Allow editing of name
: true

Remove username from header
: false

10. Allow server thread sort
: true

11. Allow server-side sorting
: true

12. Allow server charset search
: true

13. Enable UID support
: true

14. PHP session name
: SQMSESSID

15. Location base
:
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
r
 
# back to main menu

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color off
S Save data
Q Quit
Command >>
8
 
# select

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
Available Plugins:
4. listcommands
5. filters
6. fortune
7. mail_fetch
8. message_details
9. compatibility
10. calendar
11. translate
12. sent_subfolders
13. empty_trash
14. spamcop
15. bug_report
16. abook_take
17. info
18. secure_login
19. administrator
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
9
 
# add compatibility (number is different at an env)

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
4. compatibility
Available Plugins:
5. listcommands
6. filters
7. fortune
8. mail_fetch
9. message_details
10. calendar
11. translate
12. sent_subfolders
13. empty_trash
14. spamcop
15. bug_report
16. abook_take
17. info
18. secure_login
19. administrator
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
13
 
# add empty_trash (number is different at an env)

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
4. compatibility
5. empty_trash
Available Plugins:
6. listcommands
7. filters
8. fortune
9. mail_fetch
10. message_details
11. calendar
12. translate
13. sent_subfolders
14. spamcop
15. bug_report
16. abook_take
17. info
18. secure_login
19. administrator
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
18
 
# add secure_login (number is different at an env)

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
4. compatibility
5. empty_trash
6. secure_login
Available Plugins:
7. listcommands
8. filters
9. fortune
10. mail_fetch
11. message_details
12. calendar
13. translate
14. sent_subfolders
15. spamcop
16. bug_report
17. abook_take
18. info
19. administrator
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
q
 
# quit
You have not saved your data.
Save? [Y/n]:
y
 
# save

Data saved in config.php
Exiting conf.pl.
You might want to test your configuration by browsing to
http://your-squirrelmail-location/src/configtest.php
Happy SquirrelMailing!
[root@www ~]#
cp /usr/share/squirrelmail/plugins/secure_login/config.sample.php /usr/share/squirrelmail/plugins/secure_login/config.php

[root@www ~]#
vi /usr/share/squirrelmail/plugins/secure_login/config.php
# line 24: change (continue to connect with SSL after login)

$change_back_to_http_after_login =
0
;
[root@www ~]#
/etc/rc.d/init.d/httpd reload

Reloading httpd:     [  OK  ]
[6] Access to 'http://(your server's name or IP address/)/webmail/', then follwing sacreen is shown, authenticate your user name and password to login.
[7] Just logined.

Monday, 27 October 2014

DNS SERVER CONFOGURATION

This article is a quick configuration manual of a Linux DNS server using bind. I believe that bind do not need much introduction, but before you proceed with the installation and configuration of bind nameserver make sure that bind DNS server is exactly what you want. Default setup and execution of bind on Debian or Ubuntu may take around 200MB of RAM with no zones added to the config file. Unless you reduce the memory usage of a bind via various bind "options" config settings, be prepared to have some spare RAM available just for this service. This fact is even more important if you pay for your own VPS server.

Another DNS nameservers available on a Linux systems are NSD ( Name Server Daemon) or djbdns ( tinydns ). Both are lightweight alternatives to bind9 DNS server and have less RAM requirements. Apparently are even faster.
In this article we will not go into details of what Domain Name Service ( DNS ) is nor how DNS works. Rather we simply concentrate in a simple configuration of a custom zone and config file for a given domain / host supporting www, mail services.
Sample scenario notes to help you ready this DNS bind howto:
  • nameserver IP address 192.168.135.130
  • sample domain / host: linuxconfig.org
  • authoritative nameservers for a linuxconfig.org zone: ns1.linuxconfig.org ( 192.168.0.10 ) and ns2.linuxconfig.org ( 192.168.0.11 )
  • www and mail services for linuxconfig.org will point to: 192.168.0.10

1. bind9 nameserver installation

Unless you prefer to install bind from a source code the installation is rather simple. On a Debian or Ubuntu Linux server you can install a bind nameserver with a following command:

apt-get install bind9 dnsutils
CentOS or Fedora alternative:
yum install bind dnsutils
dnsutils is not compulsory package to run bind webserver, but we will use a dig command which is part of this package as a testing tool of your bind configuration.

2. Creating a DNS zone file

At this stage we will need to create a new zone file for a domain linuxconfig.org. Navigate to /etc/bind/ directory execute following sequence of commands to navigate to zones/master/
cd /etc/bind
mkdir -p zones/master
cd zones/master/
/etc/bind/zones/master directory will contain a zone file for a linuxconfig.org domain. If you prefer to use another directory to hold this file you are free to do so. The following zone file db.linuxconfig.org will hold a DNS record to assist a nameserver resolve a fully qualified domain name to an IP address. Create and save db.linuxconfig.org with a following content:
;
; BIND data file for linuxconfig.org
;
$TTL    3h
@       IN      SOA     ns1.linuxconfig.org. admin.linuxconfig.org. (
                          1        ; Serial
                          3h       ; Refresh after 3 hours
                          1h       ; Retry after 1 hour
                          1w       ; Expire after 1 week
                          1h )     ; Negative caching TTL of 1 day
;
@       IN      NS      ns1.linuxconfig.org.
@       IN      NS      ns2.linuxconfig.org.


linuxconfig.org.    IN      MX      10      mail.linuxconfig.org.
linuxconfig.org.    IN      A       192.168.0.10
ns1                     IN      A       192.168.0.10
ns2                     IN      A       192.168.0.11
www                     IN      CNAME   linuxconfig.org.
mail                    IN      A       192.168.0.10
ftp                     IN      CNAME   linuxconfig.org.
Here is just a quick review of some lines from the above bind DNS zone file:
  • SOA Record: nameserver authoritative for a zone linuxconfig.org is ns1.linuxconfig.org and admin.linuxconfig.org is an email address of a person responsible for this DNS zone.
  • NS Records: two nameservers for a linuxconfig.org zone are ns[1,2].linuxconfig.org
  • MX ( Mail Exchange): linuxconfig.org mail exachange record. Number 10 means a preference for discarting a records A : A simply means address inanother words in linuxconfig.org's zone a ns1 would ahve a A ( address ) 192.168.0.10.
  • CNAME Record ( Canonical Name record ): restart the query using the canonical name instead of the original name

3. address-to-name mappings

At this stage the bind DNS server can resolve an IP address mapped to a linuxconfig.org host. What we should do now is the teach our nameserver the other way around, which is, to resolve a host from an IP address. For this we are going to need yet another file and that is db.192.168.0 with a following content:
PTR
;
; BIND reverse data file for 0.168.192.in-addr.arpa
;
$TTL    604800
0.168.192.in-addr.arpa.      IN      SOA     ns1.linuxconfig.org. admin.linuxconfig.org. (
                          1         ; Serial
                          3h       ; Refresh after 3 hours
                          1h       ; Retry after 1 hour
                          1w       ; Expire after 1 week
                          1h )     ; Negative caching TTL of 1 day
;
0.168.192.in-addr.arpa.       IN      NS      ns1.linuxconfig.org.
0.168.192.in-addr.arpa.       IN      NS      ns2.linuxconfig.org.

10.0.168.192.in-addr.arpa.   IN      PTR     linuxconfig.org.
  • PTR: a NDS record used for a mapping of an IP address to a host name.

4. Updating a BIND Configuration File

At this point we should have two files ready:
  • /etc/bind/zones/master/db.linuxconfig.org
  • /etc/bind/zones/master/db.192.168.0
All we need to do now is to insert both zone file names into a bind's configuration file named.conf.local. To do that add following lines into this file:
zone "linuxconfig.org" {
       type master;
       file "/etc/bind/zones/master/db.linuxconfig.org";
};

zone "0.168.192.in-addr.arpa" {
       type master;
       file "/etc/bind/zones/master/db.192.168.0";
};
Last thing before we go ahead to check a configuration is to add and IP address af a stable DNS server to a named.conf.options file. This IP address is used in case that a local DNS server do not know the answer the a name resolution query. In IP address of a DNS server in many cases is provided by your Internet provider. Alternatively if you are google fan use 8.8.8.8 or 8.8.4.4.
Replace a following blog of text withing a named.conf.options file:
       // forwarders {
       //      0.0.0.0;
       // };
with new stable DNS server IP address
        forwarders {
              8.8.4.4;
         };

5. Checking bind's zone files and configuration

Before we attempt to start a bind nameserver with a new zone and configuration here are some tools to check if we have not done some typo or misconfiguration.
To check a configuration files run a following command:
named-checkconf
With this named-checkconf command the rule is: no news are good news. If no output had been produced your config files looks OK.
To check a DNS zone files we can use named-checkzone command:
named-checkzone linuxconfig.org /etc/bind/zones/master/db.linuxconfig.org
zone linuxconfig.org/IN: loaded serial 1
OK
reverse zone file check:
named-checkzone 0.168.192.in-addr.arpa /etc/bind/zones/master/db.192.168.0
zone 0.168.192.in-addr.arpa/IN: loaded serial 2
OK

6. Start / restart bind nameserver

At this point nothing can stop us to run bind9 dns server:
 /etc/init.d/bind9 start
Starting domain name service...: bind9.
Alternatively, if your bind server is already running use a following command to to assist you with its restart:
/etc/init.d/bind9 restart
Stopping domain name service...: bind9.
Starting domain name service...: bind9.

7. Testing a bind server configuration

A dig command from dnsutils package will become handy to help us to test a new configuration of bind nameserver.
dig command can be used from any PC which has a network access the your DNS server but preferably your should start your testing from a localhost. In our this case the IP address of our name server is 192.168.135.130. First we will test host-to-IP resolution:
dig @192.168.135.130 www.linuxconfig.org

; <<>> DiG 9.6-ESV-R1 <<>> @192.168.135.130 www.linuxconfig.org
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60863
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;www.linuxconfig.org.           IN      A

;; ANSWER SECTION:
www.linuxconfig.org.    10800   IN      CNAME   linuxconfig.org.
linuxconfig.org.        10800   IN      A       192.168.0.10

;; AUTHORITY SECTION:
linuxconfig.org.        10800   IN      NS      ns2.linuxconfig.org.
linuxconfig.org.        10800   IN      NS      ns1.linuxconfig.org.

;; ADDITIONAL SECTION:
ns1.linuxconfig.org.    10800   IN      A       192.168.0.10
ns2.linuxconfig.org.    10800   IN      A       192.168.0.11

;; Query time: 0 msec
;; SERVER: 192.168.135.130#53(192.168.135.130)
;; WHEN: Thu Aug  5 18:50:48 2010
;; MSG SIZE  rcvd: 135
Next we test IP-to-host resolution:
dig @192.168.135.130 -x 192.168.0.10

; <<>> DiG 9.6-ESV-R1 <<>> @192.168.135.130 -x 192.168.0.10
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10810
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;10.0.168.192.in-addr.arpa.     IN      PTR

;; ANSWER SECTION:
10.0.168.192.in-addr.arpa. 604800 IN    PTR     linuxconfig.org.

;; AUTHORITY SECTION:
0.168.192.in-addr.arpa. 604800  IN      NS      ns2.linuxconfig.org.
0.168.192.in-addr.arpa. 604800  IN      NS      ns1.linuxconfig.org.

;; ADDITIONAL SECTION:
ns1.linuxconfig.org.    10800   IN      A       192.168.0.10
ns2.linuxconfig.org.    10800   IN      A       192.168.0.11

;; Query time: 0 msec
;; SERVER: 192.168.135.130#53(192.168.135.130)
;; WHEN: Thu Aug  5 18:52:06 2010
;; MSG SIZE  rcvd: 140
Congratulation. You have just created and configured your own DNS zone using bind nameserver.

Thursday, 12 June 2014

LAMP CONFIGURATION METERIALS

This document will walk you through the installation of what is known as a "LAMP" system: Linux, Apache, MySQL and PHP. Depending on who you talk to, the P also stands for Perl or Python, but in general, it is assumed to be PHP. I run CentOS on my servers; these directions were written for CentOS/Red Hat/Fedora. I have had requests for SuSE (another RPM-based distribution) as well as Debian-based systems, so I will work on variants of these directions for those distributions in the future (donations might help speed that process up!). The main difference between the distributions is in the paths to the startup scripts. Red Hat systems used /etc/rc.d/init.d and SuSE uses /etc/init.d.
If you need an SSL-enabled server, I have a LAMP with SSL howto as well.
I designed this document so you can just copy/paste each line or block of commands into your shell session and it will "just work" for you. This avoids tedious typing, and the inevitable typos or missed steps that result. These commands work properly via copy/paste. If you are having problems and you are not using copy/paste, please re-check your typing before sending me an email saying "It doesn't work."
Text in a "command" box like this one is a literal Linux commandline, and should be typed or pasted exactly as written.
One note: many many people have followed these directions as written, and have not had any problems.
If you are having a problem, chances are it's something you are doing (or not doing), something different
about your computer, etc.

It is probably NOT this procedure. :)
Initial Steps
PLEASE BE AWARE THAT A SOURCE-BASED INSTALLATION LIKE THIS ONE IS NOT NEEDED FOR A BASIC LAMP SERVER! You should only be doing a source-based installation if you need to alter settings in one or more components of the LAMP stack (e.g., you need a feature in PHP that isn't in the default RPM). If you are just getting started with LAMP, use the binaries provided by your distribution - it is much simpler, and a lot easier to upgrade later.
Most out-of-the-box Red Hat Linux installations will have one or more of the LAMP components installed via RPM files. I personally believe in installing things like this from source, so I get the most control over what's compiled in, what's left out, etc. But source code installs can wreak havoc if overlaid on top of RPM installs, as the two most likely won't share the same directories, etc.
If you have not yet installed your Linux OS, or just for future reference, do not choose to install Apache, PHP, or MySQL during the system installation. Then you can immediately proceed with the source-based install listed here.
Note: to install applications from source code, you will need a C++ compiler (gcc++) installed. This is generally taken care of, but I've had enough queries about it that I've added this note to avoid getting more! You can use your distribution's install CDs to get the proper version of the compiler. Or, if you are using an RPM based distro, you can use a site like http://www.rpmfind.net/ to locate the correct RPM version for your system. (You will obviously not be able to use/rebuild a source RPM to get the compiler installed, as you need the compiler to build the final binary RPM!) On a Fedora system, you can do this command:
su - root
yum install gcc gcc-c++
Log in as root
Because we will be installing software to directories that "regular" users don't have write access to, and also possibly uninstalling RPM versions of some applications, we'll log in as root. The only steps that need root access are the actual installation steps, but by doing the configure and make steps as root, the source code will also be inaccessible to "regular" users.
If you do not have direct access (via keyboard) to the server, PLEASE use Secure Shell (SSH) to access the server and not telnet!! Whenever you use telnet (or plain FTP for that matter), you are transmitting your username, password, and all session information in "plain text". This means that anyone who can access a machine someplace between your PC and your server can snoop your session and get your info. Use encryption wherever possible!
su - root
Remove RPM Versions of the Applications
Before we start with our source code install, we need to remove all the existing RPM files for these products. To find out what RPMs are already installed, use the RPM query command:
rpm -qa
in conjunction with grep to filter your results:
rpm -qa | grep -i apache
rpm -qa | grep -i httpd
rpm -qa | grep -i php
rpm -qa | grep -i mysql
The 'httpd' search is in case you have Apache2 installed via RPM.
To remove the RPMs generated by these commands, do
rpm -e filename
for each RPM you found in the query. If you have any content in your MySQL database already, the RPM removal step should not delete the database files. When you reinstall MySQL, you should be able to move all those files to your new MySQL data directory and have access to them all again.
Get the Source Code for all Applications
We want to put all our source code someplace central, so it's not getting mixed up in someone's home directory, etc.
cd /usr/local/src
One way application source code is distributed is in what are known as "tarballs." The tar command is usually associated with making tape backups - tar stands for Tape ARchive. It's also a handy way to pack up multiple files for easy distribution. Use the man tar command to learn more about how to use this very flexible tool.
At the time of updating this, the current versions of all the components we'll use are:
MySQL - 4.1.22
Apache - 1.3.37
PHP - 4.4.6
Please note: these are the only versions of these that I have set up myself, and verified these steps against. If you use another version of any component, especially a newer version, this HOWTO may not be accurate, and I won't be able to provide free support under those circumstances. Paid support and assistance is always available however.
wget http://www.php.net/distributions/php-4.4.6.tar.gz
wget http://apache.oregonstate.edu/httpd/apache_1.3.37.tar.gz
There may be an Apache mirror closer to you - check their mirror page for other sources. Then insert the URL you get in place of the above for the wget command.
For MySQL, go to http://www.mysql.com/ and choose an appropriate mirror to get the newest MySQL version (v4.1.22).
Unpack the Source Code
tar zxf php-4.4.6.tar.gz
tar zxf apache_1.3.37.tar.gz
tar zxf mysql-4.1.22.tar.gz
This should leave you with the following directories:
/usr/local/src/php-4.4.6
/usr/local/src/apache_1.3.37
/usr/local/src/mysql-4.1.22
Build and Install MySQL
First, we create the group and user that "owns" MySQL. For security purposes, we don't want MySQL running as root on the system. To be able to easily identify MySQL processes in top or a ps list, we'll make a user and group named mysql:
groupadd mysql
useradd -g mysql -c "MySQL Server" mysql
If you get any messages about the group or user already existing, that's fine. The goal is just to make sure we have them on the system.
What the useradd command is doing is creating a user mysql in the group mysql with the "name" of MySQL Server. This way when it's showed in various user and process watching apps, you'll be able to tell what it is right away.
Now we'll change to the "working" directory where the source code is, change the file 'ownership' for the source tree (this prevents build issues in reported in some cases where the packager's username was included on the source and you aren't using the exact same name to compile with!) and start building.
The configure command has many options you can specify. I have listed some fairly common ones; if you'd like to see others, do:
./configure --help | less
to see them all. Read the documentation on the MySQL website for a more detailed explanation of each option.
cd /usr/local/src/mysql-4.1.22

chown -R root.root *

make clean

./configure \
--prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--disable-maintainer-mode \
--with-mysqld-user=mysql \
--with-unix-socket-path=/tmp/mysql.sock \
--without-comment \
--without-debug \
--without-bench
18-Jul-2005: If you are installing MySQL 4.0.x on Fedora Core 4, there is a problem with LinuxThreads that prevents MySQL from compiling properly. Installing on Fedora Core 3 works fine though. Thanks to Kevin Spencer for bringing this to my attention. There is a workaround listed at http://bugs.mysql.com/bug.php?id=9497. Thanks to Collin Campbell for that link. Another solution can be found at http://bugs.mysql.com/bug.php?id=2173. Thanks to Kaloyan Raev for that one.
Now comes the long part, where the source code is actually compiled and then installed. Plan to get some coffee or take a break while this step runs. It could be 10-15 minutes or more, depending on your system's free memory, load average, etc.
make && make install
Configure MySQL
MySQL is "installed" but we have a few more steps until it's actually "done" and ready to start. First run the script which actually sets up MySQL's internal database (named, oddly enough, mysql).
./scripts/mysql_install_db
Then we want to set the proper ownership for the MySQL directories and data files, so that only MySQL (and root) can do anything with them.
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
Copy the default configuration file for the expected size of the database (small, medium, large, huge)
cp support-files/my-medium.cnf /etc/my.cnf
chown root:sys /etc/my.cnf
chmod 644 /etc/my.cnf
If you get an error message about the data directory not existing, etc., something went wrong in the mysql_install_db step above. Go back and review that; make sure you didn't get some sort of error message when you ran it, etc.
Now we have to tell the system where to find some of the dynamic libraries that MySQL will need to run. We use dynamic libraries instead of static to keep the memory usage of the MySQL program itself to a minimum.
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig
Now create a startup script, which enables MySQL auto-start each time your server is restarted.
cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
/sbin/chkconfig --level 3 mysql on
Then set up symlinks for all the MySQL binaries, so they can be run from anyplace without having to include/specify long paths, etc.
cd /usr/local/mysql/bin
for file in *; do ln -s /usr/local/mysql/bin/$file /usr/bin/$file; done
MySQL Security Issues
First, we will assume that only applications on the same server will be allowed to access the database (i.e., not a program running on a physically separate server). So we'll tell MySQL not to even listen on port 3306 for TCP connections like it does by default.
Edit /etc/my.cnf and uncomment the
skip-networking
line (delete the leading #).
For more security info, check out this MySQL security tutorial.
Start MySQL
First, test the linked copy of the startup script in the normal server runlevel start directory, to make sure the symlink was properly set up:
cd ~
/etc/rc.d/rc3.d/S90mysql start
If you ever want to manually start or stop the MySQL server, use these commands:
/etc/rc.d/init.d/mysql start
/etc/rc.d/init.d/mysql stop
Let's "test" the install to see what version of MySQL we're running now:
mysqladmin version
It should answer back with the version we've just installed...
Now we'll set a password for the MySQL root user (note that the MySQL root user is not the same as the system root user, and definitely should not have the same password as the system root user!).
mysqladmin -u root password new-password
(obviously, insert your own password in the above command instead of the "new-password" string!)
You're done! MySQL is now installed and running on your server. It is highly recommended that you read about MySQL security and lock down your server as much as possible. The MySQL site has info at http://www.mysql.com/doc/en/Privilege_system.html.
Test MySQL
To run a quick test, use the command line program mysql:
mysql -u root -p
and enter your new root user password when prompted. You will then see the MySQL prompt:
mysql>
First, while we're in here, we'll take care of another security issue and delete the sample database test and all default accounts except for the MySQL root user. Enter each of these lines at the mysql> prompt:
drop database test;
use mysql;
delete from db;
delete from user where not (host="localhost" and user="root");
flush privileges;
As another security measure, I like to change the MySQL administrator account name from root to something harder to guess. This will make it that much harder for someone who gains shell access to your server to take control of MySQL.
MAKE SURE YOU REMEMBER THIS NEW NAME, AND USE IT WHEREVER
YOU SEE "root" IN OTHER DIRECTIONS, WEBSITES, ETC.

ONCE YOU DO THIS STEP, THE USERNAME "root" WILL CEASE TO
EXIST IN YOUR MYSQL CONFIGURATION!
update user set user="sqladmin" where user="root";
flush privileges;
Now, on with the "standard" testing... First, create a new database:
create database foo;
You should see the result:
Query OK, 1 row affected (0.04 sec)

mysql>
Delete the database:
drop database foo;
You should see the result:
Query OK, 0 rows affected (0.06 sec)

mysql>
To exit from mysql enter \q:
\q
Build and Install Apache (with DSO support)
The advantage to building Apache with support for dynamically loaded modules is that in the future, you can add functionality to your webserver by just compiling and installing modules, and restarting the webserver. If the features were compiled into Apache, you would need to rebuild Apache from scratch every time you wanted to add or update a module (like PHP). Your Apache binary is also smaller, which means more efficient memory usage.
The downside to dynamic modules is a slight performance hit compared to having the modules compiled in.
cd /usr/local/src/apache_1.3.37

make clean

./configure \
--prefix=/usr/local/apache \
--enable-shared=max \
--enable-module=rewrite \
--enable-module=so

make && make install
Build and Install PHP
This section has only been tested with PHP v4.x. If you are trying to build PHP 5.x, I do not have experience with this yet, and do not provide free support for you to get it working. Please note that there are many options which can be selected when compiling PHP. Some will have library dependencies, meaning certain software may need to be already installed on your server before you start building PHP. You can use the command
./configure --help | less
once you change into the PHP source directory. This will show you a list of all possible configuration switches. For more information on what these switches are, please check the PHP website documentation.
cd /usr/local/src/php-4.4.6

./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--disable-debug \
--enable-ftp \
--enable-inline-optimization \
--enable-magic-quotes \
--enable-mbstring \
--enable-mm=shared \
--enable-safe-mode \
--enable-track-vars \
--enable-trans-sid \
--enable-wddx=shared \
--enable-xml \
--with-dom \
--with-gd \
--with-gettext \
--with-mysql=/usr/local/mysql \
--with-regex=system \
--with-xml \
--with-zlib-dir=/usr/lib

make && make install

cp php.ini-dist /usr/local/lib/php.ini
I like to keep my config files all together in /etc. I set up a symbolic link like this:
ln -s /usr/local/lib/php.ini /etc/php.ini
Then I can just open /etc/php.ini in my editor to make changes.
Recommended reading on securing your PHP installation is this article at SecurityFocus.com.
Edit the Apache Configuration File (httpd.conf)
I like to keep all my configuration files together in /etc, so I set up a symbolic link from the actual location to /etc:
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
Now open /etc/httpd.conf in your favorite text editor, and set all the basic Apache options in accordance with the official Apache instructions (beyond the scope of this HOWTO).
Also recommended is the article on securing Apache.
To ensure your PHP files are properly interpreted, and not just downloaded as text files, remove the # at the beginning of the lines which read:
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps
If the AddType lines above don't exist, manually enter them (without the leading # of course) after the line
AddType application/x-tar .tgz
or anyplace within the <IfModule mod_mime.c> section of httpd.conf.
If you wish to use other/additional extensions/filetypes for your PHP scripts instead of just .php, add them to the AddType directive:
AddType application/x-httpd-php .php .foo
AddType application/x-httpd-php-source .phps .phtmls
An example: if you wanted every single HTML page to be parsed and processed like a PHP script, just add .htm and .html:
AddType application/x-httpd-php .php .htm .html
There will be a bit of a performance loss if every single HTML page is being checked for PHP code even if it doesn't contain any. But if you want to use PHP but be "stealthy" about it, you can use this trick.
Add index.php to the list of valid Directory Index files so that your "default page" in a directory can be named index.php.
<IfModule mod_dir.c>
    DirectoryIndex index.php index.htm index.html
</IfModule>
You can add anything else you want here too. If you want foobar.baz to be a valid directory index page, just add the .baz filetype to the AddType line, and add foobar.baz to the DirectoryIndex line.
Start Apache
We want to set Apache up with a normal start/stop script in /etc/rc.d/init.d so it can be auto-started and controlled like other system daemons. Set up a symbolic link for the apachectl utility (installed automatically as part of Apache):
ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache
Then set up auto-start for runlevel 3 (where the server will go by default):
ln -s /etc/rc.d/init.d/apache /etc/rc.d/rc3.d/S90apache
Then start the daemon:
/etc/rc.d/init.d/apache start
You can check that it's running properly by doing:
ps -ef
and look for the httpd processes.