Track 2 Workshop PacNOG 7 June 30, 2010 Configuring Ubuntu for use with LAMP ------------------------------------ 1. Install the LAMP Server Components ---------------------------------- When you install Ubuntu Server 9.10 you have the option to install a "LAMP Server" configuration. We did not do this. To install LAMP at this time start by doing (in a terminal window): $ sudo apt-get update $ sudo install lamp-server^ NOTE: You must include the "^" symbol for this to work. Now you will many potential packages appear on the screen. Say yes to the dialog that looks something like this (final disk space amounts will vary): After this operation, 73.8MB of additional disk space will be used. Do you want to continue [Y/n]? As the installation progresses you will be asked to provide a password for MySQL. Please use the same password as you have for the "pacnog" user on your machines. 2. Post Install Configuration -------------------------- LAMP is now available on your machine. Try going to: http://localhost/ In a web browser. You should see the text: It works! This is the default web page for this server. The web server software is running but no content has been added, yet. This means that the Apache web server is up and running. If you'd like to see that the Apache scripting language is being interpreted by the Apache web server do the following: $ cd /var/www $ sudo rm index.html $ sudo vi index.php In the newly created file "index.php" enter the following: >>>> <<<< Then save and exit from the file (":wq" if using vi). Now restart the Apache web server: $ sudo apache2ctl restart In a web browser to go: http://loclahost/ and you will see an entire page full of information describing what your Apache, MySQL and PHP environment looks like. In general leaving a page like this lying around is considered a security risk as it gives away lots of information about your server. For now, however, we shall leave it. If you go down the page you will see a section titled, "mysql" - this implies that your Apache web server, PHP and MySQL are able to talk to each other. You have a LAMP server up and running. 3. Install phpMyAdmin ------------------ phpMyAdmin allows you to control your MySQL databases via a web-based GUI vs. using the MySQL database command line. This can be a useful tool. To install do: $ sudo apt-get install libapache2-mod-auth-mysql phpmyadmin Respond "Y" when prompted: After this operation, 17.7MB of additional disk space will be used. Do you want to continue [Y/n]? Y * The installation will prompt you to select a web server for automatic configuration. Use the space bar on your keyboard to select apache2 and then press . * Another screen will come up asking if you want to configure a new database called dbconfig-common. Since this is a fresh installation, use the key to select Yes and press . * You'll be prompted next to enter the MySQL root password. Enter the MySQL root password that you created earlier (same password as the "pacnog" user), press to select and press . * You'll then be prompted to enter a MySQL application password for phpmyadmin. Use the same password that we entered in the previous step (i.e., same password as the "pacnog" user). * A final password confirmation screen appears. Enter in the same password again, tab to and press . At this point the phpMyAdmin MySQL web front-end has been installed. We need to do some more configuration before we can use phpMyAdmin with Apache. 4. Some Initial Apache Configuration --------------------------------- We will start pretty simple. But, we will leave things open so that if you wished to we could run our web site with Virtual Hosting configured. The first thing we should do is the following: $ cd /var/www $ sudo mkdir share $ sudo mkdir share/pacnog7 $ sudo mv index.php share/pacnog7/. Now let's move our default web root from "/var/www" to "/var/www/share/pacnog7" $ cd /etc/apache2/sites-available $ sudo vi default There are some lines to be changed in this file. Change: Change: DocumentRoot /var/www to: Document /var/www/share/pacnog7 Change: ErrorLog /var/log/apache2/error.log to: ErrorLog /var/log/apache2/pacnog7_error.log Change: CustomLog /var/log/apache2/access.log combined to: CustomLog /var/log/apache2/pacnog7_access.log combined At this point save and exit from the file (":wq" in vi). Now restart your Apache web server: $ sudo /etc/init.d/apache2 restart In a web browser you should be able to go to: http://localhost/ and still see your previous page you created with php, even though you have moved the directory and files. In addition, try going to: http://localhost/phpmyadmin/ and you should see the phpMyAdmin MySQL web front end software. You can log in as: user: root password: [pacnog user password used during install] Feel free to look around. I would not recommend making changes to any of the databases listed at this time.