Setting Up Local (Web) Development Environment
May 14th, 2008 | by hantu |I have been working on hyourinmaru quite often, and I feel that I neglected zangetsu. I decided that I should properly setup the (web) development environment I needed.
The following guide has been tested on Ubuntu 8.04 Hardy Heron only, not sure if it will work elsewhere.
(hyourinmaru is my MacBook running Leopard, zangetsu is my desktop running Ubuntu 8.04)
Installing MySQL
At the time of writing, 5.0.51b is the latest stable release. I downloaded the source of it from mysql.com.
sudo groupadd mysql
sudo useradd -g mysql mysql
tar zxvf mysql-5.0.51b.tar.gz (Specify the path, if the file is not in your current working directory)
cd mysql-5.0.51b
./configure --prefix=/opt/mysql
make
sudo make install
sudo cp support-files/my-medium.cnf /etc/my.cnf
cd /opt/mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
sudo bin/mysql_install_db --user=mysql
sudo chown -R root .
sudo chown -R mysql var (According to MySQL [1], the data directory must be owned by mysql)
sudo bin/mysqld_safe --user=mysql & (We are still in /opt/mysql)
sudo bin/mysqladmin version (Just to see MySQL started correctly)
sudo bin/mysqladmin variables (More checking)
sudo bin/mysqladmin -u root shutdown (Check if we can shutdown MySQL)
sudo bin/mysqld_safe --user=mysql --log &
bin/mysql -u root
DROP USER ''; (We are in the mysql shell, I removed anonymous user altogether)
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpass');
SET PASSWORD FOR 'root'@'zangetsu' = PASSWORD('yourpass');
sudo bin/mysqladmin -u root -p shutdown (Now you need the password to shutdown)
sudo bin/mysqld_safe --user=mysql --log &
Installing Apache HTTP Server
Apache HTTP Server 2.2.8 is the latest version, and can be downloaded from here.
tar zxvf httpd-2.2.8.tar.gz cd httpd-2.2.8 ./configure --prefix=/opt/apache --enable-so --enable-rewrite (You can always change the options, depending on what you want) make sudo make install cd /opt/apache sudo vim conf/httpd.conf (Edit config file appropiately, I won't get into details here) sudo bin/apachectl -f conf/httpd.conf (Tries to start HTTP server)
Browse to http://localhost/ and if you see ‘It Works!’ (I did not change DocumentRoot), then the server is running fine.
Adding apachectl to /etc/init.d/:
sudo cp bin/apachectl /etc/init.d/apachectl sudo chmod +x /etc/init.d/apachectl
Following the recommendation from David Winter [2], time to secure the install:
sudo useradd -g nogroup apache sudo vim /opt/apache/conf/httpd.conf
Change:
User daemon Group daemon
to:
User apache Group nogroup
Restart Apache and check if it is running as user apache
sudo /etc/init.d/apachectl start ps aux | grep httpd
Installing PHP 5
I obtained the latest PHP 5 release from the php.net.
tar zxvf php-5.2.6.tar.gz cd php-5.2.6 ./configure --prefix=/opt/php --with-apxs2=/opt/apache/bin/apxs --with-mysql=/opt/mysql --with-gd --enable-soap --with-zlib (If you want to include other things, do ./configure --help) make sudo make install sudo vim /opt/apache/conf/httpd.con
I added the below two lines between <IfModule mime_module> and </IfModule>
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
Now start your HTTP server, and try it out. Works like a charm for me!
Installing Ruby
The latest available Ruby version is 1.8.6, at this time.
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p114.tar.gz tar zxvf ruby-1.8.6-p114.tar.gz cd ruby-1.8.6-p114 ./configure --prefix=/opt/ruby make sudo make install
After all those are done, check your installation by:
/opt/ruby/bin/ruby --version
It should return something like:
ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-linux]
Installing Rails
I am using RubyGems to install Rails, the latest RubyGems is 1.1.1.
wget http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz
tar zxvf rubygems-1.1.1.tgz
cd rubygems-1.1.1
export GEM_HOME=/opt/ruby/gems
sudo /opt/ruby/bin/ruby setup.rb config –prefix=/opt/ruby
sudo /opt/ruby/bin/ruby setup.rb setup
sudo /opt/ruby/bin/ruby setup.rb install
Check your installation by:
/opt/rubygem/bin/gem --version
You should get:
1.1.1
Then check if there’s any updates available:
/opt/rubygem/bin/gem update --system
Now let’s move on to install Rails:
sudo /opt/rubygem/bin/gem install rails --include-dependencies
Checking Rails version:
sudo /opt/ruby/bin/rails --version
And I also installed the MySQL gem:
sudo gem install mysql -- --with-mysql-dir=/opt/mysql
Done!
Troubles!
After I created a test application using Rails, I tried to start the server using:
/opt/ruby/bin/ruby script/server
I came across this error: no such file to load — openssl
After some searching online, I found this [3] and [4].
sudo apt-get install libssl-dev cd /path/to/sources/ruby-1.8.6-p114 cd ext/openssl sudo /opt/ruby/bin/ruby extconf.rb make sudo make install
Finally, start the server again, browse to http://localhost:3000 - and it works!
ref:
You must be logged in to post a comment.