Environment
Virtual machine: VMWare10.0.1 build-1379776
Operating system: CentOS7 64-bit
HTTP Server:apache (httpd)
Steps
PHP environment requires HTTP server support, this article uses the HTTP server for Apache, you can also choose the more popular nginx.
Apache default root directory View location/etc/httpd/conf/httpd.conf File View documentroot configuration values
1. Install PHP
Yum Install PHP php-devel
2, install php Common extension (optional, according to their actual needs)
Yum Install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
3. Restart Apache to make PHP effective
Apachectl restart
4. Test the PHP environment
Create a new info.php in the/var/www/html directory (Apache default root directory)
VI /var/www/html/info. php
File contents
Phpinfo ();?>
Visit http://localhost/info.php
Additional: MySQL Test
Create a new mysql.php in the/var/www/html directory (Apache default root directory)
VI /var/www/htmml/mysql.php
File contents
<?PHP$con=mysql_connect("localhost", "root", "root");if(!$con) { die(' Could not connect: '.Mysql_error()); } mysql_select_db("MySQL",$con); $result=mysql_query("SELECT * from User"); while($row=Mysql_fetch_array($result)) { Echo $row[' User ']. " " .$row[' Host ']; Echo"<br/>"; } Mysql_close($con);?>
Visit http://localhost/mysql.php
Deployment CentOS Installation PHP Environment