Home > Article > Backend Development > How to deploy php project on linux
How to deploy PHP projects in Linux: First open the terminal and install PHP common extensions; then restart apache to make PHP take effect [apachectl restart]; finally test the PHP environment.
How to deploy PHP projects in Linux:
1. First open the terminal.
yum install php php-devel
Enter to confirm the installation, wait about 20 seconds and the installation is successful.
2. Install common PHP extensions (optional, based on your 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 take effect
apachectl restart4. Test the php environmentCreate a new info in the /var/www/html directory (Apache default root directory) .php
vi /var/www/html/info.phpFile content
<?php phpinfo(); ?>Visit http://localhost/info.php 5. Additional: mysql test ( It has not been installed and needs to be installed)Create a new mysql.php in the /var/www/html directory (apache default root directory)
vi /var/www/htmml/mysql.phpFile content
<?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);?>6. Visit http://localhost/mysql.php to view database information.
Related video recommendations:
The above is the detailed content of How to deploy php project on linux. For more information, please follow other related articles on the PHP Chinese website!