SlideShare a Scribd company logo
1 of 16
Download to read offline
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

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 oracle11gGuy Harrison
 
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 - SlidesSeveralnines
 
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 SSDUnitiv
 
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 - UKOUGKeith 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 2014Severalnines
 
Advancedtroubleshooting 101208145718-phpapp01
Advancedtroubleshooting 101208145718-phpapp01Advancedtroubleshooting 101208145718-phpapp01
Advancedtroubleshooting 101208145718-phpapp01Suresh Kumar
 
SSD based storage tuning for databases
SSD based storage tuning for databasesSSD based storage tuning for databases
SSD based storage tuning for databasesAngelo 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 LinuxSebastien 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 VMWarevmug
 
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 referenceVinh 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
 
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 InstructionYury Velikanov
 
Testing Delphix: easy data virtualization
Testing Delphix: easy data virtualizationTesting Delphix: easy data virtualization
Testing Delphix: easy data virtualizationFranck Pachot
 
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-usGanesh Bagde
 
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
 
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-0Senthil Muthuvelu
 
Configuration Management and Salt
Configuration Management and SaltConfiguration Management and Salt
Configuration Management and Salt55020
 

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 insertion-rotation
avl insertion-rotationavl insertion-rotation
avl insertion-rotationXad Kuain
 
History evaluation
History evaluationHistory evaluation
History evaluationXad Kuain
 
Computer and programming language
Computer and programming languageComputer and programming language
Computer and programming languageXad 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 programmingXad 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

VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Complet Documnetation for Smart Assistant Application for Disabled Person
Complet Documnetation   for Smart Assistant Application for Disabled PersonComplet Documnetation   for Smart Assistant Application for Disabled Person
Complet Documnetation for Smart Assistant Application for Disabled Personfurqan222004
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 

Recently uploaded (20)

VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Complet Documnetation for Smart Assistant Application for Disabled Person
Complet Documnetation   for Smart Assistant Application for Disabled PersonComplet Documnetation   for Smart Assistant Application for Disabled Person
Complet Documnetation for Smart Assistant Application for Disabled Person
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
sasti delhi Call Girls in munirka 🔝 9953056974 🔝 escort Service-
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 

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