SlideShare uma empresa Scribd logo
1 de 16
Baixar para ler 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

Mais conteúdo relacionado

Mais procurados

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
webhostingguy
 
Updated UNIX RESUME 7+Yrs- Kalesha
Updated UNIX RESUME 7+Yrs- KaleshaUpdated UNIX RESUME 7+Yrs- Kalesha
Updated UNIX RESUME 7+Yrs- Kalesha
Kalesha Ananthu
 

Mais procurados (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
 

Semelhante a How to build a lamp server-sample

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
Banking at Ho Chi Minh city
 
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
 
How to become cloud backup provider
How to become cloud backup providerHow to become cloud backup provider
How to become cloud backup provider
CLOUDIAN 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 Isilon
Boni Bruno
 

Semelhante a 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
 

Mais de 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
 

Último

一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
pxcywzqs
 
75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
Asmae Rabhi
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
ayvbos
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
JOHNBEBONYAP1
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Monica Sydney
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
galaxypingy
 

Último (20)

一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolino
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 

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