Here I explain how to install PHP and CGI on your .
You may need basic knowledge of Linux command, PHP, Java, Tomcat.
Please use the link below to go to further reading if necessary.
1. Check PHP and CGI are installed
2. Install XCode
3. Install Port
4. Install CGI
5. Check PHP and CGI version
Follow the instruction 1. Check PHP and CGI are installed.
If you have any suggestion and question, especially technically and grammatically, please feel free to leave your comment.
Thank you for your visit😊
You may need basic knowledge of Linux command, PHP, Java, Tomcat.
Please use the link below to go to further reading if necessary.
I. How to install Java
II. How to install Tomcat
III. How to install PHP and CGI
IV. How to deploy PHP/JavaBridge
V. How to deploy your PHP and Java files
II. How to install Tomcat
III. How to install PHP and CGI
IV. How to deploy PHP/JavaBridge
V. How to deploy your PHP and Java files
III. How to install PHP and CGI
1. Check PHP and CGI are installed
1.1. Check PHP version
Open Terminal and enter following command.
If you see your result as below, you have already installed PHP and CGI. If not, follow next step.

Open Terminal and enter following command.
php -v
You can also find out where is php.ini by entering these following command.which php
whereis php
1.2. Check CGI versionwhereis php
php-cgi
If you see your result as below, you have already installed PHP and CGI. If not, follow next step.

2. Install XCode
In order to use Port, you need to install XCode first.
Open AppStore and install XCode.
Make sure you run XCode after the installation.

Open AppStore and install XCode.
Make sure you run XCode after the installation.

3. Install Port
Here I show How to install Port. 
If you have Brew, go head and use it instead of Port.
3.1. Download Port installer
Here is port file I found online. Please download Port installation file
3.2. Extract tar.gz file
If you have Brew, go head and use it instead of Port.
3.1. Download Port installer
Here is port file I found online. Please download Port installation file
3.2. Extract tar.gz file
tar xzvf MacPorts-2.4.1.tar.gz
3.3. Build and install the unpacked sourcescd MacPorts-2.4.1
make && sudo make install
3.4. If you would like to delete installation files, type following commandmake && sudo make install
cd ../
rm -rf MacPorts-2.4.1*
rm -rf MacPorts-2.4.1*
4. Install CGI
4.1. Add /opt/local/bin to $PATH
It is also ok to install php and php-cgi separately.
vim ~/.bash_profile
$PATH = $PATH:{whatever directry you have here}:/opt/local/bin
4.2. Install the same version of PHP and CGI$PATH = $PATH:{whatever directry you have here}:/opt/local/bin
It is also ok to install php and php-cgi separately.
sudo port install php53 php53-cgi
4.3. Make link to php and php-cgicd /opt/local/bin
ln -s php53 php
ln -s php-cgi53 php-cgi
If php and php-cgi already exist, use the following command for update instead.ln -s php53 php
ln -s php-cgi53 php-cgi
ln -sfn
5. Check PHP and CGI version
Follow the instruction 1. Check PHP and CGI are installed.
If you have any suggestion and question, especially technically and grammatically, please feel free to leave your comment.
Thank you for your visit😊
Comments