jpablobr.com

→ php staging environment for continuous integration part 1

More on: php, staging environment, continuous integration, Sun Nov 04 00:33:02 -0600 2009

Ubuntu server configuration: (Ubuntu Jaunty Jackalope (Ubuntu 9.04))

Most of the how-to is a compilation from various how-to's I used... (Check them for further reference)
First, I pretty much follow this tut till page # 3:

The Perfect Server - Ubuntu Jaunty Jackalope (Ubuntu 9.04)

Installing Git

Now that we have a fairly simple and stable environment I prefer to configure Git and the SSH requires just in case something goes wrong it wouldn’t be such a pain to reinstall everything...

I pretty much only installed openssh-server and set up the keys so I don’t need to use password authentication (which is a requirement for Git). Don’t continue if you don’t have this set up because that’s why I was talking about reinstalling the whole thing again...

I also wrote on this previews post, a how-to about how to set up RSA key authentication in Eclipse or Aptana IDE

However, here are some good resources for SSH:

This is the best tutorial I’ve found so far, and it has very good links references…

Installing Git on a server (Ubuntu or Debian)

Step 1: Install Git. You'll have to do this ON BOTH YOUR SERVER AND LOCAL MACHINE. If you're running a different OS for your client find and check out instructions for installing git on that OS instead. See this link for OS X if you don't have Mac Ports.

sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install git-core

Step 2: Set up the server. We'll have to do some work on the server. We're going to use Gitosis which needs python and a python setup tool to get running. Grabbing the python setup tool in Debian/Ubuntu will grab all the requirements if you don't already have them:

sudo apt-get install python-setuptools

Step 3: Gitosis. Now it's time to get Gitosis. For the most part I followed the instructions on scie.nti.st, so full credit and many thanks to them. Once you're done with my instructions, I recommend you go visit them and read more details on adding users and some other advanced topics.

From your home directory on your server, create a new directory called src, and from there grab the gitosis code.

mkdir ~/src cd ~/src git clone git://eagain.net/gitosis.git

Install it using the python setup tool we grabbed earlier.

cd gitosis sudo python setup.py install

Step 4: Setup some security. We're next going to add a new user called git. This is the guy that will do all the heavy lifting for us!

sudo adduser \ --system \ --shell /bin/sh \ --gecos 'git version control' \ --group --disabled-password \ --home /home/git \ git

IMPORTANT: If you have locked down ssh, don't forget to go into your /etc/ssh/ssh_config file and add git to the list of Allowed Users that can login. That list of users is separated by a space not a comma.

I always encourage the use of public/private key exchange and in the case of gitosis it looks to be required. Generate a key if you haven't already. See instructions for public/private key here. I'm going to assume that from this point on you can access your server from your local machine using a public key exchange!

