Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to serve pages on Mac OS X using default Apache Web Server

Tags:

macos

I have enabled the Web Server on my Mac OS X (10.5.6) by going to the System Preferences -> Internet & Network -> Sharing and clicking on the Web Server option. It gives me the IP address of my system as the Web Server, but even after clicking on it, it does not show the page, but gives an error: Failed to Connect

Any help on this would be wonderful.

I have tried with MAMP, but there, I am unable to get my own PHP pages to be displayed.

Starting and/or stopping the web server from the command line, gives me the following:

dyld: Symbol not found: _apr_socket_sendfile
  Referenced from: /usr/sbin/httpd
  Expected in: /usr/lib/libapr-1.0.dylib

Trace/BPT trap

The files on my box are:

~ $ ls -lrt /usr/lib/libapr*
-rwxr-xr-x  1 root  wheel  578640 Sep 23  2007 /usr/lib/libapr-1.0.2.7.dylib
-rwxr-xr-x  1 root  wheel  393696 Sep 23  2007 /usr/lib/libaprutil-1.0.2.7.dylib
-rwxrwxr-x  1 root  admin  569544 Oct 27 10:44 /usr/lib/libaprutil-1.0.2.12.dylib
-rwxrwxr-x  1 root  admin  835824 Oct 27 10:44 /usr/lib/libapr-1.0.2.12.dylib
lrwxr-xr-x  1 root  admin      25 Jan  4 22:28 /usr/lib/libaprutil-1.dylib -> libaprutil-1.0.2.12.dylib
lrwxr-xr-x  1 root  admin      25 Jan  4 22:28 /usr/lib/libaprutil-1.0.dylib -> libaprutil-1.0.2.12.dylib
lrwxr-xr-x  1 root  admin      21 Jan  4 22:28 /usr/lib/libapr-1.dylib -> libapr-1.0.2.12.dylib
lrwxr-xr-x  1 root  admin      21 Jan  4 22:28 /usr/lib/libapr-1.0.dylib -> libapr-1.0.2.12.dylib

The MD5 values are:

~ $ openssl md5 /usr/sbin/httpd /usr/lib/libapr-1.0.dylib 
MD5(/usr/sbin/httpd)= d5194790e9cfaca881d0e8fc3db24889
MD5(/usr/lib/libapr-1.0.dylib)= f7f7fd3cd315ca4e7c6ad2a2f222998e

The libapr-1.0.dylib is linked to the newer 1.0.2.12 version.

like image 848
gagneet Avatar asked Dec 08 '25 13:12

gagneet


2 Answers

I'm having a similar problem and got to this page cause I feel lucky today :) The error means the httpd binary makes reference to a symbol that cannot be found in the appropriate dynamically linked library (libapr in this case, Apache Runtime Library)

Running same OS X version on an iMac. /usr/lib/libapr-1.0.dylib points to the most recent version of the library (1.0.2.12), which does not define the method/symbol _apr_socket_sendfile

The other version of libapr library is 1.0.2.7, does have that symbol. I had the symbolic links point to this version instead (also for libaprutil):

// BEFORE (both 1.0.2.7 and 1.0.2.12 versions exist, symlinks point to .12)
bash-3.2# ls -l libapr*
-rwxr-xr-x  2 userna  wheel  835824 19 Sep  2008 libapr-1.0.2.12.dylib
-rwxr-xr-x  1 root    wheel  578640 24 Sep  2007 libapr-1.0.2.7.dylib
lrwxrwxrwx  1 root    wheel      21 14 Oct  2008 libapr-1.0.dylib -> libapr-1.0.2.12.dylib
lrwxrwxrwx  1 root    wheel      21 14 Oct  2008 libapr-1.dylib -> libapr-1.0.2.12.dylib
-rwxr-xr-x  2 userna  wheel  569544 19 Sep  2008 libaprutil-1.0.2.12.dylib
-rwxr-xr-x  1 root    wheel  393696 24 Sep  2007 libaprutil-1.0.2.7.dylib
lrwxrwxrwx  1 root    wheel      25 14 Oct  2008 libaprutil-1.0.dylib -> libaprutil-1.0.2.12.dylib
lrwxrwxrwx  1 root    wheel      25 14 Oct  2008 libaprutil-1.dylib -> libaprutil-1.0.2.12.dylib

// CHANGE symbolic links to previous version
bash-3.2# ln -sf libapr-1.0.2.7.dylib libapr-1.0.dylib
bash-3.2# ln -sf libapr-1.0.2.7.dylib libapr-1.dylib
bash-3.2# ln -sf libaprutil-1.0.2.7.dylib libaprutil-1.0.dylib
bash-3.2# ln -sf libaprutil-1.0.2.7.dylib libaprutil-1.dylib

// TESTing whether httpd is loaded and run
bash-3.2# /usr/sbin/httpd -t
Syntax OK

Not really sure whether this has been broken since last software update that included Apache Web Server, I rarely use it on this box.

Hope it helps ;)
Jon

like image 162
Jon RePe Avatar answered Dec 11 '25 01:12

Jon RePe


Maybe there are errors in the apache configuration.

If you disable the webserver in the System preferences and open a terminal you can check your configuration by typing:

httpd -t

If it gives a "Syntax OK" you're one step closer to a working webserver. Start the webserver manually by typing:

sudo httpd

If there are no errors, the webserver is started. Open a browser and check http://localhost. Sometimes an extra refresh (Command+R) is needed.

Stopping the server:

sudo httpd -k stop

If the manually starting works, but the System preferences version doesn't, Check the /var/log/apache2/error_log for errors.

like image 37
Bob Fanger Avatar answered Dec 11 '25 01:12

Bob Fanger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!