Setting up your local development environment – PHP

Posted July 3rd, 2010 in Tehnikalije by smottt

Last time we went through steps needed for setting up apache. Now we will set up PHP. At the time of writing, the current stable release is 5.2.13. Yes, I’m compiling 5.2.x branch of PHP, because 5.3.x is still not well adopted among hosting providers. I’ll describe how to run multiple PHP versions at some later tutorial.

Download and prepare

First few steps are practically the same as for the apache. Download the source and check md5.

md5sum php-5.2.13.tar.gz | grep cdf95cdc1ebccccce9c96653fd593dd4

Extract the archive.

tar xzf php-5.2.13.tar.gz

Go into the extracted directory.

cd php-5.2.13

Configure for compiling

./configure \
--prefix=/usr/local/php5.2.13 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/usr/local/php5.2.13/conf \
--enable-cli \
--with-pear=/usr/local/pear \
--with-openssl=/usr \
--with-iconv \
--with-curl \
--with-mysql \
--with-mysqli \
--enable-mbstring \
--enable-exif \
--with-jpeg-dir \
--with-zlib \
--with-zlib-dir \
--with-png-dir \
--with-gd \
--with-gettext \
--enable-gd-native-ttf \
--with-mhash \
--with-pspell \
--with-mcrypt \
--enable-bcmath \
--with-mime-magic \
--with-pdo-mysql \
--enable-sockets \
--enable-soap

You don’t need all of these extras, they just might be useful to you. Some of the more important ones are:

–prefix=… sets the location of the PHP installation.

–with-apxs2=… sets the location of the apxs binary of the apache. Adjust accordinally.

–with-config-file-path=… sets the location of the php.ini configuration file. I just set it so it is more clear where the .ini file will be.

–enable-cli wether or not you want to use php from the command line.

You can read more about the configuration options in the PHP manual.

http://php.net/manual/en/configure.php

Compile

make

If this error occures while doing “make” -> “/usr/bin/ld: cannot find -lltdl collect2: ld returned 1 exit status”, just install the libltdl-dev package. Should be something similar for other linux distributions.

sudo apt-get install libltdl-dev

It is a good practice to run tests and report any possible bugs by running this command. It however is not mandatory to run it.

make test

This might take a while. After tests are through, there might be a fail or two, so you can decide if you want to report those or not.

Let’s go on and install it. This command must be run as super user.

sudo make install

Configure

Now we have to copy the php.ini to appropriate directory.

sudo cp php.ini-recommended /usr/local/php5.2.13/conf/php.ini

Next, we configure apache to handle our PHP scripts.

sudo gedit /usr/local/apache2/conf/httpd.conf

Find a line which starts with AddType and add this below.

AddType application/x-httpd-php .php

Than in line which starts with DirectoryIndex add this.

index.php

Save the file and restart apache.

sudo /usr/local/apache2/bin/apachectl -k restart

Test

Go to your documents root directory. In previous tutorial we used /var/www directory for this.

In this directory create a file named test.php and put this in it:

<?php phpinfo(); ?>

Now go to http://localhost/test.php

If you see a lot of data about your PHP installation, you have succeeded.

Enjoy!

Update: This tutorial also applies for PHP 5.2.14.

./configure –prefix=/usr/local/php5.2.13 –with-apxs2=/usr/local/apache2/bin/apxs –with-config-file-path=/usr/local/php5.2.13/conf –enable-cli –with-pear=/usr/local/pear –with-openssl=/usr –with-iconv –with-curl –with-mysql –with-mysqli –enable-mbstring –enable-exif –with-jpeg-dir –with-zlib –with-zlib-dir –with-png-dir –with-gd –with-gettext –enable-gd-native-ttf –with-mhash –enable-ftp –with-pspell –with-mcrypt –enable-bcmath –with-mime-magic –with-pdo-mysql –enable-sockets –enable-soap

Setting up your local web development environment – Apache

Posted June 25th, 2010 in Tehnikalije by smottt

This is the first on in the series of tutorials on how to set up your local web development environment on linux (I’m using ubuntu). It is targeting those people, who don’t know their way around linux, but don’t want to use generic packages. It’s more fun. :)

Download and prepare

First, you go to the apache homepage. You download apache, check sha1, because it can get corrupted!

