Environment
Speaking of the environment, I am using Eclipse, the server is Nginx. Tools php nginx eclipse Specific steps to create a new PHP project
As shown in figure:
All the way next, the following content is temporarily not modified.
Then add the php file
Write a little bit of test content. Mine is this:
<?php
echo "Hello php!\n";
$var = 0;
$var + 5;
Var_dump ($var);
echo "bye!\n";
Configure Nginx
In Nginx's Conf folder there is a main.conf, we can directly modify this, of course, the more recommended method is to create a conf file of their own.
We create a new vhosts folder in the Conf folder to store the Conf file for the PHP website.
Now we create a new php-test.conf file in the Vhosts folder.
Edit the contents of the inside.
First copy the contents of the main.conf, and then modify the good.
My final content is this:
server {
listen ;
server_name www.php-test.com;
Root d:/code/php-test;
Index index.php;
CharSet Utf-8;
Access_log f:/devenv/logs/php-test.access.log main;
Error_log F:/devenv/logs/php-test.error.log;
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9001
location ~ \.php$ {
try_files $fastcgi _SCRI Pt_name = 404;
Fastcgi_pass 127.0.0.1:9001;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include fastcgi_params;
}
# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' one
location ~/\.ht {
D Eny all ;
}
We compare main.conf to know where the changes, on-demand changes can be.
server_name there actually write 127.0.0.1, I am here to modify the system of the hosts file let it point to 127.0.0.1. So actually the effect is the same.
Save the Conf file.
Next, start Nginx and PHP, and then you can access it in the browser.
Let's test, in the browser input http://www.php-test.com/index.php "PS: replace www.php-test.com into their own just write server_name", and then you can see the results of the operation.
Note that if you are running eclipse at this point, you may be in debug mode and you will see the results out of debugging.
PS: In fact, eclipse to configure to achieve a single step of PHP debugging, the next article will introduce this.