Home  >  Article  >  Backend Development  >  How to deploy php in linux

How to deploy php in linux

藏色散人
藏色散人Original
2020-07-24 10:06:483613browse

How to deploy PHP on Linux: First open the terminal and execute the command "yum install php php-devel"; then install common PHP extensions; finally restart apache with the command "apachectl restart" to make PHP take effect.

How to deploy php in linux

Deploy php in Linux (CentOS7) system:

First open the terminal.

yum install php php-devel Enter to confirm the installation, wait about 20 seconds and the installation is successful.

Recommended: "PHP Tutorial"

How to deploy php in linux

Install common PHP extensions (optional, according to your actual needs)

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

How to deploy php in linux

Restart apache to make php take effect

apachectl restart

How to deploy php in linux

Test the php environment

In the /var/www/html directory Create a new info.php

vi /var/www/html/info.php

file content in (Apache’s default root directory)

<?php phpinfo(); ?>

Visit http://localhost/info.php

How to deploy php in linux

Additional: mysql test (not installed but needs to be installed)

Create a new mysql.php in the /var/www/html directory (apache default root directory)

vi /var/www/htmml/mysql.php

File content

<?php
$con = mysql_connect("localhost","root","root");
if (!$con)  {  
die(&#39;Could not connect: &#39; . mysql_error());  } 
mysql_select_db("mysql", $con); 
$result = mysql_query("SELECT * FROM user"); while($row = mysql_fetch_array($result))  {  
echo $row[&#39;User&#39;] . " " . $row[&#39;Host&#39;];  
echo "<br />";  } 
mysql_close($con);
?>

How to deploy php in linux

Visit http://localhost/mysql.php to view database information.

How to deploy php in linux

Notes

The php installation package can be downloaded directly using the terminal, no need to download it in advance

The above is the detailed content of How to deploy php in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn