Linux Server builds process using the Centos distribution in a virtual environment
This tutorial will instruct you how to provision a virtual machine using the Centos operating System and to configure a LAMP server
Add the necessary VCPU, Memory, Vnics, HDD to meet the business requirements. During the VM provisioning you will want to select the following option listed below:
In this example we will be using the following virtual hardware:
1 x vCPU
2GB RAM
1 x vNIC
1 x VMDK ??
Installing Centos operating system
This is based on installing Centos 5.5 x64 version
(Centos is developed using the same kernel as RHEL)
1. Press enter to install using graphical mode
2. You will be prompted to test the media (Probably best to test the media to ensure the media is not corrupted)
3. Select language (English)
4. Select United Kingdom (Keyboard)
5. You will now be prompted to format the disk. Ensure that there is no data on the disk about to be formatted because this is irreversible
6. Tick the review and modify partitioning layout and select next
7. Make note of the size of the / partition and delete it. Create a new / partition using ext3 but subtract 5 GB of space.
8. This will separate the operating systems from log files; therefore if log files grow large enough to take up all the space if will not knock the server over.
9. Delete the LVM group and create the partition table noted above. Next select the default option to use grub as the boot loader.
10. Select edit to configure a static IP address. Be sure to disable the check box to enable IPv6
11. Configure the default gateway, domain name, and DNS.
12. Select the time zone (Europe / London)
13. Configure the firewall to allow http and ssh traffic
14. Enable NTP. This will normally sync time with the domain controller holding the PDC emulator role
1. Create an Administrator account. This will be the account used to establish SSH connections
2. Continue through the wizard selecting the default options and click finish
Install VMware Tools
1. Mount the vmware tools using the vsphere client
2. Login to the server using the administrator account
3. Right click the desktop to open a terminal session
4. SU to root
Mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
Note: If you have a previous installation, delete the previous vmware-distrib directory before installing. The default location of this directory is /tmp/vmware-tools-distrib.
tar zxf /mnt/cdrom/VMwareTools-5.0.0-<xxxx>.tar.gz
umount /dev/cdrom
cd vmware-tools-distrib
Accept the default settings by pressing enter at the prompts
Follow the on screen prompts and exit the CLI
Starting VMware Tools Automatically
You may find it helpful to configure your guest operating system so VMware Tools starts when you start your X server. The steps for doing so vary depending on your Linux distribution and your desktop environment. Check your operating system documentation for the appropriate steps to take.
Update the operating system
Open a terminal session
Yum list updates
Yum update
Install Apache
yum install httpd httpd-devel
/etc/init.d/httpd start
Install MySQL Database Server
yum install mysql mysql-server mysql-devel
/etc/init.d/mysqld start
mysql
mysql
Changing MySQL Root Password
By default the root password is empty for the mysql database. It is a good idea to change the mysql root password to a new one from a security point of view.
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
Verify Login to MySql is successful:
mysql -u root -p
Enter Password: <your new password>
Enter Password: <your new password>
To Create A New MySQL User
To create a new mysql user 'guest' with 'all privileges' on the database 'demo':
mysql > create database demo
mysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';
mysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';
Install PHP5 Scripting Language
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
Restart Apache to load php.
/etc/init.d/httpd restart
To Test If PHP Is Working Or Not:
Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes.
// test.php
<?php
phpinfo();
?>
Then point your browser to http://ip.address/test.php.
Install phpMyAdmin
Download version 2 version 3 requires php 5.2 and it is not supported on centos 5.5
yum install phpmyadmin
Download from phpmyadmin.com
Extract tar
Mv phpmyadmin….. to phpmyadmin
Cp –R phpmyadmin /var/www/html
Configure PHPmyadmin
Cp config.sample.inc.php config.inc.php
Common Errors
Forbidden You don't have permission to access /phpmyadmin/ on this server.
To fix:
Edit the /etc/httpd/conf.d/phpmyadmin.conf and uncomment the line deny from all.
nano /etc/httpd/conf.d/phpmyadmin.conf
<Directory "/usr/share/phpmyadmin">
Order Deny,Allow
# Deny from all
Allow from 127.0.0.1
</Directory>
ErrorThe configuration file now needs a secret passphrase (blowfish_secret)
To fix:
nano /usr/share/phpmyadmin/conf.inc.php
Look for a line and enter any password. Just dont leave it empty!
$cfg['blowfish_secret'] = 'mydemopass'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
Install Webmin
Download webmin http://webmin.com/download.html
wget <webmin rpm path>
rpm - i webmin-1.410-1.noarch.rpm
rpm - i webmin-1.410-1.noarch.rpm
Open port 10000 on the firewall
Point your browser to: http://ip.address:10000
You should see a webmin login. But we don't know the login and password yet! To set up the webmin password run the script below...
/usr/libexec/webmin/changepass.pl /etc/webmin admin <newpasswd>
Log in with the admin username and new webmin password!
To uninstall webmin, just run:
To uninstall webmin, just run:
/etc/webmin/uninstall.sh
Final Steps Configuring the Services to Auto start
We want the Apache and mysql to be loaded at every boot so we switch them on using chkconfig:
chkconfig httpd on
chkconfig mysqld on
chkconfig mysqld on
Install Anti Virus
Install Clam anti-virus
Yum install clamav
Yum install clamtk (GUI)