sha1sum httpd-2.2.15.tar.gz | grep ’1a751aab443ce76ede233b6d3351223e9c9516f2′

If a line is returned, the file is OK, we can proceed, else, return to step 1.

Extract the archive.

tar xzf httpd-2.2.15.tar.gz

Move into the directory of the extracted archive.

cd httpd-2.2.15.tar.gz

Configure for compiling

Next, we have to configure apache, before we compile it.

./configure –prefix=/usr/local/apache2 –enable-so –enable-mods-shared=all –enable-mod-rewrite

–prefix=/usr/local/apache2 tells apache where to install all the files needed. In this case we are installing apache to /usr/local/apache2 directory.

–enable-mods-shared=all tells apache to compile all modules as dynamic shared modules. We can then enable these modules in httpd.conf file, via the LoadModule directive.

–enable-mod-rewrite tells apache to enable mod rewrite.

Troubleshoot

If you get this error during the configuration:

mod_deflate has been requested but can not be built due to prerequisite failures

This happened because we enabled all mods by default, one of which is the mod_deflate that uses the zlib library. You can simply install its headers on ubuntu.

sudo apt-get install zlib1g-dev

The dependencies should pass.

Compile

make

Next one must be executed as super user.

sudo make install

Test it

Now, apache should be working. Let’s test it.

sudo /usr/local/apache2/bin/apachectl -k start

Go to: http://localhost

You should see a “It works!” on your screen.

But when we started apache, it threw out an error: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

Configure it

It’s time to configure it, so it won’t throw errors at us. You can use different text editor than gedit (vi, nano, mcedit … )

sudo gedit /usr/local/apache2/conf/httpd.conf

ServerAdmin -> change it to your email, just for a clean configuration file.

Uncomment ServerName directive (remove # in front of it) and change www.example.com to localhost. With this, we got rid of that error from before.

DocumentRoot -> change to directory in which you want to have your html, php etc. files.

<Directory “/usr/local/apache2/htdocs”> -> change if you changed the DocumentRoot in the previous step.

Here we must change the line AllowOverride None to AlloweOverride All if we want mod_rewrite to function properly.

Check if the syntax of the configuration file is OK.

/usr/local/apache2/bin/apachectl -t

If everything is OK, restart apache.

sudo /usr/local/apache2/bin/apachectl -k restart

You’re good to go!

Annoying Eclipse message about JavaHL on Ubuntu 10.04

Posted June 21st, 2010 in Tehnikalije by smottt

How to get rid of it?

First of, we need to install some libraries:

sudo apt-get install libsvn-java

Once this is done, we need to tell JVM (Java Virtual Machine) to include the path to our new libsvnjavahl-1.so file, when searching for extensions. We can do this in the eclipse configuration file. It is located inside the directory in which you installed Eclipse and is called eclipse.ini.

Find the line -vmargs and after it (in a new line) add this one:

-Djava.library.path=/usr/lib/jni

Restart Eclipse and you’re done.

This worked with Eclipse Galileo (3.5.2) and Ubuntu 10.04.

How to pin My Computer to Windows 7 taskbar directly

Posted February 20th, 2010 in Tehnikalije by smottt

Vedno me muči to vprašanje, ko nameščam W7. In moram vedno googlat, zato tale bolj personal note. Mogoče bo pa še komu prav prišlo. :)

1. Desni klik na mapco v taskbaru

2. Desni klik na Windows Explorer

3. Properties

4. V target polje vneseš naslednjo zadevo:

%SystemRoot%\explorer.exe /E,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

That’s it. :)

Javascript kviz/test

Posted February 14th, 2010 in Tehnikalije by smottt

Misliš, da obvladaš JavaScript? Jaz ga sigurno ne, vsaj po rezultatu sodeč (9 odgovorov napačnih). :D

http://perfectionkills.com/javascript-quiz/

Facebook digital cleanse

Posted February 10th, 2010 in Lajf by smottt

Kot je videti, je blog spet online. Tokrat na bolj samostojni (in ne pod-) domeni. Na žalost izgleda, da sem bil malo preveč površen pri backupu baze, saj so izginili vsi vnosi v letu 2009.  Nič hudega, bo pač leto 2010 nov začetek tule gor.

