Build a Linux + PHP development environment _ php instance in win7

Source: Internet
Author: User
Tags php development environment
This article will introduce my PHP development environment in the form of an overview and list the tools I use, but the configuration process will not be too detailed. For more information, see. I have been using Linux desktops for more than three years, and it is quite uncomfortable. The main reason is that the experience of various software is not uniform, and it is too split. too many choices are hard to choose.
Back to Windows, it is even worse. using * nix tool set becomes very difficult, and it is also troublesome to deploy the Web environment, and my servers are all Linux, some functions in the code cannot run on Windows.

Because I occasionally play games, I chose to go back to the Windows desktop a month ago.
However, the software below me is almost cross-platform. if you use Linux desktop, there will be no impact.

My host is Windows 7x64, and then runs an Arch virtual machine. all code is run and debugged on the virtual machine.

Arch Virtual Machine

Arch installation is a bit difficult, but I like its KISS philosophy. I use VirtualBox to allocate 512MiB or even 256MiB.
Change the network to "bridging network card" and then set a fixed IP address bound to the MAC on the vro. I gave the virtual machine 192.168.0.105 while my host was 192.168.0.100.

The core software packages to be installed are: openssh, nginx, mariadb, php, and xdebug.
Others: vim, mongodb, php-mongo, and phpmyadmin.

It is inconvenient to directly run commands on the virtual machine window of VirtualBox. I will install a virtual desktop software called zooawin, similar to the Workspace of KDE, which will throw the VirtualBox window to another desktop.
Then run the XShell command to connect to SSH.

Of course, you also need to create a non-root account for daily use. I have created a jysperm.
Then you can modify/etc/php/php-fpm.conf:

User = jysperm
Group = jysperm
In this way, the PHP-FPM process will run with your users, read and write files will not encounter any permission issues.

As a development server, you may need to develop and test multiple projects at the same time. it is very difficult to create a site in Nginx every time. the following configuration file allows you:

The code is as follows:


Server {
Listen 80;
Server_name ~ (?

. *) \. AB \. jyprince \. me $;

Access_log/home/jysperm/nginx. access. log;
Error_log/home/jysperm/nginx. error. log;

Index index.html index. php;
Autoindex on;

Root/home/jysperm/$ dir;

Location /{
Try_files $ uri // index. php? $ Args;
}

Location ~ \. Php $ {
Fastcgi_pass unix:/run/php-fpm/php-fpm.sock;

Fastcgi_index index. php;
Include fastcgi_params;
}
}

*. AB. jyprince. the me domain name is resolved to 192.168.0.105. in this way, you only need to access test. AB. jyprince. me, which is equivalent to accessing the files in/home/jysperm/test, and you do not need to modify the Nginx configuration file in the future.

PHPStorm

The best ide I have ever seen is PHPStorm.

The Deployment function of PHPStorm can be automatically deployed to the server after you modify the file each time. you only need to create an SFTP-type server, fill in the information of the Arch Virtual Machine, and then select Automatic Upload.
Each project is uploaded to a folder under/home/jysperm.

Then access the project name. AB. jysperm. me. everything is automatic.

Remote Debugging

Modify/etc/php/conf. d/xdebug. ini in the Arch VM:

The code is as follows:


Zend_extension =/usr/lib/php/modules/xdebug. so
Xdebug. remote_enable = on
Xdebug. idekey = jysperm
Xdebug. remote_host = 192.168.0.100
Xdebug. remote_port = 9000

Create a new PHP Remote Debug in PHPStorm.
When debugging is required, enable debugging in PHPStorm, set a breakpoint, and then enable the request to carry the Cookie XDEBUG_SESSION = jysperm.
When debugging the page, you can use this tool to generate bookmarks and click bookmarks to control the debugging switch.

When debugging RESTful APIs, I usually use a Chrome extension called Postman. this application does not seem to have the Cookie editing function. in this case, a Cookie is added to the HTTP Header: XDEBUG_SESSION = jysperm.

Other recommendations

Robomogo-cross-platform Mongo GUI client
SourceTree-Git GUI in Windows
SSH in Secure Shell-Chrome
Clover-make Windows resource manager like Chrome
FileZilla-cross-platform FTP client
SmartGit-cross-platform Git GUI
Sublime Text-easy-to-use cross-platform editor

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.