Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.

This post is about FreeBSD, however the idea is about the same for other Unix systems.

While I tried to install memcached, the system complained with this message:

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

This problem is caused by missing couple variables at the shell level: PHP_AUTOCONF, PHP_AUTOHEADER. It is very easy to solve this problem:

1. First, make sure that Autoconf is installed in your system:

#pkg_info | grep autoconf
autoconf-2.68       Automatically configure source code on many Un*x platforms
autoconf-wrapper-20071109 Wrapper script for GNU autoconf

If autoconf is not available, install it from here:

cd /usr/ports/devel/autoconf268
make install clean

2. Now, we need to set couple variables. This step is very important because you can’t set the variable using sudo export x=y. First, switch to root

sudo su

3. Find out where is autoconf (The location in FreeBSD and Linux are different)

which autoconf

4. Set the autoconf, in my case, it is /usr/local/bin/autoconf

export PHP_AUTOCONF=/usr/local/bin/autoconf

5. Do the same thing for autoheader:

which autoheader
export PHP_AUTOHEADER=/usr/local/bin/autoheader

That’s it. Now try to install your software again and the error message should be gone.

–Derrick

Our sponsors:

fetch: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ngx-fancyindex-0.2.2.tar.bz2: File unavailable (e.g., file not found, no access)

Today I tried to run the upgrade my nginx on my FreeBSD box, and I received the following message:

===>  Vulnerability check disabled, database not found
===>  License accepted by the user
===>  Found saved configuration for nginx-0.7.66
=> ngx-fancyindex-0.2.2.tar.bz2 doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://connectical.com/attachments/download/26/.
fetch: http://connectical.com/attachments/download/26/ngx-fancyindex-0.2.2.tar.bz2: Not Found
=> Attempting to fetch from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/.
fetch: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ngx-fancyindex-0.2.2.tar.bz2: File unavailable (e.g., file not found, no access)
=> Couldn't fetch it - please try to retrieve this
=> port manually into /usr/ports/distfiles/ and try again.

Obviously, the FreeBSD box could not download the file. To fix this problem, simply run the following commands:

cd /usr/ports/distfiles/
sudo wget http://files.connectical.com/gentoo/ngx-fancyindex-0.2.2.tar.bz2

This will allow FreeBSD to skip downloading the file from a wrong URL. Now, go back to the nginx port:

cd /usr/ports/www/nginx

and try to install nginx again:

sudo make install clean

Our sponsors:

Weird PHP Error after FreeBSD port upgrade (PHP Warning: PHP Startup: Unable to load dynamic library)

Today I upgraded the port on my FreeBSD box using portmaster tools:

portmaster -Dai

After that, I found that the PHP gave the following weird error:

php -v

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/memcached.so' - /usr/local/lib/php/20060613/memcached.so: Undefined symbol " php_session_create_id" in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613/mysql.so' - Cannot open "/usr/local/lib/php/20060613/mysql.so" in Unknown on line 0

