Home >Backend Development >PHP Tutorial >Pitfalls encountered when configuring nginx+php+mysql under debian

Pitfalls encountered when configuring nginx+php+mysql under debian

高洛峰
高洛峰Original
2017-02-09 09:34:251425browse

1. The debian6 server I use on Alibaba Cloud has php5.3.3 installed by default. But the modules such as php-cgi and php-fpm were not installed, because I used the fastcgi module when configuring nginx and php in the windows test environment, so I wanted to follow php-cgi as soon as I started, but executed apt-get install php5- cgi reports an error. After struggling all morning, I modified the /etc/apt/source.list source file and added the following source:

deb http://www.php.cn/ wheezy main non-free contrib
deb http://www.php.cn/ wheezy-proposed-updates main non-free contrib
deb-src http://www.php.cn/ wheezy main non-free contrib
deb-src http://www.php.cn/ wheezy-proposed-updates main non-free contrib

Then I installed php-cgi and php-fpm, and it was successful. . .

2. After installing php, the original installation experience should be to use php-cgi to start php, but when entering php-cgi -b 127.0.0.1:9000, the system reports the following error:

HP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/suhosin.so' - /usr/lib/php5/20100525+lfs/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0

Then go online After querying the cause of the error, one article mentioned that it could be executed:

aptitude purge php5-suhosin

Sure enough, php started successfully.

3.nginx and php have been successfully installed and published, now you need to connect to the database. Experience in installing Windows environment requires modifying php.ini. It turns out that the configuration method under Linux is different. You need to install php5-mysql first. After the installation is successful, you can use the following code to test whether PHP can successfully connect to mysql

<?php
header("Content-type:text/html;charset=utf-8");
echo &#39;开始mysql数据库连接.<br>';
$con = mysql_connect("localhost","root","root");
if($con){
echo '连接mysql数据库成功.<br>';
}else{
die('连接mysql数据库失败:' . mysql_error());
}
mysql_close($con);
echo '关闭mysql数据库连接.';
 ?>

1. I use the debian6 server on Alibaba Cloud. php5.3.3 is installed by default. But the modules such as php-cgi and php-fpm were not installed, because I used the fastcgi module when configuring nginx and php in the windows test environment, so I wanted to follow php-cgi as soon as I started, but executed apt-get install php5- cgi reports an error. After struggling all morning, I modified the /etc/apt/source.list source file and added the following source:

deb http://www.php.cn/ wheezy main non-free contrib
deb http://www.php.cn/ wheezy-proposed-updates main non-free contrib
deb-src http://www.php.cn/ wheezy main non-free contrib
deb-src http://www.php.cn/ wheezy-proposed-updates main non-free contrib

Then I installed php-cgi and php-fpm, and it was successful. . .

2. After installing php, the original installation experience should be to use php-cgi to start php, but when entering php-cgi -b 127.0.0.1:9000, the system reports the following error:

HP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/suhosin.so' - /usr/lib/php5/20100525+lfs/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0

Then go online After querying the cause of the error, one article mentioned that it could be executed:

aptitude purge php5-suhosin

Sure enough, php started successfully.

3.nginx and php have been successfully installed and published, now you need to connect to the database. Experience in installing in windows environment, you need to modify php.ini. It turns out that the configuration methods under Linux are different. You need to install php5-mysql first. After the installation is successful, you can use the following code to test whether PHP is successfully connected to mysql

<?php
header("Content-type:text/html;charset=utf-8");
echo &#39;开始mysql数据库连接.<br>';
$con = mysql_connect("localhost","root","root");
if($con){
echo '连接mysql数据库成功.<br>';
}else{
die('连接mysql数据库失败:' . mysql_error());
}
mysql_close($con);
echo '关闭mysql数据库连接.';
 ?>

More configuration nginx+php+mysql under Debian encountered For related articles, please pay attention to 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