Home > Article > Backend Development > Solving PHP server installation problems for you_PHP tutorial
We all know the powerful functions of PHP. We will give a detailed introduction to the PHP server installation that everyone is worried about and share it with you. Please follow the steps below and come and try the PHP server. Install it!
<ol class="dp-xml"> <li class="alt"><span><span># For PHP 5 do something like this: </span></span></li> <li class=""> <span>LoadModule php5_module "C:/php/php5apache2.dll" </span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>----</SPAN></FONT></STRONG><SPAN> LINE 117 </SPAN></SPAN><LI class=alt><SPAN>AddType application/x-httpd-php .php </SPAN><LI class=""><SPAN> </SPAN><LI class=alt><SPAN># configure the path to php.ini </SPAN><LI class=""><SPAN>PHPIniDir "C:/php" </SPAN></LI></OL>
Then restarted the apache server, and the result was an error:
<OL class=dp-xml><LI class=alt><SPAN><SPAN>httpd.exe: Syntax error on line 117 of C:/apache/conf/httpd.conf: Cannot load C: </SPAN></SPAN><LI class=""><SPAN>/php/php5apache2.dll into server: The specified module could not be found. </SPAN><LI class=alt><SPAN>Note the errors or messages above, and press the </SPAN><STRONG><FONT color=#006699><SPAN class=tag><</SPAN><SPAN class=tag-name>ESC</SPAN><SPAN class=tag>></span></font></strong><span> key to exit. 20... </span> </li> </ol>
It took me two hours...crying...Solution: next 2.0.59 The apache server is ok. The previous error is caused by a version problem. To check whether it is installed, save the following code as hello.php and put it in htdocs under the main folder where the apache server is installed. Run the server and browse Enter: localhost/hello.php in the server to view.
<ol class="dp-xml"><li class="alt"> <span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>time</FONT></SPAN><SPAN class=attribute-value><FONT color=#0000ff>time</FONT></SPAN><SPAN> = time(); </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>thetime</FONT></SPAN><SPAN> = </SPAN><SPAN class=attribute-value><FONT color=#0000ff>date</FONT></SPAN><SPAN>("l, jS F Y g:ia",$time); </SPAN></SPAN><LI class=""><SPAN>echo "Hello world! The time is currently". $thetime ."."; </SPAN><LI class=alt><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span> </span> </li></ol>
Hey, I encountered a new problem the next day, unable to connect to the database, and the error message was:
<ol class="dp-xml"><li class="alt"><span><span>Call to undefined function mysql_connect() in ... </span></span></li></ol>
The reason is PHP5 unbundles the mysql client, and we need to change the configuration file ourselves. Uncomment the extension php_mysql.dll, and then set the extension_dir and it will be ok. There is no problem with my configuration, and the ddl files are also in the right place, but the problem remains the same, so in the end I had to Changing the software version again, I changed php to 4.4.4. Because 4.4.4 automatically configures mysql, there is no need to change php.ini. You only need to edit the apache configuration file:
<ol class="dp-xml"> <li class="alt"><span><span>#LoadModule php5_module "c:/php/php5apache2.dll" </span></span></li> <li class=""><span>LoadModule php4_module "c:/php/sapi/php4apache2.dll" </span></li> <li class="alt"><span>AddType application/x-httpd-php .php </span></li> </ol>
You can use this PHP server installation test code to test:
<ol class="dp-xml"><li class="alt"> <span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=""><SPAN>echo phpinfo(); </SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>link</FONT></SPAN><SPAN> = </SPAN><SPAN class=attribute-value><FONT color=#0000ff>mysql_connect</FONT></SPAN><SPAN>('localhost', 'root', '123456'); </SPAN></SPAN><LI class=""><SPAN>if (!$link) { </SPAN><LI class=alt><SPAN>die('Could not connect: ' . mysql_error()); </SPAN><LI class=""><SPAN>} </SPAN><LI class=alt><SPAN>echo 'Connected successfully'; </SPAN><LI class=""><SPAN>mysql_close($link); </SPAN><LI class=alt><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span> </span> </li></ol>
The gratifying thing is that this time I can find the mysql_connect method, but there is a new error:
<ol class="dp-xml"><li class="alt"><span><span>Client does not support authentication protocol </span></span></li></ol>
I almost want to give up at this point! Thinking of the importance of PHP, I finally gritted my teeth and persisted. This error is because the cryptographic algorithm of the mysql client program in php4 is incompatible with the new mysql server. There seems to be only one solution for php4. Just execute the following command in mysql:
<ol class="dp-xml"> <li class="alt"><span><span>mysql</span><span class="tag">></span><span> UPDATE mysql.user SET </span><span class="attribute">Password</span><span> = </span><span class="attribute-value">OLD_PASSWORD</span><span>('newpwd') </span></span></li> <li class=""> <span>-</span><span class="tag">></span><span> WHERE </span><span class="attribute">Host</span><span> = </span><span class="attribute-value">'some_host'</span><span> AND </span><span class="attribute">User</span><span> = </span><span class="attribute-value">'some_user'</span><span>; </span> </li> <li class="alt"> <span>mysql</span><span class="tag">></span><span> FLUSH PRIVILEGES; </span> </li> </ol>