Browsing articles in "Programming"
Oct
31

Installing Apache2 and PHP 5.4 from source on Ubuntu 11.10

By Luc  //  Linux, Php, Programming, System  //  No Comments

This guide will show you how to install Apache 2.2 (2.2.21) and PHP 5.4 and MySQL 5.6 from the latest source

First, we will make sure that the development environment and libraries are install on your server
Setup Development Environment tools and libraries

sudo apt-get update
sudo apt-get -y -q install make g++ flex bison build-essential zlib1g-dev binutils cmake
sudo apt-get -y -q install libmcrypt-dev libmhash-dev libxslt1-dev libtidy-dev libbz2-dev libxml2-dev libssl-dev libmysqlclient16 libmysqlclient16-dev
sudo apt-get -y -q install libpng12-dev libpng12-0 libpng3 libjpeg62 libjpeg62-dev libxpm-dev libpcre3 libpcre3-dev zlib1g zlib1g-dev libltdl-dev libltdl7
sudo apt-get -y -q install pkg-config libcurl4-openssl-dev libfreetype6 libfreetype6-dev libc-client2007e libc-client2007e-dev libkrb5-3 libkrb5-dev
sudo apt-get -y -q install openssl libglobus-openssl libglobus-openssl-dev libcurl4-openssl-dev libicu-dev libicu44 libpspell-dev
sudo apt-get -y -q install linux-libc-dev libc-dev-bin libc-bin libc-client2007e-dev eglibc-source libkrb5-3 libkrb5-dev libkrb53 libkrb5support0
sudo apt-get -y -q install libncurses5-dev libncurses5 ncurses-base ncurses-bin ncurses-term libaio-dev

Installing Apache 2.2.21 from source

wget http://apache.mirror.nexicom.net//httpd/httpd-2.2.21.tar.gz
tar zxf httpd-2.2.21.tar.gz cd httpd-2.2.21
./configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-deflate --enable-expires --enable-headers --enable-usertrack --enable-ssl --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so
make -s
sudo make install
sudo mkdir /var/www/
sudo chgrp -R www-data /var/www/

Configure Apache2 to start automatically when system is rebooted

runlevel (should output a number like 2)
cd /etc/rcX.d/ (replace X with the number you saw when you run 'runlevel')

sudo ln -s -T /usr/local/apache2/bin/apachectl S80apache

Easy enough, Apache2 is already installed and ready to serve normal HTML web pages.

You can control the status of the web server with these commands:

Stop the web server
/usr/local/apache2/bin/apachectl stop

Start the web server
/usr/local/apache2/bin/apachectl start
Installing MySQL 5.6 from source

sudo groupadd mysql
sudo useradd -r -g mysql mysql

sudo mkdir /var/log/mysql/
sudo chgrp -R mysql /var/log/mysql/

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.3-m6.tar.gz/from/http://mirror.csclub.uwaterloo.ca/mysql/
mv index.html mysql.tar.gz
tar zxf mysql.tar.gz
cd mysql-5.6.3-m6/
mkdir bld
cd bld
cmake -DBUILD_CONFIG=mysql_release ..
sudo make install

cd /usr/local/mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
sudo scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data

sudo chown -R root .
sudo chown -R mysql data

sudo cp support-files/my-medium.cnf /etc/my.cnf
sudo cp support-files/mysql.server /etc/init.d/mysql.server

Edit configuration file sudo nano /etc/mysql/my.cnf

under [MYSQLD] edit or add the following lines:
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

to save
to exit

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
sudo /usr/local/mysql/bin/mysqladmin -u root password "NEW PASSWORD"

Installing PHP 5.4 from source

wget http://downloads.php.net/stas/php-5.4.0beta2.tar.gz
tar zxf php-5.4.0beta2.tar.gz
cd php-5.4.0beta2/
'./configure' '--disable-short-tags' '--enable-exif' '--with-zlib' '--with-bz2' '--with-openssl' '--with-pcre-regex' '--with-gettext' '--with-mcrypt' '--with-mhash' '--with-iconv' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-xpm-dir' '--with-xsl' '--with-tidy' '--with-freetype-dir' '--enable-gd-native-ttf' '--enable-calendar' '--enable-mbstring' '--enable-ftp' '--enable-bcmath' '--enable-sockets' '--enable-dom' '--enable-xml' '--enable-soap' '--enable-libxml' '--enable-session' '--enable-simplexml' '--enable-calendar' '--without-pear' '--enable-mbstring' '--disable-cli' '--with-png-dir=/usr/lib/libpng12.so' '--with-mysql-sock' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' --with-imap-ssl --with-kerberos --with-curl --enable-ftp
make -s
sudo make install

