Apache install on Mac OSX 10.6.8

Hi,

I’m trying to install Apache web server on Mac OSX 10.6.8. On my first attempt with ./configure, I was informed that my apr version was too old. So I downloaded apr and apr-util, and as instructed by the Apache INSTALL doc, I upacked those files and moved their directories to httpd-2.4.3/srclib/apr and httpd-2.4.3/srclib/apr-util:


~/Downloads/httpd-2.4.3/srclib$ ls
Makefile	Makefile.in	apr		apr-util

Then the Apache INSTALL doc said to run configure like this:

~/Downloads/httpd-2.4.3 $ ./configure --with-included-apr

But I got the error:

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

So I looked at the Apache installation docs here:

http://httpd.apache.org/docs/current/install.html

which say:

REQUIREMENTS


Perl-Compatible Regular Expressions Library (PCRE)
This library is required but not longer bundled with httpd. Download the source code from http://www.pcre.org, or install a Port or Package. If your build system can’t find the pcre-config script installed by the PCRE build, point to it using the --with-pcre parameter. On some platforms, you may have to install the corresponding -dev package to allow httpd to build against your installed copy of PCRE.

So I downloaded pcre and installed pcre with ./configure, make, make install, which seemed to install pcre correctly. But when I tried to run ./configure for Apache, and Apache couldn’t find pcre. So next I tried:

~/Downloads/httpd-2.4.3$ ./configure --with-included-apr --with-pcre=../pcre-8.32/pcre-config

and this time ./configure seemed to end normally.

On to make:

~/Downloads/httpd-2.4.3$  make

But make ends with pcre errors:


