SlideShare a Scribd company logo
How To Build a LAMP Server
(Linux, Apache, MySQL, PHP)
© 2013-2015 Steve Parker, BSc, RHCE
How to Build a LAMP Server Page 154
Copyright © 2013-2015 by Steve Parker. All Rights Reserved. No part
of this publication or the information in it may be quoted from or
reproduced in any form by means such as printing, scanning,
photocopying or otherwise without prior written permission of the
copyright holder.
Linux® is the registered trademark of Linus Torvalds in the U.S. and
other countries.
Apache® is the registered trademark of the Apache Software
Foundation.
MySQL® is the registered trademark of Oracle and/or its affiliates.
All trademarks are acknowledged as belonging to their respective
owners.
Page 2 How to Build a LAMP Server
How to Build a LAMP Server Page 154
Table of Contents
Volume One: Install and Configure the Software Stack.........................6
Chapter 1 - Install the Linux Operating System......................................7
Choose a Language...........................................................................10
Storage Selection..............................................................................12
Host Name........................................................................................14
Timezone..........................................................................................14
Root Password..................................................................................15
Storage Configuration.......................................................................16
Grub Boot Loader.............................................................................30
Select Software.................................................................................31
Installation of Packages....................................................................32
Reboot...............................................................................................32
Chapter 2 - Post-Install Linux Configuration........................................34
Enable network interfaces.................................................................34
Add a Personal User Account...........................................................36
Log in Remotely...............................................................................36
Configure sudo..................................................................................37
Harden SSH......................................................................................40
Useful Tools......................................................................................41
Chapter 3 - The Apache httpd Web Server............................................42
Install Apache httpd..........................................................................42
Chapter 4 - Apache Configuration.........................................................47
Apache Security................................................................................47
Testing Apache.................................................................................50
Troubleshoot Apache........................................................................50
Install your own Test Page................................................................53
Enable Start at Boot..........................................................................53
Chapter 5 - PHP.....................................................................................55
Install PHP........................................................................................55
Test PHP...........................................................................................57
Chapter 6 - Install MySQL....................................................................60
Secure MySQL.................................................................................64
Enable Start at Boot..........................................................................69
Page 4 How to Build a LAMP Server
Troubleshoot MySQL.......................................................................69
Chapter 7 - phpMyAdmin.....................................................................70
Download the EPEL metapackage...................................................71
Install phpMyAdmin.........................................................................71
Configure phpMyAdmin...................................................................77
Log in to phpMyAdmin....................................................................78
Create an Application Database........................................................79
Configure MySQL Users..................................................................80
Volume Two: Now Do Stuff With It!...................................................86
Chapter 8 - Database Design.................................................................88
Database Tables................................................................................88
Item table.................................................................................89
Wishlist table...........................................................................89
User table.................................................................................90
Relational Databases.........................................................................90
MySQL Workbench............................................................90
Chapter 9 - Making Tables in MySQL..................................................94
Chapter 10 - Prototype Application.......................................................97
Populating the Database....................................................................98
Pulling Data from the Database........................................................99
Don't die!..........................................................................101
Chapter 11 - Start Building the Application........................................103
Add Images to Items.......................................................................106
Create the Item Page.......................................................................108
Create the Wishlist Page.................................................................115
A wishlistname() Function..............................................................119
Adding Users..................................................................................122
Registration.....................................................................................125
Chapter 12 - Finishing Touches...........................................................139
Showing and Adding WishLists.....................................................139
Adding an Item to a WishList.........................................................142
Conclusion...........................................................................................152
Feedback..............................................................................................154
By The Same Author...........................................................................154
How to Build a LAMP Server Page 154
Volume One: Install and
Configure the Software Stack
This book is about setting up a LAMP (Linux, Apache, MySQL, PHP)
web server. It covers all of the necessary tasks, and explains all of the
important aspects of each part of the stack along the way.
This first part, Volume One, can be used as a direct guide for installing
the software, but it aims to also help the reader to understand the
nuances of the software being installed, with helpful advice about the
structure and setup of the system, and about ensuring maintainability as
well as securing the overall system.
LAMP is actually a coming together of four entirely unrelated software
projects, which share a similar ecosystem and development culture, and
which work together particularly well. Each part is Free or Open Source
software, developed in the open and actively updated independently of
the others. The interfaces between the elements are well defined
however, so they continue to work well together in spite of there being
no centralized control whatsoever. This also means that any of the
elements can be replaced by equivalents - most often the "P", which can
be PHP, Perl or Python, and the "L", which can be Linux, Windows
(WAMP), Solaris (SAMP), one of the BSD-based Unices (such as
OAMP for OpenBSD), or even Mac OSX (MAMP). The Database and
Web Server layer can be replaced too, though this is less often seen.
Whilst not a PHP or MySQL tutorial, Volume Two also shows how to
structure and set up a simple database and write the PHP code to
manipulate that database. The resulting code as well as configuration
files are also available for download for free from http://steve-
parker.org/code/kindle/lamp/.
Feedback is always most welcome: Please contact lamp@steve-
parker.org with any comments.
Page 6 How to Build a LAMP Server
Chapter 1 - Install the Linux
Operating System
The first step is to install the Linux-based operating system. Nothing
special is required here, the LAMP stack will run on any typical
distribution; we are using CentOS 6.4. Red Hat Enterprise Linux.
Oracle Enterprise Linux, or Scientific Linux are all equivalent as far as
this document is concerned. They differ in terms of support contracts
and availability of media and documentation, but technically they are
the same. Red Hat 5 is also largely similar as far as this document is
concerned, but Red Hat 6 is a more up-to-date alternative if you can get
it. Red Hat 7 is different in some details but essentially the same for
these purposes. We will do a basic "minimal" OS installation, using a
disk layout suitable for a LAMP server.
Red Hat Enterprise Linux is available from redhat.com.
Workalikes are available from CentOS.org,
oracle.com/linux and scientificlinux.org.
Then we will secure and configure the OS as necessary.
First, install the DVD-ROM into the drive, or present it via VMWare,
VirtualBox or whatever virtualisation is being used. On booting, you
should get the Red Hat boot screen.
Branding: Here I'm using CentOS; the only difference is
the branding, all of the actual software is identical.
If you don't get this screen, go into the BIOS (or UEFI) and check the
boot device order.
How to Build a LAMP Server Page 154
Choose "Install or upgrade an existing system". If you choose the
text-based installer, you will not be able to set up an LVM-managed
disk configuration, so choose the default graphical installation if
possible. For a minute or so, a a black-and-white screen shows the
installer starting up:
Loading vmlinuz.....
Loading initrd.img .......................
This is followed by lots of scrolling text as various parts of the system
are initialized. Then you will be offered the opportunity to check the
integrity of the media you are about to install from. This used to be a
very useful facility, particularly when burnable media was new, and
internet connections were particularly unreliable. It can be worth doing,
particularly if you are not certain of the quality of the media you are
using. Otherwise, you can skip this stage.
Page 8 How to Build a LAMP Server
Press the <TAB> key to highlight the "Skip" button, and press either
Enter or the space bar to select the option you want. Since there are
only two choices here, it can be hard to tell which is the highlighted
option - the first screenshot shows "OK" highlighted, and the second
shows "Skip" highlighted.
At this point, assuming you have chosen the default graphical install
option, the display may flicker for a short while as it detects your
How to Build a LAMP Server Page 154
hardware and determines a suitable (probably not optimal, but at least
workable) resolution for your graphics device. Shortly afterwards, you
should see the CentOS (or Red Hat) welcome screen.
Choose a Language
Click Next, and go on to select your preferred Language and
Keyboard layout.
Page 10 How to Build a LAMP Server
Press Back and Next to navigate between the different screens.
How to Build a LAMP Server Page 154
Storage Selection
Next comes the first part of the Storage setup of the installation routine.
This detects available storage devices, and formats them if necessary.
Don't worry; it will always provide you with information about devices
and ask for confirmation before formatting anything. If you are doing a
test install on a dedicated machine, it is fine to go with the default.
Otherwise, take particular care at this stage of the installation.
First, the installer checks the state of all disks it can find. The first part
of this requires you to tell the installer what type of devices you will be
installing onto. If you are unsure, "Basic Storage Devices" is almost
certain to be the right answer. If you need the SAN options, then the
actual process will be specific to your environment, and you will likely
have existing procedures in place for performing Operating System
installations onto those devices.
The installer will detect the disks available, and may well warn about
the state of new, unformatted disks. In this example, I have presented it
with a blank VMWare virtual disk, which - for all the installer knows -
could be something important that it simply failed to recognize, so it
plays safe and asks you what to do with the disk.
If SAN devices may be mapped to the system, be very
careful before clicking on "Yes, discard any data",
and extra care before doing so with the "Apply my
choice to all devices with undetected partitions or
filesystems" box checked!
Page 12 How to Build a LAMP Server
Host Name
At this stage, the installer takes a short break from the storage setup,
and asks you to provide a name for the server.
The default of localhost.localdomain is not very descriptive; I
have named this server as lamp.example.com.
How to Build a LAMP Server Page 154
If you want to set up a static IP address, this is also the place to do that.
Click the "Network" button (not shown here) at the bottom of the same
screen, and you can set an IP address, network gateway, and so on. It is
very easy to change the network configuration later by editing a couple
of text files, so instead we will show how to set up your networking
preferences once the installation has completed.
Page 14 How to Build a LAMP Server
That's all for the sample
of the guide. Please visit
http://steve-parker.org/lamp/buy
for the full PDF document
(also available on Kindle and Paperback)
How to Build a LAMP Server Page 154
Steve Parker is also the author of the
“Shell Scripting Tutorial” - check it out
at http://steve-parker.org/sh/sh.shtml,
also available as an e-Book and printed
book: Just search Amazon for “Shell
Scripting Tutorial”
ISBN-10: 1499546653
ISBN-13: 978-1499546651
Steve Parker is also the author of the
Wiley book “Shell Scripting- Expert
Recipes for Linux, Bash and more”
ISBN-10: 1118024486
ISBN-13: 978-1118024485
Page 16 How to Build a LAMP Server