Next, copy your id_rsa.pub file over to your server somewhere (in our example we're using /tmp) and then run this command:

sudo -H -u git gitosis-init < /tmp/id_rsa.pub

You'll see output like this:

Initialized empty Git repository in . Initialized empty Git repository in .

Others have reported seeing that 3 times but when I did it on Ubuntu Hardy Heron I only saw it twice.

Step 5: Minor permissions tweak.</strong> Just in case, let's make sure permissions are set correctly:

sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

We're now done with the server config! From your local machine, test it out with this:

git clone git@YOUR_SERVER:gitosis-admin.git

If all went well you have a gitosis-admin directory with a gitosis.conf file and keydir directory. We're basically setup now. We just need to create a new repository and push it to the server.

Also, as promised here are some resources: (I added a couple more)

Now we can continue with the rest of the system configuration.

Set system locale:

sudo locale-gen en_US.UTF-8 sudo /usr/sbin/update-locale LANG=en_US.UTF-8

Install PHP with php client and without apache (one long line):

sudo aptitude -y install php5-common php5-dev php5-mysql php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-cgi php5-mcrypt php5-curl php5-gd php5-memcache php5-mhash php5-pspell php5-snmp php5-sqlite libmagick9-dev php5-cli

Fix issues with imagick:

sudo aptitude -y install make php-pear sudo pecl install imagick

Adjust php.ini memory limit:

sudo vim /etc/php5/cgi/php.ini

Find line:

memory_limit = 16M and change it to: memory_limit = 48M

Append to the end of this file this line:

extension=imagick.so

For installing Apache2, PHP (5 & 4) & MySql check this tut

After the MySql install

mysql-server libapache2-mod-auth-mysql php5-mysql

I like to run

mysql_secure_installation

Phpmyadmin and mysql-admin

PhpMyAdmin is a very famous MySQL management software package. To use it you should install and configure PHP, Apache and php mysql (or mysqli) extension see ApacheMySQLPHP for instructions.

Install phpMyAdmin From Package (source)

Install phpMyAdmin from the Universe repository see InstallingSoftware for detailed instructions on using repositories and package managers.

From console:

sudo apt-get install phpmyadmin

To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf.

Include /etc/phpmyadmin/apache.conf

Once phpMyAdmin is installed point your browser to http://localhost/phpmyadmin to start using it. You should be able to login using any users you've setup in MySQL. If no users have been setup, use admin with no password to login.

Should you get a 404 "Not Found" error when you point your browser to the location of phpMyAdmin (such as: http://localhost/phpmyadmin) this is likely caused by not checking the 'Apache 2' selection during installation. To redo the installation run the following:

sudo dpkg-reconfigure -plow phpmyadmin

Then select Apache 2 for the webserver you wish to configure.

If this does not work, then you can do the following to include the phpMyadmin-shipped Apache configuration into Apache:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf sudo /etc/init.d/apache2 reload

Troubleshooting Phpmyadmin & mysql-admin

If you get blowfish_secret error: Choose and set a phrase for cryptography in the file /etc/phpmyadmin/blowfish_secret.inc.php and copy the line (not the php tags) into the file /etc/phpmyadmin/config.inc.php or you will receive an error.

If you get a 404 error upon visiting http://localhost/phpmyadmin: You will need to configure apache2.conf to work with Phpmyadmin.

sudo vim /etc/apache2/apache2.conf

Include the following line at the bottom of the file, save and quit.

Include /etc/phpmyadmin/apache.conf

These are the steps I followed in order to get cakephp working on my user public_html folder. (Source)

as many of you probably know, if you have apache's userdir module loaded, you can put your web pages on /home/user/public_html , and access them with the url: http://localhost/~user/ . I really prefer this, so all my web pages are on my personal home, but how to configure cakephp to work with these paths, i got a hard time with this, but finally got it!. here's how:

In case you don't have apache2's userdir module:

sudo ln -s /etc/apache2/mods-available/userdir.load /etc/apache2/mods-enabled/userdir.load sudo ln -s /etc/apache2/mods-available/userdir.conf /etc/apache2/mods-enabled/userdir.conf

You need the rewrite module also... (this could be done with the same method used for userdir)

sudo a2enmod rewrite

Now lets edit some apache files...

sudo vim /etc/apache2/sites-enabled/mysite

Inside the first two directory/directory tags, change the AllowOverride lines:


                Options FollowSymLinks
                AllowOverride All // change here
                
            
              
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All // change here
              Order allow,deny
              allow from all
              # This directive allows us to have apache2's default start page
              # in /apache2-default/, but still have / go to the right place
              #RedirectMatch ^/$ /apache2-default/
              
            

Do the same on /etc/apache2/mods-enabled/userdir.conf

AllowOverride All // change here Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

Now you need to restart you apache2 server...

sudo /etc/init.d/apache2 restart

I'll assume you've already downloaded cakephp latest release or that you know where you can find it

Unpack the downloaded file in /home/user/public_html/

rename the extracted folder (thats the name of your application)

cd /home/user/public_html/application_name

edit the .htaccess file so it look like these:

RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] RewriteBase /~user/application_name/

now point your browser to http://localhost/~user/application_name and you show see cakephp's default page

Here you can find the second part of this how-to…
blog comments powered by

Disqus