Skip to content

Instantly share code, notes, and snippets.

@yegeniy
Created April 12, 2012 04:00
Show Gist options
  • Save yegeniy/2364518 to your computer and use it in GitHub Desktop.
Save yegeniy/2364518 to your computer and use it in GitHub Desktop.
Dev environment setup on Ubuntu for PHP, Mongo, MySQL

Install php

sudo apt-get install -y php5-common libapache2-mod-php5 php5-cli curl libcurl3 libcurl3-dev php5-curl php5-mcrypt php5-ldap php5-gd php5-mysql phpunit php-pear

sudo pear upgrade pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear install --alldeps phpunit/PHPUnit

References:

http://www.e-gineer.com/v1/instructions/install-gd13-for-php-with-apache-on-linux.htm

Make opensky.lcl work

sudo vi /etc/hosts

127.0.0.1 opensky.lcl www.opensky.lcl

Then go to opensky.lcl in a browser

Edit php.ini: (mine is at /etc/php5/apache2/php.ini ) and add this line: extension=curl.so

sudo /etc/init.d/apache2 restart

Install mysql server 5.5

Use this install script:

https://gist.github.com/2063867

Create opensky_devo database:

mysqladmin -uroot create opensky_devo

Initiate the schema:

./bin/schema --env=dev

if apache rewrite isn't enabled, install it:

a2enmod rewrite
sudo /etc/init.d/apache2 restart

If you run out of memory:

in php.ini set memory_limit to -1

References:

http://stackoverflow.com/questions/415801/allowed-memory-size-of-33554432-bytes-exhausted-tried-to-allocate-43148176-byte

Install MongoDB

Add the following line to /etc/apt/sources.list

deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

sudo aptitude update
sudo apt-get update
sudo apt-get install mongodb-10gen
sudo pecl install mongo

Add the following line to /etc/php5/cli/php.ini and /etc/php5/apach2/php.ini

extension=mongo.so

Mongo should be running, if it's not:

sudo mongod --config /etc/mongodb.conf

References:

http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages

Setup VPN

sudo apt-get install -y openvpn resolvconf

Troubleshooting

Unintstall old version of MySQL

To search for installed packages containing mysql:

sudo aptitude search mysql | grep -P "i   "
i   libmysql++-dev                  - MySQL C++ library bindings (development)  
i   libmysqlclient-dev              - MySQL database development files          
i   libqt4-sql-mysql                - Qt 4 MySQL database driver                
i   mysql-client-5.1                - MySQL database client binaries            
i   mysql-common                    - MySQL database common files, e.g. /etc/mys
i   mysql-server                    - MySQL database server (metapackage dependi
i   mysql-workbench-gpl             - MySQL Workbench                           
i   php5-mysql                      - MySQL module for php5    

To remove those packages automatically:

sudo aptitude search mysql | grep -P "i   \w" | awk '{print $2}' | xargs -i sudo apt-get remove -y {}

If that fails this is a copy of my history when uninstalling:

sudo apt-get purge mysql-server

sudo apt-get autoremove

sudo apt-get clean

sudo apt-get udpate && sudo apt-get upgrade

sudo apt-get update && sudo apt-get upgrade

sudo apt-get install mysql-server build-essential

MySQL Reset root password

sudo stop mysql
mysqld_safe --skip-grant-tables

in another console:

mysql --user=root mysql

and execute:

update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
exit;

Problems with mongo and PHP

If you get an error installing mongo try:

sudo apt-get remove mongodb-clients
sudo apt-get install mongodb-10gen

sudo mongod --config /etc/mongodb.conf

sudo pecl install mongo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment