This article illustrates the steps and methods of building a PHP server environment on CentOS. Share to everyone for your reference, specific as follows:
Install Apache:
Yum Install httpd Httpd-devel
Start Apache:
Enter the IP address of the server at this time, should see Apache service page, the port does not lose, Apache default is to use 80 ports
Install MySQL:
Yum install MySQL Mysql-server
Start MySQL:
Installing PHP
Yum Install PHP Php-devel
Restart Apache for PHP to take effect
/ETC/INIT.D/HTTPD restart
At this point you can create a PHP file in the directory:/var/www/html/
Code:
Then access this file, you can see some information about PHP, php.ini configuration file path can be seen on this page
Installing Extensions for PHP
Copy Code code as follows:
Yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
you need to restart Apache after you install the extension
/ETC/INIT.D/HTTPD restart
Test whether MySQL links successful PHP code
<?php
$con = mysql_connect ("10.0.@.@@", "@@", "@@");
if (! $con)
{
die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("MyDB", $con);
$result = mysql_query ("SELECT * from Sys_user");
while ($row = Mysql_fetch_array ($result))
{
echo $row [' UserName ']. " " . $row [' PassWord ']. " " . $row [' id '];
echo "<br/>";
}
Mysql_close ($con);
? >
You can pass the above code into the directory/var/www/html/
We can see the implementation.
PS: A simple build method can also be used as a key deployment, such as the Ezhttp tool. Interested friends can refer to the relevant documentation, no longer described here.
I hope this article will help you with your CentOS server configuration.