Skip to content

Instantly share code, notes, and snippets.

@thinkadoo
Forked from kbond/post.md
Created November 18, 2012 15:55
Show Gist options
  • Save thinkadoo/4105967 to your computer and use it in GitHub Desktop.
Save thinkadoo/4105967 to your computer and use it in GitHub Desktop.
Ubuntu PHP Development Environment Setup

Install git/subversion:

sudo apt-get install git subversion

Configure Git:

git config --global user.name "Your Name"
git config --global user.email "Your Email"

ssh-keygen -t rsa -C "Your Email"
cat ~/.ssh/id_rsa.pub

Install apache/php:

sudo apt-get install apache2 php5 php5-cli libapache2-mod-php5 php5-dev

Ensure this worked by visiting http://localhost/. You should see It works!.

Edit your php.ini:

sudo nano /etc/php5/cli/php.ini
  1. Add a timezone

     date.timezone = America/New_York
    
  2. Turn off short tags

     short_open_tag = Off
    

Install mysql (enter through password prompts to use use defaults):

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Install phpmyadmin (choose apache2 and enter through password prompts to use default):

sudo apt-get install phpmyadmin

Edit phpmyadmin config.inc.php:

sudo nano /etc/phpmyadmin/config.inc.php

Add/edit the following (around page 42):

// ...

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';

$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
$cfg['Servers'][$i]['user'] = 'root';
/* Server parameters */

// ...

Ensure this worked by visiting http://localhost/phpmyadmin.

Install useful php modules:

sudo apt-get install php5-mcrypt php5-xdebug php5-curl php5-sqlite php5-xsl php5-intl php-pear php-apc

Change php.ini directory for apache to use the same config as cli:

Edit /etc/apache2/mods-enabled/php5.load to look like the following:

PHPIniDir "/etc/php5/cli"

LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

Install PHPUnit/Behat/Mink:

sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover pear.symfony.com
sudo pear channel-discover pear.behat.org

sudo pear install --alldeps phpunit/PHPUnit
sudo pear install --alldeps behat/behat
sudo pear install --alldeps behat/mink

Appendix

A. Enable SSL

Install ssl-cert:

sudo apt-get install ssl-cert

Enable ssl and default ssl site in apache:

sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 restart

B. Install Twig C Extension

Reference: http://twig.sensiolabs.org/doc/intro.html#installing-the-c-extension

Run the following:

git clone https://github.com/fabpot/Twig.git
cd Twig/ext/twig/
sudo phpize
sudo ./configure
sudo make
sudo make install

Add the following to /etc/php5/cli/php.ini:

extension=twig.so

Restart Apache:

sudo apache2ctl restart

C. Samba

Reference: http://www.howtogeek.com/howto/ubuntu/install-samba-server-on-ubuntu/

Install samba:

sudo apt-get install samba smbfs

Edit /etc/samba/smb.conf:

...
####### Authentication #######

security = user
username map = /etc/samba/smbusers
...
[homes]
    comment = Home Directories
    browseable = yes        
    read only = no        
    valid users = %S
    
    # change to desired permissions
    create mask = 0644
    directory mask = 0644
    force create mode = 0644
    force directory mode = 0644

Create a samba user:

sudo smbpasswd -a <username>

Add user to map file (/etc/samba/smbusers):

<username> = "<username>"

Restart samba:

sudo restart smbd

D. FTP

Reference: https://help.ubuntu.com/10.04/serverguide/C/ftp-server.html

Install vsftpd:

sudo apt-get install vsftpd

Configure /etc/vsftpd.conf:

write_enable=YES
local_umask=022

Restart service:

sudo restart vsftpd

E. Smart DNS

Install dnsmasq

Reference: http://www.jejik.com/articles/2008/08/easily_develop_and_deploy_web_applications_from_subversion/

apt-get install dnsmasq

Edit /etc/dnsmasq.conf:

listen-address=127.0.0.1
address=/localhost/127.0.0.1

Edit /etc/dhcp3/dhclient.conf:

prepend domain-name-servers 127.0.0.1;

Edit /etc/resolv.conf (after search directives):

nameserver 127.0.0.1

Restart dnsmasq:

/etc/init.d/dnsmasq restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment