Difference between revisions of "ApachePHPMySQLForUbuntu"

From mi-linux
Jump to navigationJump to search
(Removed phpmyadmin instructions out to the discussion page.)
m (→‎Installing Apache2: - correction RE root privileges)
 
(3 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
Assuming you have an active Internet connection...
 
Assuming you have an active Internet connection...
 
== Installing Apache2 ==
 
== Installing Apache2 ==
 +
The command "sudo" allows you to execute a single command as root, avoiding the need to login as root.  If you choose to login as root before executing these commands, remove SUDO from the beginning of each line.
 +
 
=== Part 1 - Configuration ===
 
=== Part 1 - Configuration ===
 
1. open a terminal
 
1. open a terminal
Line 48: Line 50:
  
 
3.13 You should see a wepage that says '''Hello WWW World!''' - CONGRATULATIONS - your Apache webserver is up and running.
 
3.13 You should see a wepage that says '''Hello WWW World!''' - CONGRATULATIONS - your Apache webserver is up and running.
 
  
 
== Installing PHP5 ==
 
== Installing PHP5 ==
Line 105: Line 106:
 
=== Installing phpmyadmin ===
 
=== Installing phpmyadmin ===
  
See the "discussion" link at the top of the page on how to install on Ubuntu
+
'''See the [[Talk:ApachePHPMySQLForUbuntu|discussion link]] at the top of the page on how to install on Ubuntu ==
 +
 
  
 
1. Once finished, open Firefox (or preferred browser) and enter URL:
 
1. Once finished, open Firefox (or preferred browser) and enter URL:

Latest revision as of 20:25, 17 February 2007

This guide has been written for Ubuntu (versions 6.06/6.10) using a GNOME (standard) desktop - it will need to be adapted for other distributions

Assuming you have an active Internet connection...

Installing Apache2

The command "sudo" allows you to execute a single command as root, avoiding the need to login as root. If you choose to login as root before executing these commands, remove SUDO from the beginning of each line.

Part 1 - Configuration

1. open a terminal

2. enter the following - enter 'Y' to any questions, and your password if prompted

sudo apt-get install apache2
sudo chmod 777 /var/www

3. if you're using GNOME on Ubuntu

3.1 Click on 'Places' on your task bar, then 'Home Folder'

3.2 In the menu bar click on 'Go' then 'Location...' and enter /var/www in the box and hit enter, and you should see something like this:

AMP1.png

3.3 Click on 'File' then 'New Folder' on the menu, and rename the folder created as 'cp1079www' (lowercase)

3.4 Open the 'cp1079www' folder

3.5 TO MAKE LIFE EASIER: Click on 'Bookmarks' then click 'Add Bookmark' - this will create a shortcut in your 'Places' at the bottom of the left hand pane, that will be useful later.

3.6 Close the file manager window

Part 2 - Create a test file

3.7 Open your preferred text editor

3.8 Create a new blank file if one has not been automatically created for you

3.9 Enter the following into your new file

<HTML>
    Hello WWW World!
 </HTML>

3.10 Click on 'File' then 'Save' - change the filename to 'index.html' and click on 'Save in Folder' - at the bottom of the drop down list should be 'cp1079www' - the shortcut you created earlier - select this, and click 'Save'

Part 3 - Testing your installation

3.11 Open firefox (or your preferred browser)

3.12 enter the following URL:

http://localhost

You should see two hyperlinks (folders) - one should say 'apache2-default' and the other 'cp1079www' - click 'cp1079www'

3.13 You should see a wepage that says Hello WWW World! - CONGRATULATIONS - your Apache webserver is up and running.

Installing PHP5

1. open a terminal

2. enter the following - enter 'Y' to any questions, and your password if prompted

sudo apt-get install php5

3. open your preferred editor

4. create a new file (if one hasn't automatically been created) and enter the following:

<?
   // if php and apache are playing nicely together
   // you should see only the words - WOO-HOO! when 
   // you visit this page in firefox
   echo 'WOO-HOO';
 ?>

5. Save this file into your 'cp1079www' folder with the name 'test.php'

6. Open firefox (or preferred browser), enter the following URL:

http://localhost/cp1079www/test.php

7. You should the words WOO-HOO! if PHP and Apache are working correctly.


Installing MySQL

MySQL is a database server, much like Oracle and similar, not like Access - usually, it is a program that is running continually in the background whilst your Operating System is running. We will install the server application and a popular client application you can use to interact with the MySQL Server.

Installing MySQL Server

1. open a terminal

2. enter the following - enter 'Y' to any questions, and your password if prompted

sudo apt-get install mysql-server
sudo apt-get install php5-mysql

3. Once the installation process has finished, enter the following

gksudo gedit /etc/php5/apache2/php.ini

4. Search/Find the string mysql.so

5. You should find it on a line that looks like the following:

;extension=mysql.so

6. Delete the ; from the beginning of the line and save and exit

7. Restart Apache by entering the following:

sudo /etc/init.d/apache2 restart

AT THIS POINT: MySQL is installed, connected with PHP and Apache, but in order to test and manipulate databases we will also install a popular MySQL client application called phpmyadmin

Installing phpmyadmin

See the discussion link at the top of the page on how to install on Ubuntu ==


1. Once finished, open Firefox (or preferred browser) and enter URL:

http://localhost

2. You should now see a new folder here titled phpmyadmin - click it

3. A screen will prompt you for your MySQL account and password - by default, the user is 'root' and the password is not set (i.e. blank) - THIS IS NOT SECURE, AND IS USUALLY BAD PRACTICE, but as you are writing code that runs only on your computer, it is OK - if you intend to distribute any PHP/MySQL work, you need to create new users/passwords to improve security - more on this in MySQL Teaching/Learning Resources, but outside the scope of the CP1079 PHP module.

4. You should see a screen like this - CONGRATULATIONS - Linux, Apache, MySQL, and PHP are all working correctly together - this is commonly referred to as a LAMP installation.

LAMPOK.png