Windows assembly and configuration Apache +php Server

Source: Internet
Author: User
Tags php server vc9
Windows installation and configuration Apache +php Server

Download and install Apache server

Reference:http://blog.csdn.net/wujunokay/article/details/12707259

Download and install the PHP server

This best to the official website to download, there is zip, there is also installed, I downloaded the zip, decompression, you can directly use.

About the version there is no Php5apache2_2.dll, because the wrong version, how to judge the version?

There are two more versions of V6C:
VC6 x86 non thread safe
VC6 x86 thread safe
Of the two versions above, the non thread safe version of PHP was installed during the installation process,
There are no Apache options:
Select the Web server wish to Setup
IIS FastCGI
Other CGI
Do not setup a Web server

The Apache 2.2.x module option is available during the installation of the thread safe version:
Select the Web server wish to Setup
Apache 2.2.x Module
Apache CGI
IIS FastCGI
IIS CGI
Nsapi
Xitami
Netserve Web Server
Other CGI

Do not setup a Web server

If you want to use Php5apache2_2.dll, will download x86 thread safe series, I downloaded is php-5.4.20-win32-vc9-x86.

Configuring Apache and PHP Servers

1. Change the file php.ini-development in your PHP installation directory to the name php.ini.

2. Configure Upload_tmp_dir = path, such as upload_tmp_dir= "D:\MYPHPTMP".

3. Added in Apache's httpd file:

LoadModule php5_module "D:/my program/php-5.4.20-win32-vc9-x86/php5apache2_2.dll"
Phpinidir "D:/my program/php-5.4.20-win32-vc9-x86"
AddType application/x-httpd-php. php. html. htm

4. In php.ini: Extension_dir changed to ext in the path of its own installation, for example: Extension_dir = "D:\my program\php-5.4.20-win32-vc9-x86\ext".

Testing Apache and PHP servers

The code in the 1.upload.html is as follows:


The 2.upload_file_web.php code is as follows:

 0) {//echo "Error:". $_files["Trackdata" ["Error"]. "
"; $error = "200"; } else {//echo "Upload:". $_files["Trackdata" ["Name"]. "
"; echo "Type:". $_files["Trackdata" ["type"]. "
"; echo "Size:". ($_files["Trackdata" ["size"]/1024). The Kb
"; echo "Stored in:". $_files["Trackdata" ["Tmp_name"]. "
" ; } if (File_exists ("upload/". $_files["Trackdata" ["Name"])) {//echo $_files["trackdata" ["Name"]. "already exists."; $error = "201"; } else {move_uploaded_file ($_files["Trackdata" ["Tmp_name"], "upload/". $_files["Trackdata" ["name"]); echo "Stored in:". " Upload/". $_files["Trackdata" ["Name"]; $error = 202; } Echo $error; return $error;} ?>


3. Place these 2 files under the DocumentRoot path of the httpd configuration.

4. Modify the order of execution here in Apache's httpd file:

DirectoryIndex upload.html

5. Test, you can upload the file to DocumentRoot under the upload folder.

About $_files

This is a global array of files, but I used C + + and IE test, with file_put_contents ("Abb.txt", Var_export ($_files,true));

Print out the content is different, as follows:

This is the point in IE:
Array (
' File ' = =
Array (
' Name ' = ' Test3.txt ',
' Type ' = ' text/plain ',
' Tmp_name ' = ' d:\\my program\\php-5.4.20-win32-vc9-x86\\temp\\php49a.tmp ',
' ERROR ' = 0,
' Size ' = 16,
),
)
Using VC + + client is this:
Array (
' Trackdata ' =
Array (
' Name ' = ' Test3.txt ',
' Type ' = ' application/x-www-form-urlencoded ',
' Tmp_name ' = ' d:\\my program\\php-5.4.20-win32-vc9-x86\\temp\\php49f.tmp ',
' ERROR ' = 0,
' Size ' = 16,
),
)

Find the cause and analyze the following:

The reason is that in the VC
Strformat + = _t ("Content-disposition:form-data; Name=\ "Trackdata\"; Filename=\ "%s\" ");
Strformat + = _t ("\ r \ n");
Strformat + = _t ("Content-type:audio/wav");
Strformat + = _t ("content-type:application/x-www-form-urlencoded");
Strformat + = _t ("\ r \ n");
Strformat + = _t ("Content-transfer-encoding:binary");
In the upload.html.

So when it comes to quoting, it's
$_files["Trackdata" ["Error"], _files["Trackdata" ["type"], _files["Trackdata" ["Name"] and
$_files["File" ["Error"], _files["file" ["type"], _files["file" ["Name"].

Postscript

First, not familiar with PHP, to use Apache HTTP server to implement C + + file upload and download function, first installed Apache server, but always can not upload success, find some information on the Internet, installed PHP server, you can upload the success, and then installed PHP Server, test results can be uploaded successfully. That means the Apache server configuration should be no problem, PHP side can, that C + + can also. That's the problem with C + + If you call the URL, the data is passed to the server. Here to thank a netizen, is to do PHP in Beijing, has his enthusiastic help, only debugging through C + + and PHP, to achieve the function of uploading. At the moment it can only be said that the test pass, there are a lot of performance and functions need to be optimized. will also encounter some problems, but as long as a way to solve, there will be some gains.

Reprint please indicate original link: http://blog.csdn.net/wujunokay/article/details/12833127


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