Create a new php project so that it can be directly accessed in the browser

Source: Internet
Author: User
: This article mainly introduces how to create a new php project so that it can be accessed directly in a browser. if you are interested in the PHP Tutorial, refer to it. Environment

Let's talk about the environment. I use eclipse and the server is nginx.

Tools

  • Php
  • Nginx
  • Eclipse

Procedure

Create a php project



All the WaynextThe following content is not modified.

Then add the php file

Write test content at will. Mine is like this:


  

Configure nginx

In the nginx conf folder, there is a main. conf file, which can be modified directly. of course, we recommend creating a conf file by ourselves.

Create a vhosts folder in the conf folder to store the conf file of the php website.

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

Edit the content.
Copy the content of main. conf and modify it.
My final content is as follows:

server { listen 80; 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_script_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's one location ~ /\.ht { deny all; }}

By comparing the main. conf file, you will know where to modify it. you can modify it as needed.
server_nameActually write127.0.0.1I modified the hosts file of the system to direct it127.0.0.1. So the results are the same.

Save the conf file.

Start nginx and php, and then you can access it in the browser.

Let's test it. enterhttp://www.php-test.com/index.php[PS:www.php-test.comReplace it with your newly writtenserver_nameThen you can see the running result.
Note that if you enable eclipse, you may switch to the debugging mode. you can view the result by jumping out of the debugging.

PS: In fact, eclipse must be configured to implement php single-step debugging. this will be discussed in the next article.

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above describes how to create a new php project so that it can be accessed directly in a browser, including some content, and hope to help friends who are interested in PHP tutorials.

    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.