0% found this document useful (0 votes)
105 views35 pages

317 Unit 01 - Setup PDF

This document provides instructions for setting up a LAMP development environment on a VirtualBox virtual machine using an Ubuntu image. It describes how to install VirtualBox, import the Ubuntu virtual appliance, and then install and configure the LAMP stack including Apache, PHP, and MySQL. Key steps include importing the virtual machine image, granting security permissions on MacOS, installing Apache and verifying the configuration, enabling the firewall, installing PHP and testing with a info.php file, and finally installing MySQL and completing the secure installation process.

Uploaded by

Jay Jaber
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views35 pages

317 Unit 01 - Setup PDF

This document provides instructions for setting up a LAMP development environment on a VirtualBox virtual machine using an Ubuntu image. It describes how to install VirtualBox, import the Ubuntu virtual appliance, and then install and configure the LAMP stack including Apache, PHP, and MySQL. Key steps include importing the virtual machine image, granting security permissions on MacOS, installing Apache and verifying the configuration, enabling the firewall, installing PHP and testing with a info.php file, and finally installing MySQL and completing the secure installation process.

Uploaded by

Jay Jaber
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

CSC 317-03 - Spring 2020

Wed Development

SFSU, CSC 317


Setting Up – Diving in the deep end

● Install Virtual Box

● Import WebDev.ova

● Launch the Ubuntu image

● Install LAMP

● See it work!

SFSU, CSC 317 2


First Step – Get and install Virtual Box
● https://www.virtualbox.org/wiki/Downloads

SFSU, CSC 317 3


Macintosh Users – You may encounter this…
● This is a known issue
and is easy to fix if
you do it immediately!

● More on this issue can


be found at:
https://matthewpalmer.net/blog/2
017/12/10/install-virtualbox-
mac-high-sierra/index.html

SFSU, CSC 317 4


Mac Installation Issue
● Go to the Security & Privacy
panel in your system
preferences.
● You should see the message
here
● Click the Allow button

● You only have about 30


minutes from the install fail
to do this or it won’t appear
again without more work

SFSU, CSC 317 5


Launch Virtual Box
● The click the Tools Icon

SFSU, CSC 317 6


We are IMPORTING an image
● We are not doing an add, but rather an import, so select import

SFSU, CSC 317 7


Now it will ask for the file to import
● Click the folder
icon

● Then choose the


WebDev.ova file
you downloaded

● See iLearn on how


to get
WebDev.ova

SFSU, CSC 317 8


Info on the image
● The Defaults here are fine

● Just click the import button

SFSU, CSC 317 9


Now Wait…

SFSU, CSC 317 10


Now select WebDev and Start
● Select the WebDev
“machine”

● Then click Start

SFSU, CSC 317 11


Linux Installed

Lamp

SFSU, CSC 317


Ubuntu is now running!!
● Select student (this
is your username)

SFSU, CSC 317 13


The password is…
● … student

SFSU, CSC 317 14


We are up
● We are up
and running

● Click the
Terminal
Icon

SFSU, CSC 317 15


Welcome to the Linux command line interface

SFSU, CSC 317 16


Some command we will see today
● sudo – superuser do – allows normal users (with sudo privileges) to do
administrative tasks

● ls – lists the files in a directory (we will use ls -la a lot as well)

● cd – change directory

● mkdir – make directory

● apt – a tool to help install programs

SFSU, CSC 317 17


More commands
● curl – a way to retrieve the actual HTML of a URL – no rendering is done

● apache2ctl – part of the apache web services (control program)

● nano – a simple editor

● echo – plays back what is on the line to stdout

● ufw – uncomplicated fire wall

● rm – remove a file (or directory)

SFSU, CSC 317 18


Let’s start to install our software
● The apt program will be how we install the next set of components we want,
but first we need to make sure the apt database is up-to-date
○ sudo apt update

● Note, when we use sudo, we may be prompted to enter our password

● Next, we will install and use curl


○ Sudo apt install curl
○ curl sfsu.edu
■ You should see the following: (next screen)

SFSU, CSC 317 19


Curl at work
● This shows us that curl worked and that sfsu.edu now is an https site.

SFSU, CSC 317 20


Time for Apache

lAmp

SFSU, CSC 317


Install Apache
● We are now going to start the Apache installation
○ sudo apt install apache2

● Now let’s use curl to get our IP address https://www.showmyip.com/


○ curl https://www.showmyip.com/
■ Now scroll back up to where the command started and then look
down a few lines and you will find your IP address. Make a note of
it.

SFSU, CSC 317 22


Configuration
● So now we need to edit some files

● sudo nano /etc/apache2/mods-enabled/dir.conf


○ We are going to enter at the bottom of the file (replace IP as needed):
■ ServerName 130.212.92.59
○ Then to save and exit we to the following:
■ Ctrl-X (for exit)
■ Y (for yes we want to save our changes)
■ Return (to write it to the file and exit)

SFSU, CSC 317 23


Verify the configuration and start Apache
● # Verify Configuration
○ sudo apache2ctl configtest

● # Restart Apache
○ sudo service apache2 restart

● # Ensure the server starts on boot


○ sudo update-rc.d apache2 defaults

SFSU, CSC 317 24


Setting up the firewall
● Setting up Uncomplicated Firewall (ufw)

● First, show the apps that ufw understands


○ sudo ufw app list
● You should see Apache Full as one of those choices, that is what we want
○ sudo ufw allow 'Apache Full’

● Check the status of ufw


○ sudo ufw status
● Enable ufw
○ sudo ufw enable

SFSU, CSC 317 25


Let’s see if that worked…
● We can now check our work
○ curl localhost

● localhost is the “name” for our local computer (in this case the ubuntu image)

● You should see a bunch of HTML displayed


● Now open Firefox from the Ubuntu GUI – you should see the image on the
next slide

SFSU, CSC 317 26


It Works!

SFSU, CSC 317 27


Now for PHP

lamP

SFSU, CSC 317


Now let’s install PHP
● First run the install
○ sudo apt-get install php libapache2-mod-php php-mysql

● Now we need to dit the DirectoryIndex line so `index.php` is before


`index.html` in this configuration file
○ sudo nano /etc/apache2/mods-enabled/dir.conf

● Modify this line so that index.php is before index.html as shown

SFSU, CSC 317 29


Testing PHP
● Create a test file with echo – we are creating the file info.php in the “website”
directory structure with a php function call. A built-in function that returns
information on your server and configuration
○ sudo echo '<?php phpinfo(); ?>' > /var/www/html/info.php

● Now navigate to: `http://localhost/info.php` in your Ubuntu browser

SFSU, CSC 317 30


Remove that info.php file
● We now want to remove that info.php file. This file displays way too much
information about your server and should only be used for debugging your
site.
○ sudo rm /var/www/html/info.php

SFSU, CSC 317 31


Finally MySQL

laMp

SFSU, CSC 317


Database time
● First install mysql
○ sudo apt install mysql-server

● Then run through configuration steps...


○ Make sure to document your credentials!
■ sudo mysql_secure_installation

SFSU, CSC 317 33


Configuration Questions
● Choose 0 (low strength) then enter a password – this can be anything you
want but you MUST REMEMBER IT!
○ I use student for this image since it is not production

● It will then ask you to reenter the password and if you want to use that
password (renter it , then respond Y)

● Answers to the rest of the configuration questions


○ Remove anonymous users? Y
○ Disallow root login remotely? Y
○ Remove test database and access to it? N
○ Reload privilege tables now? Y
SFSU, CSC 317 34
Congratulations
You now have a Webserver

SFSU, CSC 317

You might also like