Enable PHP Programs

Source: Internet
Author: User

PHP is the abbreviation for the Personal Home page, but now PHP represents the hypertext preprocessor, which is the hypertext preprocessor. So, PHP is a program, and the so-called "preprocessing" refers to the PHP program processing PHP code, just output content (such as HTML static page, also can not output), and ultimately by the browser to parse the display, so PHP is only "preprocessing", not the results.

So, how to use PHP programs?

This article describes how to enable a PHP program and implement a simple request.

PHP is generally used as a scripting language parser in the service background, and it is related to Apache, IIS and other programs:

Therefore, it is common to use other programs to enable the PHP program.

The small range uses Mac computers, and MacOS comes with Apache and PHP to see their versions:

In other words, the path can be enabled by Apache to PHP. Then, it is necessary to understand the use of Apache first.

(1) Use of Apache

Take a demo of Apache Startup and inspection:

Apache installation directory (/PRIVATE/ETC/APACHE2) and configuration file (httpd.conf):

Open the configuration file, you can find the Apache definition of the project directory where (you can modify this directory):

At this point the thread has not written any code, this path (/library/webserver/documents) The following content is this:

After seeing these files, the thread can request (read) These files directly via the Curl command or the browser, such as:


This means that if the thread creates a PHP file under the project directory, it can be requested.

(2) Let Apache enable PHP

Note the relationship between Apache and PHP, generally need to use Apache to invoke PHP. And let Apache enable PHP, just to the Apache configuration file httpd.conf inside a sentence to uncomment:

After you dismiss the comment, you can restart Apache and let it use the new configuration content, followed by subsequent validation:

sudo apachectl restart

(3) Test PHP request

Then, the program writes a PHP file under the project directory:

To request this PHP file in a browser, you can see the information that is returned to PHP:

To summarize, this article describes the example of using PHP programs on Mac computers and involves some basic knowledge of PHP. When operating on a Mac computer, the difficulty factor is 1.

Enable PHP Programs

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.