


Pitfalls encountered when configuring nginx+php+mysql under debian
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 '开始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 '开始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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

Steps to create a Docker image: Write a Dockerfile that contains the build instructions. Build the image in the terminal, using the docker build command. Tag the image and assign names and tags using the docker tag command.

In Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.

Steps to start Nginx in Linux: Check whether Nginx is installed. Use systemctl start nginx to start the Nginx service. Use systemctl enable nginx to enable automatic startup of Nginx at system startup. Use systemctl status nginx to verify that the startup is successful. Visit http://localhost in a web browser to view the default welcome page.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.
