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

Pitfalls encountered when configuring nginx+php+mysql under debian

高洛峰
Release: 2023-03-05 15:38:01
Original
1429 people have browsed it

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 //m.sbmmt.com/ wheezy main non-free contrib
deb //m.sbmmt.com/ wheezy-proposed-updates main non-free contrib
deb-src //m.sbmmt.com/ wheezy main non-free contrib
deb-src //m.sbmmt.com/ wheezy-proposed-updates main non-free contrib
Copy after login
Copy after login

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
Copy after login
Copy after login

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

aptitude purge php5-suhosin
Copy after login
Copy after login

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数据库连接.';
 ?>
Copy after login
Copy after login

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 //m.sbmmt.com/ wheezy main non-free contrib
deb //m.sbmmt.com/ wheezy-proposed-updates main non-free contrib
deb-src //m.sbmmt.com/ wheezy main non-free contrib
deb-src //m.sbmmt.com/ wheezy-proposed-updates main non-free contrib
Copy after login
Copy after login

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
Copy after login
Copy after login

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

aptitude purge php5-suhosin
Copy after login
Copy after login

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数据库连接.';
 ?>
Copy after login
Copy after login

More configuration nginx+php+mysql under Debian encountered For related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template