Let your Apache2.0.45 support php_php tutorials on the win platform

Source: Internet
Author: User
Tags sapi
Foreword If you lack confidence in using Apache. Or you're already using Apache 2 but you can't let him work with PHP (Apache can't parse your. php script). Don't be afraid, after reading this article, all the problems will be toughened and solved. How do I summarize how the Apache and PHP methods work together. In fact, this is much simpler than what others have said. I was amazed why nobody wrote a guide to this issue before, so everyone could better understand and use Apache 2.0. With personal interest, I analyzed Apache 2.0, specifically, in order to get the latest Apache server, this article is 2.0.45 version. Now, for anyone who is concerned about the upgrade, upgrading the server to Apache 2.0 is much safer than upgrading Microsoft's IIS, and there are a whole bunch of useful tools. In this article, I'll show you how to configure your httpd.conf file to enable your server to handle. PHP and. Phps scripts. Next we're going to configure Apache 2, when we request the. php page to not show the source code or prompt to download without displaying the page we want to see. Our work includes: Download and install Apache 2.0.45 configuration httpd.conf file to make apache2 run. php and. phps files This article is for Windows 2000/ME/XP users. WIN95/98 and NT4.0 users who do not have an MSI installer may need to download and install it from Microsoft first. The reason I want to emphasize Msi installer is because this article is for the first time that Apache 2 was installed. If you have already installed Apache before this, you can start the installation directly. However, there are some steps to be taken in this article, especially when you plan to install PHP 4.3.1. All right, let's get started. Download Apache2 If you already have Apache 1.3 installed, please don't uninstall it, stop it first. After installing the Apache2 and PHP script work, you can safely uninstall apache1.3, uninstall please be careful to back up your httpd.conf file, so that you can only change a few places, you will be able to use it on the new server. For anyone who does not have Apache installed on the machine or other servers installed, please go to apache.org to download apache2.0.45 (http://nagoya.apache.org/mirror/httpd/binaries/win32/) first. Make sure you download the. msiThe file is 5.3M in size. Run the downloaded. msi file to install Apache. Your server will start automatically. If you have a firewall, make sure that the firewall allows access to Apache. You should pay attention to Apache service Monitor (a green light in the taskbar) that marks Apache at work. To make sure it is working, just move the mouse arrow to the monitor and it will tell you that it is working. Your taskbar should be about the same as: someone might wonder why it shows "running 1 out of 2 Apache services", that's because you might have more than one version of Apache at work. Most people don't do this, but there are two Apache servers on my machine. My 1.3.27 has stopped running, and Apache 2 is running. It's my machine: Notice that there's a red light on the apache1.3.27 monitor, and there's a Green Lantern on the apache2. The first person to install Apache can only see one, because you only have one. All right. The Apache server has been basically installed. Now let's download PHP source code, because we want PHP and APACHE to work together to php.net download the latest version of PHP (currently PHP 4.3.2 http://www.php.net/downloads.php). If you have already installed PHP, check if there are php4apache2.dll files under the Sapi file, and if so, you can skip the steps below. We need to download Php-4.3.2-win32.zip and php-4.3.1-installer.exe Two files, many people want to ask why all download. This is to make you lazy, so you can not need to create a folder, do not need to change the folder name from Php-4.3.1-win32 to PHP. We first use Installer.exe to install, it will build PHP folder for you, you can save more time. Run Installer.exe, install PHP according to your preferences, complete, unzip the zip file, and then locate the SAPI folder in the zipped package. Copy the folder to the PHP directory you just installed. (Example: c:php) Then we can delete the Php-4.3.2-win32 folder, because it is no longer needed (a bit of xiemoshalv feeling, haha). Copy the Php4ts.dll in the PHP folder to your system directory: Under XP is WINDOWSSystem32, under 2K is WINNTsystem32. Here we begin to modify the Conf file. Let Apache parse php pageOpen the httpd.conf file with your favorite text editor and let's add a few lines so that we can parse. php and. phps files. We need to pay attention to the two parts of the Conf file, the first part is the Dynamic Shared Object (DSO) Support list, the second part is Cgi-bin directory first let's find the DSO list shown below. # Dynamic Shared Object (DSO) Support # # to is able to use the functionality of a module which is built as a DSO you # h Ave-to-place corresponding ' LoadModule lines at the "so the" # directives contained in it is actually available _ Before_ they is used. # statically compiled modules (those listed by ' Httpd-l) does not need # to is loaded here. # # # # # Example: # LoadModule Foo_module modules/mod_foo.so There's a lot of it, always finding the last line: #LoadModule ssl_module modules/mod_ssl.so The row above is the column The last row of the table, press ENTER to produce an empty line, add the following line in this empty line: LoadModule php4_module C:/php/sapi/php4apache2.dll before closing the Conf file, we need to add two more lines. Find the Cgi-bin directory, in order to save time, you can look for: press Ctrl+f, (Translator Note: If you are in Notepad instead of WordPad to edit this text, then you should use the shortcut key F3) to find , in a second Back two times to enter the following two lines: AddType application/x-httpd-php. php. phtml. php3. PhP4 AddType application/x-httpd-php-source. Phps After adding the good, save your conf file and restart your Apache server. Advanced users can now test your exciting PHP scripts. Once it runs successfully, your work is over. For the initial installation of the user, you need to save the PHP file in your default path: C:Program filesapache groupapache2htdocs. Create a new text document, add the following code, and save it as date.php. Now to test the above code (try typing in the address bar of the browser: localhost/date.php, then hit Enter), should display the current month, date, year. If the output is correct, it means that PHP has already started working on your server. To satisfy the wishes of those who want to see the source code, you create a text document and add the following code:

You are using the Web browser.
<title><?php echo $title;?></title>Save it as Browser.phps and save as browser.php. After testing these two examples, you will find that the results are different. Browser.php will display your browser version, such as: You are using the mozilla/4.0 (compatible; MSIE 6.0; Windows 98) Web browser. And Browser.phps shows you the source code. Summary now, Apache 2.0.45 should be able to handle your. PHP and. Phps pages. Hope everything is running smoothly. Now you have a brand new server. :P

http://www.bkjia.com/PHPjc/509169.html www.bkjia.com true http://www.bkjia.com/PHPjc/509169.html techarticle Foreword If you lack confidence in using Apache. Or you're already using Apache 2 but you can't let him work with PHP (Apache can't parse your. php script). Don't be afraid, read this ...

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