More Related Content

What's hot

HP 3PAR Express Writes
HP 3PAR Express WritesHP 3PAR Express Writes
HP 3PAR Express Writes
Ivan Iannaccone
 
Making the most of ssd in oracle11g
Making the most of ssd in oracle11gMaking the most of ssd in oracle11g
Making the most of ssd in oracle11g
Guy Harrison
 
Resume
ResumeResume
Resume
Shyama nand
 
A Guide to your Tagadab Shared Hosting Control Panel
A Guide to your Tagadab Shared Hosting Control PanelA Guide to your Tagadab Shared Hosting Control Panel
A Guide to your Tagadab Shared Hosting Control Panelwebhostingguy
 
Management and Automation of MongoDB Clusters - Slides
Management and Automation of MongoDB Clusters - SlidesManagement and Automation of MongoDB Clusters - Slides
Management and Automation of MongoDB Clusters - Slides
Severalnines
 
Storage Event: HP 3PAR live erleben
Storage Event: HP 3PAR live erlebenStorage Event: HP 3PAR live erleben
Storage Event: HP 3PAR live erleben
A. Baggenstos & Co. AG
 
HP 3Par StoreServ Storage: HP All Flash Array SSD
HP 3Par StoreServ Storage: HP All Flash Array SSDHP 3Par StoreServ Storage: HP All Flash Array SSD
HP 3Par StoreServ Storage: HP All Flash Array SSD
Unitiv
 
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Embracing Database Diversity: The New Oracle / MySQL DBA -   UKOUGEmbracing Database Diversity: The New Oracle / MySQL DBA -   UKOUG
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Keith Hollman
 
