Create a new PHP project and make it accessible directly from the browser

Source: Internet
Author: User
Environment

Let's talk about the environment, I use Eclipse, the server is Nginx.

Tools

    • Php
    • Nginx
    • Eclipse

Specific steps

New PHP Project



All the way next , the following content is temporarily not modified.

Then add the php file

Write the test content casually. Mine is this:


   
    echo"Hello PHP!\n";$var = 0;$var += 5;var_dump($var);echo"Bye!\n";

Configure Nginx

In the Nginx Conf folder there is a main.conf, we can directly modify this, of course, the more recommended method is to create a new conf file.

We create a new vhosts folder in the Conf folder that holds the Conf file for the PHP site.

Now we create a new php-test.conf file in the Vhosts folder.

Edit the content inside.
First copy the contents of the main.conf, and then modify the good.
My final content is this:

server {Listen the;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. LogMain;Error_log F:/devenv/logs/php-test. Error. Log;# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9001Location ~ \. PHP$ {try_files $fastcgi _script_name =404;Fastcgi_pass127.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 ' s oneLocation ~/\. HT{Deny All;}}

We compare the main.conf to know where to change, on-demand modification can be.
server_nameIt's actually 127.0.0.1 good to write, I'm here to modify the system's hosts file so that it points to 127.0.0.1 . So actually the effect is the same.

Save the Conf file as well.

The next step is to launch Nginx and PHP, which can then be accessed in the browser.

Let's test it in the browser by typing http://www.php-test.com/index.php "PS: www.php-test.com replace it with your own just wrote server_name " and then you can see the results of the run.
Note that if you open eclipse, it is possible to go into debug mode and jump out of debugging to see the results.

PS: In fact, eclipse to configure to implement PHP single-step debugging, the next article is about this.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the new and a PHP project, so that it can be accessed directly in the browser, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.