This document provides instructions for installing a LAMP server with Drupal on it. It describes installing CentOS as the base Linux server, then using yum to add Apache, MySQL, PHP, and additional packages to create a full LAMP stack. It details configuring DHCP and FTP services. It also explains downloading and extracting Drupal, creating a MySQL database for it, and navigating through the Drupal installation process via a web browser. The key steps are: 1) installing a base Linux server; 2) using yum to add Apache, MySQL, PHP to create a LAMP server; 3) downloading and extracting Drupal; 4) creating a MySQL database; and 5) navigating through the Drupal installation
1. Included in this project presentation are:
Guidelines to building a LAMP server and installing a Content Management
System called Drupal onto it.
The system is built on VMware 6.5, hosted on a Windows XP Home Edition
desktop PC.
The LAMP server includes:
A base Linux server (CentOS 5.2)
configured with dhcp and ftp.
Apache (a Linux Web Server)
mySQL (a Database system)
PHP (a programming language)
Using yum to install packages onto the server.
Methods for downloading Drupal to the server directly at the server, or indirectly
through the client.
2. Installing a LAMP Server
A LAMP server is a server configuration that
can host websites, intranets, and Web 2.0
type content management systems.
The acronym LAMP refers to:
Linux (Operating System)
Apache (Web Server)
MySQL (Database)
PHP (A Programming language)
3. Installing a Base (Linux) Server
Only screen shots of interest are
included for the server installation.
5. Base Server Installation
Once you see this screen, it is a
matter of selecting configurable items
as the installation progresses.
After pressing the ‘next’ option
above, the installation moves on to a
number of language selection
screens.
6. If installing on a virtual machine, don’t
worry about this warning. Press ‘yes’ and
then ‘next’.
7. Again, don’t be alarmed by this message if
installing on a virtual machine. Press
‘next’.
8. By checking the ‘Active on Boot’ and ‘automatically via
DHCP’ here, the network card of the virtual server, will
adopt the settings of the host system network card.
9. Continuing on:
This is followed by a time zone
selection screen.
Which in turn, is followed by a screen
which sets the root password. The
root password must be at least 6
characters in length.
10. Up until this point, desktop and server installation are the
same. Scroll through the top pane, un-tick ‘desktop’ and tick
‘server’. Select the ‘Customise now’ radio button and press
‘next’.
11. Continuing on:
The next 2 screens allow you to choose
what type of tools and applications you
want to install. This will vary depending on
your requirements. I chose ‘development’
and ‘development tools’, followed by ‘base
system’ and ‘base’. This is the point you
also select a GUI, if you want to. If you
don’t, you will only have a command
prompt to work with after installation.
12. Click ‘next’,
And the installation process begins. It
takes approximately 15 minute.
A screen saying ‘Formatting/file
system’ appears.
Then a screen saying ‘Starting install
process’ appears.
And these are followed by a screen
with a progress bar.
16. YUM (Yellow-Dog Unified Modifier.)
Yum is a packet management utility.
It can be used to update the
operating System installation.
It can also be used to install
additional services on the basic server
installation.
17. Updating the OS
This is simply achieved by logging in
as root, and typing the command:
#yum update
18. Adding DHCP to the Basic Server
DHCP centralises and manages the
allocation of TCP/IP configuration
information on a DHCP server.
A DHCP server allocates IP addresses to
client system that are configured to use
DHCP.
These IP addresses can be leased for a
specific period and the client can attempt to
renew its lease before it expires.
19. Installing DHCP
Again we use yum.
#yum –y install dhcp
This displays a screen that shows the
version of the DHCP download and a
progress bar and percentage
indicator.
20. Some basic DHCP configuration.
First you have to give the DHCP server a
static IP address. This is done by typing:
#ifconfig eth0 192.168.0.10 netmask
255.255.255.0 up
Eth0 is the interface name. This can vary
depending on what interface you are using
to connect to the network.
21. Making this address permanent.
This address will be lost after a
reboot, if it is not permanently saved.
To save the IP address, we use the
following command:
#system-config-network
This opens a utility that allows us to
enter the information.
22. /etc/dhcpd.conf
When DHCP starts, it reads the
/etc/dhcpd.conf file.
This file contains the configuration
information for the DHCP service.
Among its configurable parameters
are:
The network and subnetmask.
23. /etc/dhcpd.conf
The default gateway and its subnet
mask.
The domain name.
The DNS Server address.
The range of IP addresses that the
DHCP Server can allocate.
The terms of the lease.
24. /etc/dhcpd.conf
A text editor like vi or nano can be
used to edit the /etc/dhcpd.conf file.
To start the DHCP service, type
#service dhcpd start
To ensure that it starts at boot, type
#chkconfig dhcpd on
25. DHCP: where to send the IP offers.
The DHCP server must be configured
to know on what interface, to send an
IP address to a client requesting one.
# route add -host 255.255.255.255
dev eth0
This tells the server to broadcast the
address out the eth0 interface.
26. Testing the DHCP server
Install a CentOS client and set it to
receive its IP address through DHCP.
If using VMware, team the DHCP
server and the client and change their
network card settings to Lan1. To do
this, right click the settings tab in
VMware or the network card itself.
27. Testing the DHCP server
Ping the server IP address. If you get
replies, the connection is ok.
Get the IP address of the client by
typing:
#ifconfig
And ping the client from the server.
28. Adding FTP to the Server
Configure the server to use the Host IP
address again by:
Breaking the VMware team.
Changing the network card from Lan1 to
NAT
Typing:
#system-config-network
Which opens the following screen.
30. FTP Installation commands.
#yum install vsftpd
#chkconfig vsftpd on
This ensures that the FTP service runs
a boot time.
Turn iptables off or else set a rule to
allow FTP. To turn iptable off type:
#service iptables off
31. Starting FTP
Start the FTP service.
#service vsftpd start
and ensure that it starts at boot time.
#chkconfig vsftpd on
32. Testing FTP
This can be done in two ways.
From the server, by typing
#ftp localhost
or from the client, (after reteaming with the
server in VMware), by typing
#ftp 192.168.0.10 ( the server IP
address)
Use ‘anonymous’ as the username and
‘password’ as the password.
33. Installing Apache
Apache is a linux web server. By installing
it on the base server, the server can be
used to host websites.
To install it on the base server, type:
#yum install httpd
followed by:
#chkconfig httpd on
This ensures that it starts at boot.
34. Checking Installation
As I didn’t install a GUI on the server
during the base server installation, I
must install a text based browser
called elinks, to test it.
To install elinks, type:
#yum install elinks
36. Starting and Stopping Apache
# apachectl stop
# apachectl start
or
# service httpd start
# service httpd stop
37. Adding MySQL to the Server
# yum install mysql-server mysql
followed by:
# service mysqld start
or
# chkconfig mysqld on
if you want it to start at boot.
38. Adding PHP to the Server
# yum install php
If installing MySQL and PHP while Apache is
running, you must stop and start Apache.
This completes the installation of the
lamp server. (Linux, Apache, MySQL &
PHP)
39. Installing Drupal on a LAMP server.
The basic LAMP server needs some
additional packages installed for
Drupal to install correctly. If using
VMware, change the network card
settings to LAT and remove the static
IP address so that the server uses the
host system IP.
41. Download Drupal & unzip it.
# wget
http://drupal.org/files/projects/drupal
-6.10.tar.gz
This creates a zipped directory called
drupal-6.10.tar.gz in the root
directory.
# tar –zxvpf drupal-6.10.tar.gz
42. (If MV doesn’t work, see slide 65)
Unzipping creates a directory called drupal-
6.1 in the root directory, which contains all
the Drupal directories and files (some
hidden).
Copy the contents of this directory to the
html directory.
# mv drupal-6.1/* drupal-6.1/.htaccess
/var/www/html
43. The mv command & What it does.
This is actually two commands, the
asterisk, ‘*’ means all files and directories.
However, asterisk, won’t copy the hidden
file .htaccess, so this must also be
specified.
(This command is in effect, # mv drupal-
6.1/* /var/www/html and # mv drupal-
6.1/.htaccess /var/www/html)
44. settings.php
Change directory into /html/sites/default
# cd /html/sites/default
Make a copy of the default.settings.php file
and call it settings.php
# cp default.settings.php settings.php
45. Give permissions to this file.
This is required so that Drupal can
make changes to it during
installation. After installation, most of
these permissions must be removed
again.
# chmod 777 settings.php
46. The files directory.
Check that the /html/sites/default/files
directory exists. If not, make it .
# mkdir files
# chmod 777 files
47. Create a database for drupal to use.
Start the mysql service if it isn’t
started automatically at boot.
# service mysqld start
48. Create a user to administer the database.
I chose root and gave a simple
password of ‘mypassword’.
# mysqladmin – u root – p password
mypassword
49. Use this user, root, to create a database.
I called the database ‘cit’.
# mysqldadmin – u root – p create cit
Then log into mysql as root and grant
permissions.
# mysql – u root – p
50. mysql
This will ask for a password. Enter mypassword, and you will
be presented with the mysql> prompt, from where you can
grant permissions.
mysql> GRANT SELECT, INSERT,
UPDATE, CREATE, DROP, INDEX, ALTER
ON cit.* TO ‘root’@’localhost’
IDENTIFIED BY
‘mypassword’;
Note, there are quotes around root, localhost and
mypassword. Don’t forget the semi-colon, at the end.
51. Activate these permissions.
mysql> FLUSH PRIVILEGES;
You can check that the database was
created by typing:
mysql> show databases
Exit mysql by typing quit.
mysql> quit
52. Re-team the server and client.
Change the network card settings
back to LAN1, ie team it with the
client in VMware, and give the server
its static IP address again, through
the system-config-network command.
Reboot the server.
53. After rebooting:
Turn iptables off, if you haven’t written specific rules, so
that the client system is allowed to browse to it.
# service iptables stop
An iptables rule to allow traffic to port 80 from hosts on
the server network of 192.168.0.0 255.255.255.0 reads:
-A INPUT -s 192.168.0.0/24 –p tcp –m tcp --dport 80 –j
ACCEPT
Save this in the /etc/sysconfig/iptables file on the server
54. Make sure that mysqld is started, by
typing:
# service mysqld start
55. Boot the client system.
Make sure that httpd is running on the
client.
# service httpd start
Open the firefox browser on the client and
enter the URL,
http://192.168.0.10/install.php
58. It goes through the install steps listed on the left hand side of the screen. If
there are errors or warnings, it prompts you with a possible solution, as
shown in this screen.
59. It then enters the database details. These refer to the
database created earlier on the server. Enter the same
details: Database name cit
Database username root
Database password mypassword
64. Reduce permissions on settings.php
Log onto the server again and change
directory, into the default, so that
you can remove some of the
permissions on settings.php .
# cd /var/www/html/sites/default
# chmod 555 settings.php
65. Alternative method of downloading Drupal onto
the server through the client.
Change the network card settings on the client
to NAT, so that it can access the internet
Open the browser and browse to drupal.org.
Click on the Download Drupal 6.10 link. It is
downloaded to the desktop as a zipped folder.
Double click it and extract it.
66. This creates another folder called drupal-6.1,
which contains all of the installation files. Re-
establish the VMware team .
68. Go to Places – Network Servers and double
click SFTP File Transfer on WWW
69. You are presented with a screen, requesting a password.
Enter the password for the server, and you login to the
server, from where you can view its directories and folders.
70. Scroll through the folders, and double click the var folder,
then www folder, and finally the html folder. If there are
files in it, delete them, and minimise the screen.
71. Open the drupal-6.10 folder on the desktop, edit – select all
and DRAG them, don’t paste them, into the html folder.
72. You can then continue with the installation, by browsing to
the server,
http://192.168.0.10/install.php , as outlined earlier, and
proceed with the install.