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:

Comments on running webservers at home – Part 1

I like to experiment all kind of computer technologies especially server applications. I am not one of those who is satisfied with just making a website and putting it in somewhere. I like the full control of the server because I like to try different combination of applications for performance tuning. For example, I doubt regular web hosting company allows you to host the entire system on a ram disk with a reasonable price tag. That’s why I choose to host a server at home. That’s a lot cheaper, plus I have the full control. However, running server application may generate lots of upstream traffic. That’s why most internet server providers (such as Charter) do not allow their customers to run any server related applications using their internet connection service. They do it by blocking most service related common ports, e.g., 80 (HTTP), 21 (FTP), 22 (SSH) etc. So there is really nothing you can do other than hosting your applications on different ports.

Two years ago, I started hosting all of my websites using my own computers. I found a number of benefits.

Benefits of hosting websites at home

1. It saves me tons of money.

I was paying $72/year per domain for web hosting. Since I have more than ten domains, the total running costs per year is pretty high. This amount is really nothing comparing to the cost of the electricity.

Monthly cost for web hosting:

$72 per domain/yr * 10 domains / 12 months
= $60 per domain / month

My monthly electricity cost at home, which includes everything such as running 10 non-gaming computers, washer, dryer, lighting etc:

$80 / month

I haven’t tried measuring the exact energy but you can imagine the electricity used by computers should be under $10 / month.

2. It is fun (and environmental friendly too).

I have few stone-age computers including a Pentium II laptop, a Mac G3 (speed wise similar to Pentium II), a Pentium M Celeron laptop etc. I integrated them to a web server farm (web clusters). Since running a web server does not require a lot of CPU power, they are doing okay for hosting low-traffic websites. Also, it is cool to show off my friends the global data center that I build for my websites.

3. Your data is secured!

Have you ever heard of any bank host their web sites on web hosting? No matter what type of encryption you use for your web applications, you still need to process the raw, original, and unencrypted data on the server side at one point. Processing confidential information on a shared server is like talking your secrets in a study room in a public library. You think you are in an isolated environment, but you can be surveillanced, it’s very simple and easy.

Here is an example:
Supposes I have a web application which accepts the confidential information from my users, and all traffics are encrypted. After the confidential information is decrypted on the server-side, my web application processes the raw information and do further things.

Let’s say the server environment is Apache + PHP + MySQL, the most popular combination of web application environment. Since they are all open-source, it is very easy to modify the source codes and log every single thing into a file, including the raw, original, unencrypted data processed by my web application.

You may think this may require lots of work and it will never happen on you. What if your competitor wants your confidential information? It doesn’t cost much to hire someone to do it.

Sounds scary?

More scary things come along. Shared web hosting (hosting multiple domains on one single server) always come with lots of trouble that many people are ignored. In theory, every website on a shared hosting lives in a virtual, independent environment, think about it as a virtual machine like VMWare or Hyper-V. Practically, it is not easy to set up such environment (e.g., FreeBSD Jail) and many web hosting companies choose to go with a less difficult path, because customers will not realize it anyway. Now here is the interesting part, supposes my domain and your domain are hosted on the same server. I can access the resource at the operating system level first (which will required some hacking), then access your file after that. Now I have access your source code and I can do whatever I want.

The most secure place in the world is the place that can be accessed by you, and no body else, i.e., your home, or any place you have full control

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:

Starting MySQL.. ERROR! The server quit without updating PID file

This article is a bit outdated. Please visit the following article instead. It includes a better discussion on how to solve this problem using different scenarios:

Thanks.

–Derrick

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:

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:

Updated: What technologies (or toys) I am playing recently?

Recently I am playing the following technologies (toys):

  1. Tornado Web – Not sure how long will Apache + PHP last. Time to learn Python.
  2. Tokyo Cabinet & Tyrant – Another one of my long term plans to step away from SQL.
  3. PHP API for Tokyo Tyrant — I decide to write my own because I cannot find a good one.
  4. Moving my development platform from Windows to FreeBSD. My servers have been already on FreeBSD for many years. I think now is a good time to move my desktop systems to FreeBSD as well. Why not Linux? Oh Well…
  5. LUA – I may pick up Lua if time is permitted.

Looks like I will have a busy time other than shoveling the snow this Winter.

–Derrick

Our sponsors:

Does the most popular imply the best?

Today, I had a discussion with my co-worker on the best languages for web applications. While I argued that Perl, and Ruby performs better than PHP, my co-worker had an opposite opinion. He believed that PHP is the best language overall because it is widely used. It brings me to think of a question, does the most popular imply the best?

Let’s answer this question by examples:

Category Most Popular The Best Why The Best?
OS (Desktop) Windows OS X User friendly, secure, stability, and performance.
OS (Server) Linux, Windows Server FreeBSD Fast, stable, secure, simple design, and centralize management.
Browsers Internet Explorer, Firefox Safari Fast, secure, stable
Programming languages (Desktop/GUI) C#, Java C, C++ Fast, secure
Programming languages (Web/Server) PHP, ASP Ruby, Python, Perl Fast, fewer lines of code.
Database MySQL, Oracle Berkeley DB, Tokyo Cabinet Fast I/O, simple design, smaller size of the database file.
Software company to work for Microsoft Start-up Rewards, opportunity to grow

I think there are several reasons why the most popular things are not the best.

1. Most popular thing is always backed by the best marketing strategies. Marketing strategies is simply a way to let people know about the product and convince them to use it. It has nothing to do with the quality of the product at all.

Example: The ads of Internet Explorer 8 look very attractive. Is it the most secure browser ever?

2. Most people are followers. They are not good in selecting good products from bad products(i.e., filtering the noise). They believe that the choice form most people (most popular) should be the best one. This is similar to election. The choice of most people is more likely to be better.

Example: Is MySQL really the best database?

3. Different people have different preferences. So a popular product must have the general taste. For example, an extremely hot and spicy food may be better to the body, but it is not as popular as a mild one, because the number of people that can take extremely hot and spicy food is smaller.

Example: Linux is very easy to configure comparing to FreeBSD (GUI vs command line) from the end-user perspective, but it is less powerful and stable overall.

Conclusions:

Think twice before your move.

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: