Lucid ships with php 5.3, the newest version of php. Unfortunately a number of popular open source content management systems do not yet run on 5.3. This was also an issue when I upgraded my mac to Snow Leopard. In both cases, php 5.3 must be downgraded to 5.2.10 (you could choose to run both versions too, but I’m not going to address that here).
Setting up a Lucid server on SliceHost
on Slicehost, if you’re willing to wipe out everything, you can rebuild a clean slice for Lucid, which is what I chose.
- upgrade your kernel to 2.6.32-16.25
- rebuild slice with Lucid
As soon as the build is complete, you need to ssh in, and
- change the root password
passwd
- create a sudoers group and create and add a user to it
groupadd sudoers visudo
add
%sudoers ALL=(ALL) ALL
create user with sudo privileges
useradd yourUserName usermod -a -G sudoers yourUserName
- edit ssh configuration to disallow root login
vi /etc/ssh/sshd_config
find
PermitRootLogin yes
and set it to
PermitRootLogin no
add
AllowUsers yourusername
- setup IPtables
I used http://articles.slicehost.com/2010/4/30/ubuntu-lucid-setup-part-1 - reload ssh
/etc/init.d/ssh reload
- Add additional sources to sources.list. See sources list generator for more sources lists.
vi /etc/apt/sources.list
- Set to use bash
dpkg-reconfigure dash
select “no”
- synchronize date
apt-get install ntp ntpdate
- Install tools for compiling
apt-get install build-essential
- if you’re a vi user, install vim-nox (hint: I used to install vim-full, but that’s now deprecated in Lucid)
apt-get install vim-nox
Set up LAMP server
- If you don’t need to compile from source, you can use one of Ubuntu’s 1-liners for installing a LAMP server.
tasksel1 or 1apt-get install lamp-server^
I used the latter. This will return the following:
apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl libdbi-perl libexpat1 libhtml-template-perl libmysqlclient16 libnet-daemon-perl libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-common mysql-server mysql-server-5.1 mysql-server-core-5.1 php5-common php5-mysql psmisc Suggested packages: www-browser apache2-doc apache2-suexec apache2-suexec-custom ufw php-pear zbishell libipc-sharedcache-perl tinyca mailx php5-suhosin The following NEW packages will be installed: apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libdbd-mysql-perl libdbi-perl libexpat1 libhtml-template-perl libmysqlclient16 libnet-daemon-perl libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-common mysql-server mysql-server-5.1 mysql-server-core-5.1 php5-common php5-mysql psmisc
- test apache
http://www.domainname.com/
should return “It Works!” - test php
vi /var/www/test.php <php phpinfo(); ?>
- reload apache
/etc/init.d/apache2 restart
navigate in browser to http://www.domainname.com/test.php
- check that mysql is bound to localhost
cat /etc/mysql/my.cnf | grep bind-address
should return
bind-address =127.0.0.1
If it doesn't, edit /etc/mysql/my.cnf with correct address
Ok! everything works as planned. Two small tasks remaining: We need to downgrade php from 5.3 to 5.2.10 and install more php libraries.
Downgrading Lucid from PHP 5.3 to 5.2
There are several methods floating around out there, which all use the same idea.
- MrKandy wrote a good script
- Nck Veenhof
- the jibe blog. I used the bash script provided in the comments on this blog post because it was the most succinct.
For future use, I created this bash script
You can either execute that script as a bash script or execute it within the shell. I initially executed it within the shell, then later decided to save it as an executable script for future use.
To execute as a script
- create a directory somewhere you'd like to store scripts. It could be ~/home/username/scripts. Copy the bash script above to your scripts directory, name it someName.sh, and make it executable
chmod ugo+x
- execute the script
sudo ./someName.sh
sudo apt-get update
sudo apt-get install $php_packages
Essentially, the way it works is it finds all the php 5.3 packages and removes them, then uses sed to replace "lucid" with "karmic" in the sources list and saves that in /etc/apt/sources/preferences.d which is iterated over first during update. It then pins the karmic sources for php packages so that the php version isn't inadvertently updated during update/upgrade.
Next step for me was to install some more php packages since the initial install was so minimal and I wiped it out anyway.
apt-get install php5-cli php5-curl php5-imagick php-pear php5-sqlite php5-xmlrpc php5-xsl
and finally, I like to use phpmyadmin for managing multiple databases:
apt-get install libapache2-mod-auth-mysql phpmyadmin
select [*] apache 2 by hitting the space bar
If this is a fresh install, select yes when asked to configure dbconfig-common
enter the mysql root password created earlier
enter a password for the phpmyadmin admin account
navigate in a browser to http://www.domainname/phpmyadmin
Why didn't I just not install 5.3 and build 5.2 in? Because I think it's actually faster this way. For me at least. I install defaults, test that apache and mysql work as expected, downgrade to 5.2, install remaining php packages. Fairly straight-forward. If only it had been so easy on my mac.
Will I do this on my production servers? Probably not for php applications. Ubuntu 8.04 is supported for another year and 9.04 is supported for 2 years. There's no hurry. I will, however, probably go ahead and use 10.04 for Rails, Django, and Plone installations.
Update: Rolling Back
3/17/2011
To roll this back, do the following:
- list out the php modules installed to compare
dpkg -l | grep php
- archive outside of sources directory or comment out /etc/apt/sources.list.d/karmic.list
- archive /etc/apt/preferences.d/php outside of the sources directory
apt-get update apt-get upgrade
- I manually reinstalled php5 and modules even though apt-get should update should update them:
apt-get install libapache2-mod-php5 php5-common php5-mysql php-pear php5-suhosin libapache2-mod-php5 php5-curl php5-imagick php-pear php5-sqlite php5-xmlrpc php5-xsl
- I had to remove the "#" mark from imagick.conf and cli.conf - apparently that's been deprecated as a comment symbol
- if you're running WordPress, don't forget to edit php.ini with the date/time zone. Initially I got an internal server error after restoring php5. Fixing the date/time seemed to do the trick.
Why?
I was installing an application for a friend and needed to install ffmpeg packages. Unfortunately, when I ran apt-get update, I received the below error:
APT::Cache limit ... .... Dynamic MMap out of room! ... Problem with MergeList /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_dapper_main_binary-i386_Packages E: The package lists or status file could not be parsed or opened.
The default Apt Cache limit was too low for all the sources (Lucid and Karmic). I stepped through the troubleshooting procedure for packages, upping my apt cache to 200000000 which is quite high and the error disappeared. In the end I decided to just keep it tidy and rollback. All of the php applications I'm running work fine on 5.3.
June 1st, 2010 at 2:38 am
Great work! Thanks!
August 14th, 2010 at 1:46 am
[...] semioticpixels.com – Setting up Ubuntu Lucid 10.04 for web development [...]