install and setup LAMP on Ubuntu for development

LAMP stack: Linux, Apache, MySQL, PHPMyAdmin

LAMP: Linux Operating System, Apache Webserver, PHP programming language, MySQL database, PHPMyAdmin database web interface

First install Apache2, PHP5, Mysql, Phpmyadmin in that order.

WEBROOT
########################
Then lets setup ~/public_html as webroot rather than /var/www/ (because it requires root privileges to modify there which is a pain!):

1. Copy the existing website configuration (virtual directory):
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite

2. Modify the following of mysite:
gksudo gedit /etc/apache2/sites-available/mysite
/var/www -> /home/USERNAME/public_html

3. enable mysite and disable default
sudo a2ensite
sudo a2dissite default
sudo /etc/init.d/apache2 reload

/home/USERNAME/public_html can now be accessed as webroot in webbrowser as http://localhost

PHP
########################
Setup PHP at this file: /etc/php5/apache2/php.ini
short_open_tag = Off (only use <php ?>? rather than non-standard <? ?> (inverted <)
error_reporting = E_ALL | E_STRICT (see all errors including the E_STRICT ones)
display_errors = On (obvious…)
display_startup_errors = On
html_errors = On

Remember to run this to update the apache configuration:
sudo /etc/init.d/apache2 restart

MYSQL
########################
user = root
Remember to use innoDB as storage engine for mySQL databases as it enables transactions and much more.

PHPMYADMIN
########################
access phpmyadmin at localhost/phpmyadmin (use “root” as user)

External guide with lots of more stuff including security: https://help.ubuntu.com/10.04/serverguide/C/httpd.html

Leave a Reply

Your email address will not be published. Required fields are marked *