Mac OSX builds PHP development environment

Source: Internet
Author: User
Tags php development environment php framework codeigniter kohana netbeans

Build a PHP development environment on Mac OSX:

1, because the system comes with apache2.4.10 and php5.5.20, no intention to mamp again.

To start Apache:

sudo apachectl start

To restart Apache:

sudo apachectl restart

To view the Apache version:

Httpd-v


2. Configure PHP:

To view the PHP version:

Php-v

Configure Apache to enable PHP:

sudo vi/etc/apache2/httpd.conf

To open the PHP5 configuration:

LoadModule Php5_module libexec/apache2/libphp5.so

Restart Apache after saving is in effect.


3, previously installed MySQL 5 and database management software Navicat Premium, will no longer install phpadmin.


4. Download and install NetBeans PHP 8.0.2.

Https://netbeans.org/downloads/index.html


5. Use NetBeans PHP to create a new PHP project and debug the code:

Debug code needs to configure PHP enable Xdebug, the author according to the traditional way to visit the official website of Xdebug, found only Windows binary download, almost walked a detour on the Mac self-compilation. After studying for some time, finally solve the problem.

A) OS X not only comes with Apache, PHP, libphp for Apache, but also comes with xdebug, enabling it, it requires sudo cp/etc/php.ini.default/etc/php.ini before executing the following command:

sudo sh-c ' echo zend_extension=$ (find/usr/lib/php/extensions-name "xdebug.so") >> $ (php-qr "Echo php_ini_loaded_ File (); ") && apachectl Restart '

Note: "Ambiguos Redirect" error occurs if you do not create/etc/php.ini first.

b) Configure the php.ini to support Xdebug:

sudo vi/etc/php.ini

Shit + G go to file Finally, add (zend_extension= is a) step automatically generated):

zend_extension= /usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so

xdebug.remote_enable= on

xdebug.remote_log= "/var/log/xdebug.log"

xdebug.remote_host= localhost

xdebug.remote_handler= DBGP

xdebug.remote_port= 9000

xdebug.idekey= Netbeans-xdebug


6. Configure Apache to refer to the PHP project path created by NetBeans. Because the NetBeans PHP IDE creates the project by default into the Netbeansprojects directory under the current user's XXX home directory, you need to set alias to run the IDE-created Web project ToDoList under Apache. The ToDoList project is an example project from the NetBeans IDE, especially because alias points to Todolist/web instead of todolist.

sudo vi/etc/apache2/httpd.conf

Add the following line:

Alias /todolist/users/xxx/netbeansprojects/todolist/web

<directory "/users/yxcd/netbeansprojects/" >

allowoverride all

Options Indexesmultiviewsfollowsymlinks

Require all granted

</Directory>

After you configure Todolist/config/config.ini, you may also receive an error:

Datetime::__construct (): It is not safe for rely on the system ' s timezone settings.

Workaround: Edit/etc/php.ini, open Date.timezone and set to Asia/shanghai

[Date]

Date.timezone = Asia/shanghai

Problem solved after restarting Apache.


7, everything has, only owe East wind. Finally, it is very easy to debug PHP projects with NetBeans. Right-click on the project tree and choose Debug from the context menu. The previous steps, if set incorrectly, will cause NetBeans to wait for the connection while debugging.

Some articles say waiting for the connection is 9000 port is occupied, need to modify the php.ini in the

xdebug.remote_port= 9000

For other values such as 9001, then set NetBeans Debug listening port also to 9001. Menu: NetBeans IDE > Preferences

Then click the PHP panel and switch to the Debug window to modify the debugger port. However, I encountered debugging while waiting for the connection situation is not because of the port, but the httpd.conf alias path problem, as well as the configuration of php.ini.


Ps:

1, the Windows version of the PHP environment, the author has also built countless times, each time is also as described above the general manual configuration. But today to help colleagues build the environment, I pass httpd.apache.org, step by step Guide to download xampp, found more convenient, so it is no longer manual toss. XAMPP installation, most of the software is not, only check Apache, PHP and so on.

2, Windows NetBeans PHP IDE debugging also need Xdebug, although you can xdebug download a companion XAMPP version (such as 32-bit, VC11, PHP 5.6, etc.) binary. dll, but I still recommend that you only need to edit C \ Xampp\php\php.ini, open the entry about Xdebug. Note that the Xdebug.remote_enable entry defaults to not on, but 0,0 represents off, not only to remove the comment symbol semicolon, but also to overwrite the item. or directly refer to my front 5, b) configuration.

3, strongly recommend PHP framework CodeIgniter, 8 years ago I contacted it, still hesitate to choose CI or its Community derivative version Kohana, I turned to the Java camp. Visiting CodeIgniter now, it is gratifying to see that it has finally reached 3.0, the use of the agreement to MIT, and the transfer of code to an American university. And Kohana's last update seems to have stayed a few years ago. A simple look at some of the introduction and video, self-wrote something, found that compared to the Java World, PHP + CI is so carefree, has been recommended to learn the back-end colleagues, to this also recommend to everyone.

Chinese CI site: http://codeigniter.org.cn

3.0 of the Chinese manual has not been completed, please give the community some encouragement.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Mac OSX builds PHP development environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.