...
...
/Downloads/httpd-2.4.3/modules/ldap -I/Users/7stud/Downloads/httpd-2.4.3/modules/loggers -I/Users/7stud/Downloads/httpd-2.4.3/modules/lua -I/Users/7stud/Downloads/httpd-2.4.3/modules/proxy -I/Users/7stud/Downloads/httpd-2.4.3/modules/session -I/Users/7stud/Downloads/httpd-2.4.3/modules/ssl -I/Users/7stud/Downloads/httpd-2.4.3/modules/test -I/Users/7stud/Downloads/httpd-2.4.3/server -I/Users/7stud/Downloads/httpd-2.4.3/modules/arch/unix -I/Users/7stud/Downloads/httpd-2.4.3/modules/dav/main -I/Users/7stud/Downloads/httpd-2.4.3/modules/generators -I/Users/7stud/Downloads/httpd-2.4.3/modules/mappers  -prefer-non-pic -static -c util_pcre.c && touch util_pcre.lo
util_pcre.c:48:18: error: pcre.h: No such file or directory
util_pcre.c: In function 'ap_regfree':
util_pcre.c:103: error: 'pcre_free' undeclared (first use in this function)
util_pcre.c:103: error: (Each undeclared identifier is reported only once
util_pcre.c:103: error: for each function it appears in.)
util_pcre.c: In function 'ap_regcomp':
util_pcre.c:129: error: 'PCRE_CASELESS' undeclared (first use in this function)
util_pcre.c:131: error: 'PCRE_MULTILINE' undeclared (first use in this function)
util_pcre.c:133: error: 'PCRE_DOTALL' undeclared (first use in this function)
util_pcre.c:136: warning: implicit declaration of function 'pcre_compile'
util_pcre.c:136: warning: assignment makes pointer from integer without a cast
util_pcre.c:142: warning: implicit declaration of function 'pcre_fullinfo'
util_pcre.c:142: error: expected ')' before 'pcre'
util_pcre.c:142: warning: type defaults to 'int' in declaration of 'type name'
util_pcre.c:142: warning: cast from pointer to integer of different size
util_pcre.c:143: error: 'PCRE_INFO_CAPTURECOUNT' undeclared (first use in this function)
util_pcre.c: In function 'ap_regexec_len':
util_pcre.c:180: error: 'PCRE_NOTBOL' undeclared (first use in this function)
util_pcre.c:182: error: 'PCRE_NOTEOL' undeclared (first use in this function)
util_pcre.c:198: warning: implicit declaration of function 'pcre_exec'
util_pcre.c:198: error: expected ')' before 'pcre'
util_pcre.c:198: warning: type defaults to 'int' in declaration of 'type name'
util_pcre.c:198: warning: cast from pointer to integer of different size
util_pcre.c:221: error: 'PCRE_ERROR_NOMATCH' undeclared (first use in this function)
util_pcre.c:223: error: 'PCRE_ERROR_NULL' undeclared (first use in this function)
util_pcre.c:225: error: 'PCRE_ERROR_BADOPTION' undeclared (first use in this function)
util_pcre.c:227: error: 'PCRE_ERROR_BADMAGIC' undeclared (first use in this function)
util_pcre.c:229: error: 'PCRE_ERROR_UNKNOWN_NODE' undeclared (first use in this function)
util_pcre.c:231: error: 'PCRE_ERROR_NOMEMORY' undeclared (first use in this function)
make[2]: *** [util_pcre.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1




Any ideas what went wrong or what I should try next? The Apache install web page says:

On some platforms, you may have to install the corresponding -dev package to allow httpd to build against your installed copy of PCRE.

But I can’t find any information on where “the corresponding -dev package” can be downloaded from.

Thanks.

First, I think it is already installed – you just need to configure it. Second, why are you building from source in2013? Just use brew, or better yet use something like vagrant and don’t have apache running on your pc.

Second, why are you building from source in 2013?

I’m just want to set up a local development environment. I’ve already installed mysql. What do you suggest?

In order of preference:

  1. Use Vagrant (http://vagrantup.com), have infinitely local environments with VMs while being able to edit using whatever you want.
  2. Use built-in apache install, you should be able to configure it in the settings dialogs then configure it in the normal text files.

Because I was getting a pcre error while trying to install Apache, I thought I’d investigate pcre a little more. Supposedly pcre installs into /usr/local/bin by default, but I couldn’t find it there. Hmmm…I looked back over the Terminal output produced while I was trying to install Apache, and I discovered that I did ./configure on pcre, but I forgot to follow that up with make, then make install.

To correct that, I cd’ed into ~/Downloads/pcre-8.32, and then did:

./configure
make
sudo make install  (I got a permission denied error without sudo)

Then I cd’ed into ~/Downloads/httpd-2.4.3 and did:

./configure --with-included-apr  

…and that seemed to go well (without having to point to pcre-config). So I did:

make

…and this time there was no pcre error. I followed that up with:

sudo make install

and everything seemed to install fine. So I started up apache with:

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

…and that good ole ever present apache error message greeted me:

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 7studs-computer.local. Set the ‘ServerName’ directive globally to suppress this message

No worries. I opened a browser and entered http://localhost/ in the address bar, and I was greeted by:

It works!

For people that aren’t error prone, it is pretty easy to install apache. If I can’t get apache configured and working as I want, I’ll try Vagrant. Thanks for your help.

So much for vagrant:


$ vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
$ vagrant init lucid32
$ vagrant up

[default] Importing base box 'lucid32'...
[default] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.2.6

That example is from the first page of the getting started docs:

http://docs.vagrantup.com/v1/docs/getting-started/index.html

Mac OSX 10.6.8

Also, vagrant is way more difficult to setup than installing from source. In fact, as far as I can tell vagrant is so difficult to configure that unless you can copy someone else’s config files, you will have to spend a few months learning how to write the config files yourself.

I don’t know, the defaults have always worked out of the box for me insofar as “stand up a working linux vm”; the vm additions thing is par for the course but that VM is probably working, try vagrant ssh.

The whole advantage to vagrant is that when you hose that setup, you just delete the VM and re-provision. When you hose your machine’s configuration, especially in OSX, you can spend lots of time either rebuilding or repaving.

I understand the advantages to using vagrant, I just don’t think it’s possible to setup apache, php, and mysql without spending a few months figuring out how to ‘provision’ the ‘base box’ with those add ons. I’m really surprised vagrant doesn’t provide a base box for LAMP.

but that VM is probably working,

Still, vagrant was unable to install a basic ‘box’ without error on Mac OSX. That’s not good advertising for vagrant. And I was unable to ascertain how to ‘update the guest additions and repackage’.

I found a vagrant LAMP setup that I could copy here:

With regard to the steps for installing virtualbox and vagrant, previously I followed the installation instructions on the vagrant website for installing virtualbox and vagrant. Vagrant recommends that you not use ‘gems’ to install them. In any case, I skipped those steps.

I already had git installed, and after researching how to ‘clone a repo’, I issued the following command in my home directory:

~$ git clone https://github.com/ymainier/vagrant-lamp

That created a directory called vagrant-lamp and copied all the files into it. Then I just followed the rest of the directions:

  1. Go to the repo and launch the box

cd vagrant-lamp
vagrant up

That produced a fair amount of output with some errors/warnings mixed in:

[default] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.2.6


stdin: is not a tty


[2013-02-26T07:42:29+01:00] WARN: Missing gem ‘mysql’
[2013-02-26T07:42:29+01:00] INFO: Processing execute[apt-get update] action run (apt::default line 20)
[2013-02-26T07:43:06+01:00] INFO: execute[apt-get update] ran successfully
[2013-02-26T07:43:06+01:00] INFO: Processing package[mysql-devel] action install (mysql::client line 20)
[2013-02-26T07:43:47+01:00] INFO: Processing package[mysql-client] action install (mysql::client line 43)
[2013-02-26T07:44:55+01:00] INFO: Processing package[build-essential] action install (mysql::client line 60)
[2013-02-26T07:46:05+01:00] INFO: Processing gem_package[mysql] action install (mysql::client line 66)
[2013-02-26T07:46:21+01:00] WARN: Could not find previously defined grants.sql resource

Then the output concluded with no obvious signs of distress, so I forged ahead:

  1. Add this line to your /etc/hosts (or windows equivalent) 127.0.0.1 www.dev-site.com dev-site.com dev.dev-site-static.com

That’s it, the file in [repo]/public/ are served here : http://www.dev-site.com:8080/

Then I entered the following url in my browser:

http://www.dev-site.com:8080/

and I got:

Here we are - 2013-02-25T23:37:32-08:00

As the instructions say, files are served out of the vagrant-lamp/public direcdtory, so you can put files in there and access them with urls like:

http://www.dev-site.com:8080/test.html
http://www.dev-site.com:8080/test.php

I also tested if mysql would work–I doubted it would because of the “missing ‘mysql’ warning”, but using the username ‘myadmin’ and the password ‘myadmin’ (as specified in the phpmyadmin tip), I got this script to work:

<?php

$server = 'localhost';
#$database = 'my_db';
$username = 'myadmin';
$password = 'myadmin';

$conn = mysql_connect($server, $username, $password);

if (!$conn) {
    echo "Could not connect to server\
";
    trigger_error(mysql_error(), E_USER_ERROR);
}
else {
    echo "<p>Connection established</p>";
}

echo "<p>" . mysql_get_server_info() . "</p>";

mysql_close();

?>


–output:–
Connection established

5.1.67-0ubuntu0.10.04.1-log

Now if I could figure out how to setup a cgi directory, I would have a general purpose development environment.