1

For offline development I would like to make make a standalone PHP 5.4 binary so I can use the PHP self hosting option. eg php -S localhost:8000 Which would startup a server for hosting PHP files.

Since installing and configuring PHP 5.4 on mac is not trival for non tech people. I would like to be able to include a working PHP binary in my files. So essentially I can run. ./php -S localhost:8000 in my folder and it will work.

I have followed the instruction here to create a standalone PHP binary by running on the source code.

./configure --enable-static --enable-cgi --enable-mbstring\
   --enable-force-cgi-redirect \
   --with-config-file-path=/etc/php5cgi \
   --prefix=/usr/local/php5cgi \
     --with-curl \
    --enable-sockets \
   --with-zlib --with-zlib-dir=/usr/include \
   --with-pear 

Then editing the Makefile to have -all-static

BUILD_CGI = <other commands here> $(ZEND_EXTRA_LIBS) -all-static -o $(SAPI_CGI_PATH).
BUILD_CLI = <other commands here> $(ZEND_EXTRA_LIBS) -all-static -o $(SAPI_CGI_PATH).

This does work. File is standalone. But when I run the binary.

./php-cgi -h 

There is no "-S" option for the built in webserver? Do I need to change something in my configure options to allow the builtin webserver? My source was downloaded from PHP.net (I did download the 5.5 latest source, but that still does have the -S option).

Thanks, John.

5
  • 1
    Why don't you install Homebrew and use: github.com/josegonzalez/homebrew-php Commented Aug 15, 2013 at 4:44
  • 1
    i think the issue is your building a php-cgi not the php-cli Commented Aug 15, 2013 at 4:46
  • So just change the cgi at the start of my configure to cli? Commented Aug 15, 2013 at 5:00
  • Seriously, it takes only a couple of minutes, most of them spent waiting for PHP to compile, if you use Homebrew. I'd suggest that any day over hand-compiling, unless you have really really specific needs that aren't addressed by the Homebrew package. Commented Aug 15, 2013 at 7:34
  • Homebrew is not my problem. I need a 100% standalone PHP binary for mac. Now I got it working the file is 2.5mb zipped. This means my solution is self contained. Otherwise I need to tell designers they need to update their machines to PHP5.4 and change their path. This is just to hard. Commented Aug 15, 2013 at 8:17

1 Answer 1

1

thanks to @devZer0 I cd'ed into sapi/cgi/php-cgi and tried to run this. Needed to cd into sapi/cli/php That works now! php -h return the -S option for webserver.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.