Ko že govorimo o novih začetkih. Po navdihu Matt Cutts-a, tudi jaz opravljam enotedenski premor od facebooka. Zato sem tudi našel malo časa med učenjem za ponovno vzpostavitev tegale bloga. Kako 1 teden ne na facebook, če si zasvojen z obiskovanjem le-tega? Preprosto.

V datoteko hosts vpišeš:

127.0.0.1 www.facebook.com

Tako ne moreš na facebook, tudi če vpišeš naslov v brskalnik. Seveda, če poganjaš svoj lastni webserver na localhost-u, se odpre localhost. Vseeno bolje kot facebook.

Upam, da mi uspe tale mini projekt izvest do konca, saj tako vem, da sem še zmožen premagati novodobno odvisnost. :)

Moj prvi letos..

Posted December 12th, 2008 in Lajf by smottt

V bistvu je prvi letošnjo zimo =) v Mačku ob Ljubljanici..

kuhano vino

Nadležna sporočila v windows vista

Posted November 21st, 2008 in Tehnikalije by smottt

Kar precej nadležnih sporočil mi je grenilo življenje v zadnjem času. Pa nikoli nekako nisem imel časa se posvetit zadevi in razrešit problem. To se je sčasoma spremenilo, prilagam pa rešitve 3 nadležnim sporočilom, ki so me pestila. Imam angleško različico Vista Ultimate (ja, je original).

1. Nadležna ikona, ki izvira iz takoimenovanega Varnostnega središča in opozarja na to, da nimam antivirusa oz. imam samodejno posodabljanje izklopljeno. Rešitev je preprosta:

  1. Control Panel
  2. Security Center
  3. V levem stolpcu se nahaja povezava “Change the way Security Center alerts me”
  4. Izberete možnost, ki ni priporočena
  5. Voila! :)

2. Druga zadeva se ne tiče toliko viste same, kakor se tiče winampa in njegove želje po skeniranju USB pogonov, ki se priklopijo v sistem. Zmeraj znova in znova bi rad preskeniral USB ključek za medijskimi datotekami. Rešitev je malce skrita, pa vendar se vse najde:

  1. Options
  2. Preferences
  3. Plug-ins
  4. Portables
  5. Izberete ponavadi zadnji plugin, ki ima v imenu USB
  6. Uninstall

3. Vistina vgrajena zadeva za spremljanje stanja sistemskega pomnilnika lahko postane precej nadležna. Še posebno, če ste ravno sredi igre in vam vista postreže s sporočilom, da vašemu sistemu primanjkuje pomnilnika. Your computer is running low on memory. Rešitev je morda bolj preprosta, kot samo dokup pomnilnika.

  1. Desni klik na Computer
  2. Properties
  3. V levem stolpcu izberete Advanced System Settings
  4. Pod jezičkom Advanced v okviru Performance izberete Settings …
  5. Spet pod jezičkom Advanced v okviru Virtual memory izberete Change …
  6. Najverjetneje bodo vse nastavitve na 0, torej je priporočljivo zadevo zvišati na količina pomnilnika * 2.5 . Torej, če imate 1GB RAM – naj bo page file velik 2.5 GB.

Torej to je bilo par nasvetov, ki čisto lahko pridejo prav marsikomu :)

Naredimo nekaj za okolje

Posted November 20th, 2008 in Zanimivosti by smottt

Kot je Jan opisal na svojem blogu:

http://ferme.si/2008/11/20/remisli-recikliraj-svoj-star-mobilnik/

je simobil pričel z akcijo re.misli:

http://www.simobil.si/sl/inside.cp2?cid=391C4F1C-B5C8-96E3-BB25-0CDD485860D1&linkid=contentVideo2

Meni se to zdi vsekakor zelo super ideja. Kolikor doma ločujemo odpadke, se trudimo biti varčni itn.. res nisem nikjer zasledil še podatka o tem, da bi telefon zanesel k operaterju. Sem sicer pomislil, ni pa to bilo nikjer izpostavljeno, tako kot je to sedaj. In se mi zdi vredno posredovat zadevo naprej. Na prvi povezavi je vse lepo opisano. Naredimo nekaj za okolje!

Faks zna biti zanimiv

Posted November 10th, 2008 in Zanimivosti by smottt

… nekaterim še posebaj :D


Foto by: Marek