If you want to configure PHP in development mode, run this line:
sudo cp php.ini-development /usr/local/lib/php.ini

If you want to configure PHP in production mode, run this line:
sudo cp php.ini-production /usr/local/lib/php.ini

Configuring Apache2 to run PHP scripts

wget http://apache.parentinginformed.com/httpd/mod_fcgid/mod_fcgid-2.3.6.tar.gz
tar zxf mod_fcgid-2.3.6.tar.gz
cd mod_fcgid-2.3.6
APXS=/usr/local/apache2/bin/apxs ./configure.apxs
make
sudo make install

You also need to edit Apache2 config file

Order allow,deny
Allow from all
AllowOverride All
Options MultiViews Indexes Includes FollowSymLinks ExecCGI

Jun
12

Build and install APC extension on Mac OSX 10

By Luc  //  Mac, Php, Programming, System  //  5 Comments

If you tried to install the APC extension on the MAC and got the following error:

pecl mac error: ‘apc_regex’ has no member named ‘nreg’

The problem is that APC depends on the PCRE library and we need to install it before compiling APC. Here is how to fix it!

  • Open a TERMINAL session,  type :  mkdir  temp
  • Head up to this page and download a PCRE library (try to use the latest one). I took pcre-8.12.zip, put the file inside the temp directory
  • uncompress the PCRE archive via Finder (or any other way)


cd  pcre-x.xx replace x with the version number (example: cd  pcre-8.12)
./configure
make
sudo make install

  • now download the latest APC release (link here)
  • uncompress the APC archive via finder  (or terminal by typing    tar zxf  APC-X-XX  replace X with archive name and version number )
  • type

cd ~/temp/APC-3.1.9    (change the version number if you're using something different)
phpize

./configure
make

sudo make install

you should see something similar to this when it’s done compiling

Installing shared extensions:     /usr/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files:          /usr/include/php/

 

Modify your php.ini file to have the extension loaded at php startup

  • Open /private/etc/php.ini   (in Finder, select GO menu, select GO TO FOLDER and type /private/etc)
  • add this line in the Dynamic extensions area

extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so

Restart the web server (reboot your machine if your lazy, or go into the System preferences, click on Sharing, un-select Web sharing , wait a few seconds and select it again )

You’re done, congrats!

 

Note:

There is a bug in version APC 3.1.9  :-)

if you get error

Fatal error: Unknown: apc_fcntl_unlock failed: in Unknown on line 0

Relax! just modify the file apc_lock.h inside the APC folder you created. Edit the following line around lines 155-160

Find the following:

# define apc_lck_rdunlock(a) apc_fcntl_unlock(&a TSRMLS_CC)

Replace by the following

# define apc_lck_rdunlock(a) apc_fcntl_unlock(a TSRMLS_CC)

 

Recompile APC by doing:

cd ~/temp/APC-x-xx (replace X with version number) make clean phpize ./configure make sudo make install

And restart your web server! Too easy !  enjoy!

 

 

Mar
22

history behind theKolonee and WoxCore

By Luc  //  Php, Programming  //  2 Comments

You may wonder why I felt the need to write another PHP framework when there are already plenty freely available on the market. I will do my best to describe my problems.

read more

Mar
14

theKolonee CMS

By Luc  //  Php, Programming  //  No Comments

I’m still working on my own personal CMS project theKolonee. Since it’s a part time hobby, the development does not goes always as fast I want it to go.
To make sure it’s not missing any feature, I created another site with it: VirtualShowCar. By doing that, I can measure the power and weaknesses of the CMS in real time as I build the site.
When a feature is not working, I know right away.

Go check the site for more information.

* supports the latest PHP version 5.3.2

Aug
11

woxcore project created on googlecode

By Luc  //  Php, Programming  //  3 Comments

I create a new source code repository on GoogleCode.  WoxCore is the framework I created to build my new CMS named theKolonee. I will commit soon. Feel free to comment and contribute.

Features

  • Multi lingual
  • MVC
  • Static content can be separated and delivered over a CDN (content delivery network)
  • bulk import of files
  • support APC and MemCache?
  • very lightweight and fast (one single file, so no recursive includes)
  • Uses PHP 5.3 new features
Aug
11

Working on a new cms!

By Luc  //  Php, Programming  //  2 Comments

If you ever tried to do a multi-lingual site, you know that this is a painful task!   read more