-->

How do I install php-cgi? I tried MacPort, Package

2019-07-19 23:51发布

问题:

I am trying to install php-cgi on my macbook (Yosemite 10.9.3) because the PhpStorm IDE keeps coming back to me "php-cgi not found" when i try to open things in browser. I tried to use a newer version of php interpreter because the current version is 5.4. But I can only find the packages in the php.net site but I have no clue how to install it. I also tried to download homebrew but again have no clue how to start there. I tried to use MacPort to install a fastcgi by using this line: sudo port install php5 +fastcgi

But it returns this:

--->  Dependencies to be installed: autoconf213 gawk gettext expat libiconv ncurses readline m4 perl5 perl5.16 gdbm bzip2 gsed libtool libxml2 xz zlib mhash pcre libedit pkgconfig

--->  Fetching archive for expat
--->  Attempting to fetch expat-2.1.0_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/expat
--->  Attempting to fetch expat-2.1.0_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/expat
--->  Installing expat @2.1.0_0
--->  Activating expat @2.1.0_0
Error: org.macports.activate for port expat returned: Image error: /opt/local/bin/xmlwf already exists and does not belong to a registered port.  Unable to activate port expat. Use 'port -f activate expat' to force the activation.
Error: Failed to install expat
Please see the log file for port expat for details: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_textproc_expat/expat/main.log
Error: The following dependencies were not installed: autoconf213 gawk gettext expat libiconv ncurses readline m4 perl5 perl5.16 gdbm bzip2 gsed libtool libxml2 xz zlib mhash pcre libedit pkgconfig
To report a bug, follow the instructions in the guide:http://guide.macports.org/#project.tickets
Error: Processing of port php5 failed

I run a self-update with the MacPort already (version 2.3.0). Can anyone help out? Thank you so much!

P.S. For PhpStorm, I am forced to use the built-in web server when i try to view the code in the browser. If anyone got a way to do that without their built-in server, that would be great too. I have a zend server installed already.

P.S. I am using NetBeans now. But I guess it is good to make sure I get things like this settled while I am working on other things.

回答1:

It took me a few tries to get PhpStorm setup with MacPorts. These are the basic steps:

sudo port install php53 php53-cgi

This should create /opt/local/bin/php53 and php-cgi53, so next:

cd /opt/local/bin
ln -s php53 php
ln -s php-cgi53 php-cgi

Then register the PHP Interpreter with PHP Home set to /opt/local/bin and it should detect it and "Open in Browser" correctly.



回答2:

For PhpStorm, I am forced to use the built-in web server when i try to view the code in the browser. If anyone got a way to do that without their built-in server, that would be great too. I have a zend server installed already.

You are NOT forced in any way.

Just configure Deployment entry (Preferences | Deployment) and mark it as Default for this project. The URL defined there will be used when previewing pages from PhpStorm.

Without deployment entry the built-in web server is used by default.