Dev Notes

Software Development Resources by David Egan.

Set up a LAMP stack

Linux, Sysadmin
David Egan

Install Apache

sudo apt-get update

sudo apt-get install apache2

If Apache has installed correctly, http://localhost will now display the Apache2 Ubuntu Default Page.

Install MySQL

We will also include “helper” packages:

sudo apt-get install mysql-server php5-mysql

It is not necessary to run sudo apt-get update before installing MySQL because it was run prior to installing Apache - so we can assume that everything is up to date.

Set passwords for root user when prompted (twice).

Set up MySQL database directory structure:

sudo mysql_install_db

Remove dangerous defaults - removes anonymous users, and prevents root login remotely, etc. Be careful with removal of remote root login - new user will be necessary. This script is probably not necessary on local environment install:

sudo mysql_secure_installation

If the MySQL install goes wrong and you need to start again:

sudo apt-get remove --purge mysql*

sudo apt-get autoremove

sudo apt-get autoclean

Install PHP

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Modify default for Apache serving files, give preference to PHP:

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

<IfModule mod_dir.c>
    DirectoryIndex index.html index.cgi index.php index.xhtml index.htm

Bring index.php to head of the queue.

Restart Apache:

sudo service apache2 restart

PHP Modules

Get a list: apt-cache search php5-

Test PHP:

sudo nano /var/www/html/info.php



Don’t leave the file in place - security vulnerability:

sudo rm /var/www/html/info.php

NOTE: Document root is currently /var/www/html

Change Document Root & Enable Rewrites

To change document root to /var/www, and enable rewrites.

Make sure mod_rewrite is installed:

sudo a2enmod rewrite

If mod_rewrite is not enabled, running this command will enable it. Restart Apache:

service apache2 restart

Find output of ls /etc/apache2/sites-enabled

In this case, 000-default.conf

This file is used for httpd configuration in /etc/apache2/sites-available/

Edit the config file: sudo nano /etc/apache2/sites-available/000-default.conf …by adding this code block, and commenting out the DocumentRoot /var/www/html:

DocumentRoot /var/www
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

Restart Apache: sudo service apache2 restart

Install PHPMyAdmin

sudo apt-get install phpmyadmin

sudo nano /etc/apache2/apache2.conf …and include this line:

Include /etc/phpmyadmin/apache.conf

“Since Ubuntu 13.10 (Saucy Salamander), Apache no longer loads configuration files from the /etc/apache2/conf.d directory. Instead, they are loaded from the /etc/apache2/conf-enabled directory. Therefore, if you need to manually include the phpMyAdmin-shipped Apache configuration file, you must run the following:”

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/phpmyadmin.conf

sudo /etc/init.d/apache2 reload

Install PHP curl

sudo apt-get install php5-curl

sudo service apache2 restart

Install cURL

“Curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos…), file transfer resume, and proxy tunneling.”

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

This allows WP-CLI to be installed.

comments powered by Disqus