Steps and methods to build PHP server environment on CentOS server other

Source: Internet
Author: User
Tags install php php server centos centos server

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:

/ETC/INIT.D/HTTPD start

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:

/etc/init.d/mysqld start

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:

<?php phpinfo ();?>

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.

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.