Updated UNIX RESUME 7+Yrs- Kalesha
Updated UNIX RESUME 7+Yrs- KaleshaUpdated UNIX RESUME 7+Yrs- Kalesha
Updated UNIX RESUME 7+Yrs- KaleshaKalesha Ananthu
 
Slides: Severalnines ClusterControl 1.2.6 Webinar - May 2014
Slides: Severalnines ClusterControl 1.2.6 Webinar - May 2014Slides: Severalnines ClusterControl 1.2.6 Webinar - May 2014
Slides: Severalnines ClusterControl 1.2.6 Webinar - May 2014
Severalnines
 
Advancedtroubleshooting 101208145718-phpapp01
Advancedtroubleshooting 101208145718-phpapp01Advancedtroubleshooting 101208145718-phpapp01
Advancedtroubleshooting 101208145718-phpapp01
Suresh Kumar
 
SSD based storage tuning for databases
SSD based storage tuning for databasesSSD based storage tuning for databases
SSD based storage tuning for databases
Angelo Rajadurai
 
Understanding Solid State Disk and the Oracle Database Flash Cache (older ver...
Understanding Solid State Disk and the Oracle Database Flash Cache (older ver...Understanding Solid State Disk and the Oracle Database Flash Cache (older ver...
Understanding Solid State Disk and the Oracle Database Flash Cache (older ver...
Guy Harrison
 
Enabling POWER 8 advanced features on Linux
Enabling POWER 8 advanced features on LinuxEnabling POWER 8 advanced features on Linux
Enabling POWER 8 advanced features on Linux
Sebastien Chabrolles
 
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
Severalnines
 
3PAR and VMWare
3PAR and VMWare3PAR and VMWare
3PAR and VMWare
vmug
 
Hadoop Operations: Starting Out Small / So Your Cluster Isn't Yahoo-sized (yet)
Hadoop Operations: Starting Out Small / So Your Cluster Isn't Yahoo-sized (yet)Hadoop Operations: Starting Out Small / So Your Cluster Isn't Yahoo-sized (yet)
Hadoop Operations: Starting Out Small / So Your Cluster Isn't Yahoo-sized (yet)
Michael Arnold
 
iSCSI Target Support for Ceph
iSCSI Target Support for Ceph iSCSI Target Support for Ceph
iSCSI Target Support for Ceph
Ceph Community
 
Progress OpenEdge database administration guide and reference
Progress OpenEdge database administration guide and referenceProgress OpenEdge database administration guide and reference
Progress OpenEdge database administration guide and reference
Vinh Nguyen
 

What's hot (20)

HP 3PAR Express Writes
HP 3PAR Express WritesHP 3PAR Express Writes
HP 3PAR Express Writes
 
Making the most of ssd in oracle11g
Making the most of ssd in oracle11gMaking the most of ssd in oracle11g
Making the most of ssd in oracle11g
 
S3
S3S3
S3
 
Resume
ResumeResume
Resume
 
A Guide to your Tagadab Shared Hosting Control Panel
A Guide to your Tagadab Shared Hosting Control PanelA Guide to your Tagadab Shared Hosting Control Panel
A Guide to your Tagadab Shared Hosting Control Panel
 
Management and Automation of MongoDB Clusters - Slides
Management and Automation of MongoDB Clusters - SlidesManagement and Automation of MongoDB Clusters - Slides
Management and Automation of MongoDB Clusters - Slides
 
Storage Event: HP 3PAR live erleben
Storage Event: HP 3PAR live erlebenStorage Event: HP 3PAR live erleben
Storage Event: HP 3PAR live erleben
 
HP 3Par StoreServ Storage: HP All Flash Array SSD
HP 3Par StoreServ Storage: HP All Flash Array SSDHP 3Par StoreServ Storage: HP All Flash Array SSD
HP 3Par StoreServ Storage: HP All Flash Array SSD
 
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Embracing Database Diversity: The New Oracle / MySQL DBA -   UKOUGEmbracing Database Diversity: The New Oracle / MySQL DBA -   UKOUG
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
 
Updated UNIX RESUME 7+Yrs- Kalesha
Updated UNIX RESUME 7+Yrs- KaleshaUpdated UNIX RESUME 7+Yrs- Kalesha
Updated UNIX RESUME 7+Yrs- Kalesha
 
Slides: Severalnines ClusterControl 1.2.6 Webinar - May 2014
Slides: Severalnines ClusterControl 1.2.6 Webinar - May 2014Slides: Severalnines ClusterControl 1.2.6 Webinar - May 2014
Slides: Severalnines ClusterControl 1.2.6 Webinar - May 2014
 
Advancedtroubleshooting 101208145718-phpapp01
Advancedtroubleshooting 101208145718-phpapp01Advancedtroubleshooting 101208145718-phpapp01
Advancedtroubleshooting 101208145718-phpapp01
 
SSD based storage tuning for databases
SSD based storage tuning for databasesSSD based storage tuning for databases
SSD based storage tuning for databases
 
Understanding Solid State Disk and the Oracle Database Flash Cache (older ver...
Understanding Solid State Disk and the Oracle Database Flash Cache (older ver...Understanding Solid State Disk and the Oracle Database Flash Cache (older ver...
Understanding Solid State Disk and the Oracle Database Flash Cache (older ver...
 
Enabling POWER 8 advanced features on Linux
Enabling POWER 8 advanced features on LinuxEnabling POWER 8 advanced features on Linux
Enabling POWER 8 advanced features on Linux
 
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
Webinar slides: 9 DevOps Tips for Going in Production with Galera Cluster for...
 
3PAR and VMWare
3PAR and VMWare3PAR and VMWare
3PAR and VMWare
 
Hadoop Operations: Starting Out Small / So Your Cluster Isn't Yahoo-sized (yet)
Hadoop Operations: Starting Out Small / So Your Cluster Isn't Yahoo-sized (yet)Hadoop Operations: Starting Out Small / So Your Cluster Isn't Yahoo-sized (yet)
Hadoop Operations: Starting Out Small / So Your Cluster Isn't Yahoo-sized (yet)
 
iSCSI Target Support for Ceph
iSCSI Target Support for Ceph iSCSI Target Support for Ceph
iSCSI Target Support for Ceph
 
Progress OpenEdge database administration guide and reference
Progress OpenEdge database administration guide and referenceProgress OpenEdge database administration guide and reference
Progress OpenEdge database administration guide and reference
 

Similar to How to build a lamp server-sample

Suse linux enterprise_server_12_x_for_sap_applications_configuration_guide_fo...
Suse linux enterprise_server_12_x_for_sap_applications_configuration_guide_fo...Suse linux enterprise_server_12_x_for_sap_applications_configuration_guide_fo...
Suse linux enterprise_server_12_x_for_sap_applications_configuration_guide_fo...
Jaleel Ahmed Gulammohiddin
 
Sap hana master_guide_en
Sap hana master_guide_enSap hana master_guide_en
Sap hana master_guide_en
Sridhar Kasthuri
 
hana_sps11_SUSE_Linux_Enterprise_Server_11_x_for_SAP_Applications_Configurati...
hana_sps11_SUSE_Linux_Enterprise_Server_11_x_for_SAP_Applications_Configurati...hana_sps11_SUSE_Linux_Enterprise_Server_11_x_for_SAP_Applications_Configurati...
hana_sps11_SUSE_Linux_Enterprise_Server_11_x_for_SAP_Applications_Configurati...
JessDavidGuzmnGalleg
 
Suse linux enterprise_server_15_x_for_sap_applications_configuration_guide_fo...
Suse linux enterprise_server_15_x_for_sap_applications_configuration_guide_fo...Suse linux enterprise_server_15_x_for_sap_applications_configuration_guide_fo...
Suse linux enterprise_server_15_x_for_sap_applications_configuration_guide_fo...
Jaleel Ahmed Gulammohiddin
 
Performance tuning for ibm tivoli directory server redp4258
Performance tuning for ibm tivoli directory server   redp4258Performance tuning for ibm tivoli directory server   redp4258
Performance tuning for ibm tivoli directory server redp4258Banking at Ho Chi Minh city
 
RAC Attack 12c Installation Instruction
RAC Attack 12c Installation InstructionRAC Attack 12c Installation Instruction
RAC Attack 12c Installation Instruction
Yury Velikanov
 
Testing Delphix: easy data virtualization
Testing Delphix: easy data virtualizationTesting Delphix: easy data virtualization
Testing Delphix: easy data virtualization
Franck Pachot
 
0001
00010001
0001
Kais143
 
003 red hat-enterprise_linux-6-dm_multipath-en-us
003 red hat-enterprise_linux-6-dm_multipath-en-us003 red hat-enterprise_linux-6-dm_multipath-en-us
003 red hat-enterprise_linux-6-dm_multipath-en-us
Ganesh Bagde
 
Sap hana master guide
Sap hana master guideSap hana master guide
Sap hana master guide
Rajeshchowdary Kongara
 
How to become cloud backup provider
How to become cloud backup providerHow to become cloud backup provider
How to become cloud backup providerCLOUDIAN KK
 
EMC Starter Kit - IBM BigInsights - EMC Isilon
EMC Starter Kit - IBM BigInsights - EMC IsilonEMC Starter Kit - IBM BigInsights - EMC Isilon
EMC Starter Kit - IBM BigInsights - EMC IsilonBoni Bruno
 
zLAMP
zLAMPzLAMP
Backup and recovery_of_sap_systems_on_aws_v2-0
Backup and recovery_of_sap_systems_on_aws_v2-0Backup and recovery_of_sap_systems_on_aws_v2-0
Backup and recovery_of_sap_systems_on_aws_v2-0
Senthil Muthuvelu
 
SAP In-Memory Computing on IBM eX5 Systems
SAP In-Memory Computing on IBM eX5 SystemsSAP In-Memory Computing on IBM eX5 Systems
SAP In-Memory Computing on IBM eX5 Systems
IBM India Smarter Computing
 
Sql Adv
Sql AdvSql Adv
Sql Adv
jothisekaran
 
Configuration Management and Salt
Configuration Management and SaltConfiguration Management and Salt
Configuration Management and Salt
55020
 

Similar to How to build a lamp server-sample (20)

Suse linux enterprise_server_12_x_for_sap_applications_configuration_guide_fo...
Suse linux enterprise_server_12_x_for_sap_applications_configuration_guide_fo...Suse linux enterprise_server_12_x_for_sap_applications_configuration_guide_fo...
Suse linux enterprise_server_12_x_for_sap_applications_configuration_guide_fo...
 
Sap hana master_guide_en
Sap hana master_guide_enSap hana master_guide_en
Sap hana master_guide_en
 
hana_sps11_SUSE_Linux_Enterprise_Server_11_x_for_SAP_Applications_Configurati...
hana_sps11_SUSE_Linux_Enterprise_Server_11_x_for_SAP_Applications_Configurati...hana_sps11_SUSE_Linux_Enterprise_Server_11_x_for_SAP_Applications_Configurati...
hana_sps11_SUSE_Linux_Enterprise_Server_11_x_for_SAP_Applications_Configurati...
 
Suse linux enterprise_server_15_x_for_sap_applications_configuration_guide_fo...
Suse linux enterprise_server_15_x_for_sap_applications_configuration_guide_fo...Suse linux enterprise_server_15_x_for_sap_applications_configuration_guide_fo...
Suse linux enterprise_server_15_x_for_sap_applications_configuration_guide_fo...
 
Performance tuning for ibm tivoli directory server redp4258
Performance tuning for ibm tivoli directory server   redp4258Performance tuning for ibm tivoli directory server   redp4258
Performance tuning for ibm tivoli directory server redp4258
 
RAC Attack 12c Installation Instruction
RAC Attack 12c Installation InstructionRAC Attack 12c Installation Instruction
RAC Attack 12c Installation Instruction
 
Testing Delphix: easy data virtualization
Testing Delphix: easy data virtualizationTesting Delphix: easy data virtualization
Testing Delphix: easy data virtualization
 
Php mysql-tutorial-en
Php mysql-tutorial-enPhp mysql-tutorial-en
Php mysql-tutorial-en
 
0001
00010001
0001
 
003 red hat-enterprise_linux-6-dm_multipath-en-us
003 red hat-enterprise_linux-6-dm_multipath-en-us003 red hat-enterprise_linux-6-dm_multipath-en-us
003 red hat-enterprise_linux-6-dm_multipath-en-us
 
Mysql ppt
Mysql pptMysql ppt
Mysql ppt
 
Sap hana master guide
Sap hana master guideSap hana master guide
Sap hana master guide
 
How to become cloud backup provider
How to become cloud backup providerHow to become cloud backup provider
How to become cloud backup provider
 
EMC Starter Kit - IBM BigInsights - EMC Isilon
EMC Starter Kit - IBM BigInsights - EMC IsilonEMC Starter Kit - IBM BigInsights - EMC Isilon
EMC Starter Kit - IBM BigInsights - EMC Isilon
 
zLAMP
zLAMPzLAMP
zLAMP
 
Backup and recovery_of_sap_systems_on_aws_v2-0
Backup and recovery_of_sap_systems_on_aws_v2-0Backup and recovery_of_sap_systems_on_aws_v2-0
Backup and recovery_of_sap_systems_on_aws_v2-0
 
SAP In-Memory Computing on IBM eX5 Systems
SAP In-Memory Computing on IBM eX5 SystemsSAP In-Memory Computing on IBM eX5 Systems
SAP In-Memory Computing on IBM eX5 Systems
 
Sql Adv
Sql AdvSql Adv
Sql Adv
 
Configuration Management and Salt
Configuration Management and SaltConfiguration Management and Salt
Configuration Management and Salt
 
Sqlref
SqlrefSqlref
Sqlref
 

More from Xad Kuain

Avl trees
Avl treesAvl trees
Avl trees
Xad Kuain
 
avl insertion-rotation
avl insertion-rotationavl insertion-rotation
avl insertion-rotation
Xad Kuain
 
History evaluation
History evaluationHistory evaluation
History evaluation
Xad Kuain
 
Computer and programming language
Computer and programming languageComputer and programming language
Computer and programming language
Xad Kuain
 
Oracle 11g Database Administration
Oracle 11g Database Administration Oracle 11g Database Administration
Oracle 11g Database Administration
Xad Kuain
 
Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Computer Graphics & linear Algebra
Computer Graphics & linear Algebra
Xad Kuain
 
Quality assurance by Sadquain
Quality assurance by Sadquain Quality assurance by Sadquain
Quality assurance by Sadquain
Xad Kuain
 
C programming
C programmingC programming
C programming
Xad Kuain
 

More from Xad Kuain (8)

Avl trees
Avl treesAvl trees
Avl trees
 
avl insertion-rotation
avl insertion-rotationavl insertion-rotation
avl insertion-rotation
 
History evaluation
History evaluationHistory evaluation
History evaluation
 
Computer and programming language
Computer and programming languageComputer and programming language
Computer and programming language
 
Oracle 11g Database Administration
Oracle 11g Database Administration Oracle 11g Database Administration
Oracle 11g Database Administration
 
Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Computer Graphics & linear Algebra
Computer Graphics & linear Algebra
 
Quality assurance by Sadquain
Quality assurance by Sadquain Quality assurance by Sadquain
Quality assurance by Sadquain
 
C programming
C programmingC programming
C programming
 

Recently uploaded

How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
TristanJasperRamos
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
ShahulHameed54211
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
Himani415946
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 

Recently uploaded (16)

How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 

How to build a lamp server-sample

  • 1. How To Build a LAMP Server (Linux, Apache, MySQL, PHP) © 2013-2015 Steve Parker, BSc, RHCE How to Build a LAMP Server Page 154
  • 2. Copyright © 2013-2015 by Steve Parker. All Rights Reserved. No part of this publication or the information in it may be quoted from or reproduced in any form by means such as printing, scanning, photocopying or otherwise without prior written permission of the copyright holder. Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries. Apache® is the registered trademark of the Apache Software Foundation. MySQL® is the registered trademark of Oracle and/or its affiliates. All trademarks are acknowledged as belonging to their respective owners. Page 2 How to Build a LAMP Server
  • 3. How to Build a LAMP Server Page 154
  • 4. Table of Contents Volume One: Install and Configure the Software Stack.........................6 Chapter 1 - Install the Linux Operating System......................................7 Choose a Language...........................................................................10 Storage Selection..............................................................................12 Host Name........................................................................................14 Timezone..........................................................................................14 Root Password..................................................................................15 Storage Configuration.......................................................................16 Grub Boot Loader.............................................................................30 Select Software.................................................................................31 Installation of Packages....................................................................32 Reboot...............................................................................................32 Chapter 2 - Post-Install Linux Configuration........................................34 Enable network interfaces.................................................................34 Add a Personal User Account...........................................................36 Log in Remotely...............................................................................36 Configure sudo..................................................................................37 Harden SSH......................................................................................40 Useful Tools......................................................................................41 Chapter 3 - The Apache httpd Web Server............................................42 Install Apache httpd..........................................................................42 Chapter 4 - Apache Configuration.........................................................47 Apache Security................................................................................47 Testing Apache.................................................................................50 Troubleshoot Apache........................................................................50 Install your own Test Page................................................................53 Enable Start at Boot..........................................................................53 Chapter 5 - PHP.....................................................................................55 Install PHP........................................................................................55 Test PHP...........................................................................................57 Chapter 6 - Install MySQL....................................................................60 Secure MySQL.................................................................................64 Enable Start at Boot..........................................................................69 Page 4 How to Build a LAMP Server
  • 5. Troubleshoot MySQL.......................................................................69 Chapter 7 - phpMyAdmin.....................................................................70 Download the EPEL metapackage...................................................71 Install phpMyAdmin.........................................................................71 Configure phpMyAdmin...................................................................77 Log in to phpMyAdmin....................................................................78 Create an Application Database........................................................79 Configure MySQL Users..................................................................80 Volume Two: Now Do Stuff With It!...................................................86 Chapter 8 - Database Design.................................................................88 Database Tables................................................................................88 Item table.................................................................................89 Wishlist table...........................................................................89 User table.................................................................................90 Relational Databases.........................................................................90 MySQL Workbench............................................................90 Chapter 9 - Making Tables in MySQL..................................................94 Chapter 10 - Prototype Application.......................................................97 Populating the Database....................................................................98 Pulling Data from the Database........................................................99 Don't die!..........................................................................101 Chapter 11 - Start Building the Application........................................103 Add Images to Items.......................................................................106 Create the Item Page.......................................................................108 Create the Wishlist Page.................................................................115 A wishlistname() Function..............................................................119 Adding Users..................................................................................122 Registration.....................................................................................125 Chapter 12 - Finishing Touches...........................................................139 Showing and Adding WishLists.....................................................139 Adding an Item to a WishList.........................................................142 Conclusion...........................................................................................152 Feedback..............................................................................................154 By The Same Author...........................................................................154 How to Build a LAMP Server Page 154
  • 6. Volume One: Install and Configure the Software Stack This book is about setting up a LAMP (Linux, Apache, MySQL, PHP) web server. It covers all of the necessary tasks, and explains all of the important aspects of each part of the stack along the way. This first part, Volume One, can be used as a direct guide for installing the software, but it aims to also help the reader to understand the nuances of the software being installed, with helpful advice about the structure and setup of the system, and about ensuring maintainability as well as securing the overall system. LAMP is actually a coming together of four entirely unrelated software projects, which share a similar ecosystem and development culture, and which work together particularly well. Each part is Free or Open Source software, developed in the open and actively updated independently of the others. The interfaces between the elements are well defined however, so they continue to work well together in spite of there being no centralized control whatsoever. This also means that any of the elements can be replaced by equivalents - most often the "P", which can be PHP, Perl or Python, and the "L", which can be Linux, Windows (WAMP), Solaris (SAMP), one of the BSD-based Unices (such as OAMP for OpenBSD), or even Mac OSX (MAMP). The Database and Web Server layer can be replaced too, though this is less often seen. Whilst not a PHP or MySQL tutorial, Volume Two also shows how to structure and set up a simple database and write the PHP code to manipulate that database. The resulting code as well as configuration files are also available for download for free from http://steve- parker.org/code/kindle/lamp/. Feedback is always most welcome: Please contact lamp@steve- parker.org with any comments. Page 6 How to Build a LAMP Server
  • 7. Chapter 1 - Install the Linux Operating System The first step is to install the Linux-based operating system. Nothing special is required here, the LAMP stack will run on any typical distribution; we are using CentOS 6.4. Red Hat Enterprise Linux. Oracle Enterprise Linux, or Scientific Linux are all equivalent as far as this document is concerned. They differ in terms of support contracts and availability of media and documentation, but technically they are the same. Red Hat 5 is also largely similar as far as this document is concerned, but Red Hat 6 is a more up-to-date alternative if you can get it. Red Hat 7 is different in some details but essentially the same for these purposes. We will do a basic "minimal" OS installation, using a disk layout suitable for a LAMP server. Red Hat Enterprise Linux is available from redhat.com. Workalikes are available from CentOS.org, oracle.com/linux and scientificlinux.org. Then we will secure and configure the OS as necessary. First, install the DVD-ROM into the drive, or present it via VMWare, VirtualBox or whatever virtualisation is being used. On booting, you should get the Red Hat boot screen. Branding: Here I'm using CentOS; the only difference is the branding, all of the actual software is identical. If you don't get this screen, go into the BIOS (or UEFI) and check the boot device order. How to Build a LAMP Server Page 154
  • 8. Choose "Install or upgrade an existing system". If you choose the text-based installer, you will not be able to set up an LVM-managed disk configuration, so choose the default graphical installation if possible. For a minute or so, a a black-and-white screen shows the installer starting up: Loading vmlinuz..... Loading initrd.img ....................... This is followed by lots of scrolling text as various parts of the system are initialized. Then you will be offered the opportunity to check the integrity of the media you are about to install from. This used to be a very useful facility, particularly when burnable media was new, and internet connections were particularly unreliable. It can be worth doing, particularly if you are not certain of the quality of the media you are using. Otherwise, you can skip this stage. Page 8 How to Build a LAMP Server
  • 9. Press the <TAB> key to highlight the "Skip" button, and press either Enter or the space bar to select the option you want. Since there are only two choices here, it can be hard to tell which is the highlighted option - the first screenshot shows "OK" highlighted, and the second shows "Skip" highlighted. At this point, assuming you have chosen the default graphical install option, the display may flicker for a short while as it detects your How to Build a LAMP Server Page 154
  • 10. hardware and determines a suitable (probably not optimal, but at least workable) resolution for your graphics device. Shortly afterwards, you should see the CentOS (or Red Hat) welcome screen. Choose a Language Click Next, and go on to select your preferred Language and Keyboard layout. Page 10 How to Build a LAMP Server
  • 11. Press Back and Next to navigate between the different screens. How to Build a LAMP Server Page 154
  • 12. Storage Selection Next comes the first part of the Storage setup of the installation routine. This detects available storage devices, and formats them if necessary. Don't worry; it will always provide you with information about devices and ask for confirmation before formatting anything. If you are doing a test install on a dedicated machine, it is fine to go with the default. Otherwise, take particular care at this stage of the installation. First, the installer checks the state of all disks it can find. The first part of this requires you to tell the installer what type of devices you will be installing onto. If you are unsure, "Basic Storage Devices" is almost certain to be the right answer. If you need the SAN options, then the actual process will be specific to your environment, and you will likely have existing procedures in place for performing Operating System installations onto those devices. The installer will detect the disks available, and may well warn about the state of new, unformatted disks. In this example, I have presented it with a blank VMWare virtual disk, which - for all the installer knows - could be something important that it simply failed to recognize, so it plays safe and asks you what to do with the disk. If SAN devices may be mapped to the system, be very careful before clicking on "Yes, discard any data", and extra care before doing so with the "Apply my choice to all devices with undetected partitions or filesystems" box checked! Page 12 How to Build a LAMP Server
  • 13. Host Name At this stage, the installer takes a short break from the storage setup, and asks you to provide a name for the server. The default of localhost.localdomain is not very descriptive; I have named this server as lamp.example.com. How to Build a LAMP Server Page 154
  • 14. If you want to set up a static IP address, this is also the place to do that. Click the "Network" button (not shown here) at the bottom of the same screen, and you can set an IP address, network gateway, and so on. It is very easy to change the network configuration later by editing a couple of text files, so instead we will show how to set up your networking preferences once the installation has completed. Page 14 How to Build a LAMP Server
  • 15. That's all for the sample of the guide. Please visit http://steve-parker.org/lamp/buy for the full PDF document (also available on Kindle and Paperback) How to Build a LAMP Server Page 154
  • 16. Steve Parker is also the author of the “Shell Scripting Tutorial” - check it out at http://steve-parker.org/sh/sh.shtml, also available as an e-Book and printed book: Just search Amazon for “Shell Scripting Tutorial” ISBN-10: 1499546653 ISBN-13: 978-1499546651 Steve Parker is also the author of the Wiley book “Shell Scripting- Expert Recipes for Linux, Bash and more” ISBN-10: 1118024486 ISBN-13: 978-1118024485 Page 16 How to Build a LAMP Server