PHP 5.2.12 with Suhosin-Patch 0.9.7 (cli) (built: Apr  6 2010 15:50:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

In order to solve this problem, you will need to rebuild the port. In my situation, I need to clean up, uninstall, rebuild and install the affected ports:

Memcached: /usr/ports/databases/pecl-memcached

MySQL: /usr/ports/databases/php5-mysql

——————————————————————————————
Update on 2010.04.13:
Your situation may be different from mine. The tricky part is to rebuild the port at the right location. For example, if your PHP complains about pdo.so, you can rebuild the port at the affected location:

/usr/ports/database/php5-pdo

If you are not sure where does the port locate, you can search it on Google or find it with the following command:

find /usr/ports/ -name "*pdo*"

——————————————————————————————

In each affected port, run the following commands:

make clean
make deinstall
make
make install && sync
make clean

After that, restart the PHP by restarting Apache:

sudo apachectl restart

and run the php command again:

php -v

The error should be gone:

PHP 5.2.12 with Suhosin-Patch 0.9.7 (cli) (built: Apr  6 2010 15:50:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Our sponsors:

[Solved]Shared object “libtokyocabinet.so.8” not found

After upgrading the Tokyo Cabinet on my FreeBSD 8 system, I could not start Tokyo Cabinet:

ttserver
/libexec/ld-elf.so.1: Shared object "libtokyocabinet.so.8" not found, required by "ttserver"

After some investigations, I solved the problem.

1. First, go to the library directory. In my case, it is /usr/local/lib.

cd /usr/local/lib

2. Display all the libtokyocabinet.so:

ls libtokyocabinet.so*

which returns:

lrwxr-xr-x  1 root  wheel    24B Jan  9 20:17 libtokyocabinet.so -> libtokyocabinet.so.9.4.0
lrwxr-xr-x  1 root  wheel    24B Jan  9 20:17 libtokyocabinet.so.9 -> libtokyocabinet.so.9.4.0
-rwxr-xr-x  1 root  wheel   778K Jan  9 20:17 libtokyocabinet.so.9.4.0

So the solution to this problem is pretty obvious. The application is looking for libtokyocabinet.so.8 but a newer version of this library is available. A soft-link is good enough to solve this problem:

sudo ln -s libtokyocabinet.so libtokyocabinet.so.8

Here is the expected result:

ls libtokyocabinet.so*
lrwxr-xr-x  1 root  wheel    24B Jan  9 20:17 libtokyocabinet.so -> libtokyocabinet.so.9.4.0
lrwxr-xr-x  1 root  wheel    18B Jan  9 20:26 libtokyocabinet.so.8 -> libtokyocabinet.so
lrwxr-xr-x  1 root  wheel    24B Jan  9 20:17 libtokyocabinet.so.9 -> libtokyocabinet.so.9.4.0
-rwxr-xr-x  1 root  wheel   778K Jan  9 20:17 libtokyocabinet.so.9.4.0

Now I run the Tokyo Cabinet again, and the problem is gone!

ttserver
2010-01-09T20:26:12-06:00       SYSTEM  --------- logging started [13244] --------
2010-01-09T20:26:12-06:00       SYSTEM  server configuration: host=(any) port=1978
2010-01-09T20:26:12-06:00       SYSTEM  opening the database: *
2010-01-09T20:26:12-06:00       SYSTEM  service started: 13244
2010-01-09T20:26:12-06:00       INFO    timer thread 1 started
2010-01-09T20:26:12-06:00       INFO    worker thread 1 started
2010-01-09T20:26:12-06:00       INFO    worker thread 2 started
2010-01-09T20:26:12-06:00       INFO    worker thread 3 started
2010-01-09T20:26:12-06:00       INFO    worker thread 4 started
2010-01-09T20:26:12-06:00       INFO    worker thread 5 started
2010-01-09T20:26:12-06:00       INFO    worker thread 6 started
2010-01-09T20:26:12-06:00       INFO    worker thread 7 started
2010-01-09T20:26:12-06:00       INFO    worker thread 8 started
2010-01-09T20:26:12-06:00       SYSTEM  listening started

Our sponsors:

[Solved]Fedora Linux Repository Error ([Errno 14] PYCURL ERROR 6)

I was having trouble to update my Fedora Linux system by running sudo yum update.

sudo yum update
Loaded plugins: presto, refresh-packagekit
Error: Cannot retrieve repository metadata (repomd.xml) for repository: fedora.
Please verify its path and try again

sometimes I see different sets of error:

http://download.fedoraproject.org/pu...ta/repomd.xml: [Errno 14] PYCURL ERROR 6 - ""

or

http://download.fedoraproject.org/pu...ta/repomd.xml: [Errno 14] PYCURL ERROR 7 - ""

After searching these error messages on Google, I found tons of the workaround methods. Unfortunately, none of them works! Finally, I came up a way to fix this problem.

The reason why you see this error message because your system could not connect to the main Fedora server(At the time of writing this blog, fedoraproject.org has been downed for at least 4 days.), so that your computer is not redirected to any Fedora mirror servers. The easiest way to fix this problem is by specifying a mirror server in your yum repository configuration file.

First, let’s find a mirror that is closed to your location:

Fedora Mirror (Fedoraproject.org)

or

Google Cache

If you have any trouble to access the information, here is a copy of the list:

North America

ftp://limestone.uoregon.edu/fedora/extras
http://limestone.uoregon.edu/fedora/extras
ftp://fedora.bu.edu/extras
http://mirrors.kernel.org/fedora/extras
ftp://mirrors.kernel.org/fedora/extras
rsync://mirrors.kernel.org/fedora/extras
ftp://ftp.muug.mb.ca/pub/fedora/linux/extras/
http://www.muug.mb.ca/pub/fedora/linux/extras/
rsync://rsync.muug.mb.ca/fedora-linux-extras/
http://mirror.hiwaay.net/redhat/fedora/linux/extras/
ftp://mirror.hiwaay.net/redhat/fedora/linux/extras/
rsync://mirror.hiwaay.net/fedora-linux-extras/
ftp://mirror.phy.olemiss.edu/fedora/extras/
http://mirror.phy.olemiss.edu/mirror/fedora/extras/
http://fedora.mirrors.tds.net/pub/fedora-core-extras
ftp://fedora.mirrors.tds.net/pub/fedora-core-extras
rsync://fedora.mirrors.tds.net/fedora-core-extras
http://mirror.cpsc.ucalgary.ca/mirror/fedora/linux/extras/
ftp://mirror.cpsc.ucalgary.ca/mirror/fedora/linux/extras/
rsync://mirror.cpsc.ucalgary.ca/fedora-linux-extras/
http://www.gtlib.gatech.edu/pub/fedora.redhat/linux/extras/
ftp://ftp.gtlib.gatech.edu/pub/fedora.redhat/linux/extras/
rsync://rsync.gtlib.gatech.edu/fedora-linux-extras/

Europe

http://sunsite.mff.cuni.cz/pub/fedora-extras/
ftp://sunsite.mff.cuni.cz/pub/fedora-extras/
rsync://sunsite.mff.cuni.cz/fedora/extras/
ftp://alviss.et.tudelft.nl/pub/fedora
http://ftp.lug.ro/fedora/linux/extras/
ftp://ftp.lug.ro/fedora/linux/extras/
http://ftp.uni-bayreuth.de/linux/fedora/linux/extras
ftp://ftp.uni-bayreuth.de/pub/linux/fedora/linux/extras
rsync://rsync.uni-bayreuth.de/fedora-linux-extras
http://ftp1.skynet.cz/pub/linux/fedora/extras/
ftp://ftp1.skynet.cz/pub/linux/fedora/extras/
ftp://ftp.tu-chemnitz.de/pub/linux/fedora-core-extras/
http://wftp.tu-chemnitz.de/pub/linux/fedora-core-extras/
ftp://ftp.chl.chalmers.se/pub/fedora/linux/extras/
ftp://ftp.udl.es/pub/fedora/linux/extras/
http://ftp.udl.es/pub/fedora/linux/extras/
rsync://ftp.udl.es/pub/fedora/linux/extras/
ftp://gd.tuwien.ac.at/opsys/linux/fedora/extras/
http://gd.tuwien.ac.at/opsys/linux/fedora/extras/
rsync://gd.tuwien.ac.at/opsys/linux/fedora/extras/
http://fr.rpmfind.net/linux/fedora/extras/
ftp://fr.rpmfind.net/linux/fedora/extras/
rsync://fr.rpmfind.net/linux/fedora/extras/
http://mirror.etf.bg.ac.yu/fedora/linux/extras
ftp://mirror.etf.bg.ac.yu/fedora/linux/extras
rsync://mirror.etf.bg.ac.yu/fedora/linux/extras

http://mirror2.etf.bg.ac.yu/fedora/linux/extras
ftp://mirror2.etf.bg.ac.yu/fedora/linux/extras
rsync://mirror2.etf.bg.ac.yu/fedora/linux/extras
ftp://klid.dk/fedora/linux/extras/
http://klid.dk/homeftp/fedora/linux/extras/

Russia

http://ftp.rhd.ru/pub/fedora/linux/extras/
ftp://ftp.rhd.ru/pub/fedora/linux/extras/
ftp://ftp.chg.ru/pub/Linux/fedora/linux/extras/
http://ftp.chg.ru/pub/Linux/fedora/linux/extras/
rsync://ftp.chg.ru/fedora/linux/extras/

Taiwan, Asia

http://ftp.isu.edu.tw/pub/Linux/Fedora/linux/extras/
ftp://ftp.isu.edu.tw/pub/Linux/Fedora/linux/extras/

Australia

http://planetmirror.com/pub/fedora/linux/extras/
ftp://ftp.planetmirror.com/pub/fedora/linux/extras/
rsync://rsync.planetmirror.com/fedora/linux/extras/
http://mirror.pacific.net.au/linux/fedora/linux/extras/
ftp://mirror.pacific.net.au/linux/fedora/linux/extras/

In my example, I will use the following parameters:
Mirror: http://fedora.mirrors.tds.net/
Version($releasever): 12
Architecture($basearch): x86_64

If you are not sure how to determine the version and the architecture, you can type:

cat /etc/redhat-release && uname -a

It should say something like:

Fedora release 12 (Constantine)
Linux 2.6.31.6-145.fc12.x86_64 #1 SMP Sat Nov 21 15:57:45 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

Next, run the following:

sudo nano /etc/yum.repos.d/fedora.repo

and edit the following from:

[fedora]
...
baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/

[fedora-source]
baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/

to:

[fedora]
...
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
baseurl=http://fedora.mirrors.tds.net/pub/fedora/releases/12/Everything/x86_64/os/

[fedora-source]
...
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
baseurl=http://fedora.mirrors.tds.net/pub/fedora/releases/12/Everything/source/SRPMS/

Now, let’s do something similar to another file:

sudo nano /etc/yum.repos.d/fedora-updates.repo
[updates]
...
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever/$basearch/
baseurl=http://fedora.mirrors.tds.net/pub/fedora/updates/12/x86_64/

[updates-source]
...
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever/SRPMS/
baseurl=http://fedora.mirrors.tds.net/pub/fedora/updates/12/SRPMS/

Now, try to run the update again by:

sudo yum clean all
sudo yum update

It should work now. Enjoy your update!

Thoughts:

The reason why this problem happens because the Fedora server is down for at least 4 days(From 12/31 to 1/4, 2010, for four days.), and the problem is not fixed! Yes I know it is in the holiday, but it is not an excuse.

One reason why my company prefers using Fedora Linux is that it has a long history and it is backed by Red Hat. Now the quality of their service seems going down. (Their servers have gone down multiple times in December, and each down time lasted longer than a day.) I think it is probably about time for us to move to a different Linux distribution, such as Ubuntu.

Fedoraproject.org has downed.

FYI, I personally use FreeBSD for all of my server applications.

–Derrick

Our sponsors:

Installing from FreeBSD ports without prompt

When I configure my FreeBSD box, I like to install the applications from the ports instead of using pkg_add, because I can customize the configurations and optimize the compile process for my systems. However, if an application comes with lots of dependencies, it will take me a long time because I will need to sit in front of the computer and choose the options for each applications. It is a very time-consuming process.

So, how to make the process automatic? Here is the trick:

To use the default options, simply do:

sudo make -DBATCH install clean

Or view all of the options at the beginning:

sudo make config-recursive
sudo make install clean

Hope these two tricks will save you few hours.

–Derrick

Our sponsors:

“mount_smbfs: kldload(smbfs): Operation not permitted” SOLVED!!!!

When I tried to mount a windows share from FreeBSD:

sudo mount_smbfs -I WindowsBoxIPaddress //username@WindowsBoxIPaddress/WindowsShare /mnt

I always got this error:

mount_smbfs: kldload(smbfs): Operation not permitted

After searching this error message on Google, I found that all suggested solutions were related to running this command using sudo, which I already did. Today morning, I tried a different way and the problem is solved!

In /etc/rc.conf, I disable the following configurations:

#kern_securelevel="1"
#kern_securelevel_enable="YES"

After I rebooted the machine, and mounted the Windows share again, it worked! That’s simple, isn’t it?

Note: These two lines are for making the FreeBSD box more secure, and I highly recommend to put these in a public accessible server. I don’t think it is safe to make a public accessible server to access to any Windows box because there are not many protections you can do on a Windows box. In case the public server got hacked, the connections to other internal servers should be blocked, i.e., other internal servers can always access the public server, but not vice versa.

–Derrick

Our sponsors:

Performance Benchmark: FreeBSD vs Ubuntu vs OS X, which one is better?

If you cannot decide whether you should go with FreeBSD or Ubuntu (or Linux), check out this article: FreeBSD or Linux in 6 Simple Questions

Recently I am working on building a web farm which is formed by three ancient time computers (The sum of their ages is older than me). Therefore, I need to pick an operating system to make them running efficient enough. Basically here are my criterias:

  • It must be secure. (Sorry, Microsoft Windows, I tried installing Windows Server and the OS got infected by virus in 20 minutes after connecting to Web.)
  • It must be stable and require no reboot. (I have a very good experience with FreeBSD. My longest record of uptime is 6 months so far.)
  • It must be efficient and effective on performance.

So after trying different operating systems, I ran down to three choices: FreeBSD 8, Ubuntu 10 and OS X.

And I finally go with FreeBSD 8. Before I talked about why I kick the Ubuntu and OS X away, let me discuss what methodology I used.

First Test: Extreme Computation

I write a program to calculate the value of pi using Monte-Carlo simulations. For those who are not familiar with this simulation method, basically it try to repeat a calculation for n times and try to determine the value of pi based on the results of calculations. This calculation will use all available CPU resources.

Here is the result from a computer: Pentium II 400MHz + 160MB

  • FreeBSD 8.1 ~ 5 seconds
  • FreeBSD 4.11~ 10 seconds
  • Ubuntu 10.04 ~ 8 seconds
  • OS X 10.3.9 ~ 11 seconds

The result is very obvious, FreeBSD 8.1 is the best candidate in this test. However, the result of my program only gives a very small portion of the picture. So I decide to run another test:

Second Test: Apache Benchmark

No test is better than the real world test drive. Since my primary purpose is for web server, so I decide to test the performance on how Apache perform on different operating systems. My test is pretty simple, I basically ask the Apache Benchmark client to download a page from the test server. The page does three things:

  1. Display a picture
  2. Insert a record into MySQL database
  3. Retrieve the current count from MySQL database

This way I can test the overall performance on how the system handles the file I/O, database I/O and computations.

So the result is pretty interesting (1000 total requests and 100 concurrent requests)

  • FreeBSD 8.1 ~ 200 requests/sec, no failure
  • FreeBSD 4.11~ 150 requests/sec, approx. 20% failure.
  • Ubuntu 10.04 ~ 180 requests/sec, no failure
  • OS X 10.3.9 ~ 160 requests/sec, approx. 50% failure.

I am not surprised with the result because FreeBSD 8 really does a very good job in kernel optimization. Since kernel is the heart(or brain) of all computations, an OS with good kernel is expected to give good results always.

So, I finally pick FreeBSD 8 as the core OS of my web farm, and I am loving it.

Our sponsors:

Installing Apache, PHP, MySQL and MemCached on FreeBSD

This is my note on how to to install Apache, PHP, MySQL and MemCached on a FreeBSD 7 Box.

1. MySQL

Go to the mysql52-server port directory by typing the command:

cd /usr/ports/databases/mysql51-server

Build the port by typing:

make BUILD_OPTIMIZED=yes BUILD_STATIC=yes

Using these two options will speed up the execution time.

Install the port by typing:

make install clean

Open the configuration file: ”’/etc/rc.conf”’ and add the following at the end of the file:

mysql_enable="YES"

Copy the default configuration file:

cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf

Start mysql manually to avoid having to reboot now by typing:

/usr/local/etc/rc.d/mysql-server start

Setup the a master password for root user:

/usr/local/bin/mysqladmin -u root password 'new-password'

2. Apache

Go to the apache22 port directory by typing the command:

cd /usr/ports/www/apache22

Install the port by typing:

make install clean

Open the configuration file: ”’/etc/rc.conf”’ and add the following at the end of the file:

apache22_enable="YES"

Add the following in: ”’/boot/loader.conf”’

accf_http_load=YES

3. PHP

3.1 PHP5

Go to the php5 port directory by typing the command:

cd /usr/ports/lang/php5

Install the port by typing:

make install clean

Make sure the APACHE (Build Apache module) option is checked.

3.2 PHP5 Extentions

Note: If you need to install PDF-Lite, please do the following:

fetch ftp://ftp.swin.edu.au/gentoo/distfiles/PDFlib-Lite-7.0.2.tar.gz
sudo mv PDFlib-Lite-7.0.2.tar.gz /usr/ports/distfiles/

Go to the php5 extensions port directory by typing the command:

cd /usr/ports/lang/php5-extensions

Make sure sockets is selected.

Install the port by typing:

make install clean

Install the php.ini file:

cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

3.3 Enable PHP in Apache

3.3.1 httpd.conf

Edit the Apache configuration file ”’/usr/local/etc/apache22/httpd.conf”’ and add the following lines to the end of the file:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Replace this line:

DirectoryIndex index.html

by the following:

DirectoryIndex index.php index.html
3.3.2 httpd-languages.conf

Edit the Languageconfiguration file ”’/usr/local/etc/apache22/extra/httpd-languages.conf”’ and add the following lines to the end of the file:

AddDefaultCharset On

Startup the Apache:

/usr/local/etc/rc.d/apache22 start

4. MEMCached

Go to the pecl-memcache port directory by typing the command:

cd /usr/ports/databases/pecl-memcache

Install the port by typing:

make install clean

Go to the memcached port directory by typing the command:

cd /usr/ports/databases/memcached

Install the port by typing:

make install clean

Open the configuration file: ”’/etc/rc.conf”’ and add the following at the end of the file:

memcached_enable="YES"

To start using MemCached without rebooting, type:

/usr/local/bin/memcached -d -u nobody

–Derrick

Our sponsors: