


Compilation and installation of PHP7 under CentOS, MySQL support and solutions to some problems
I recently tried php7 and encountered some problems in compiling and supporting MySQL. I believe many students have encountered the same problem, so I will talk about the process here. To put it simply, there are only 3 steps to compile PHP7: 1. ./buildconf --force 2. ./configure 3. make make install Steps 1 and 3 are nothing to worry about. Configure is the key to compilation and involves
I recently tried php7 and encountered some problems in compiling and supporting MySQL. I believe many students have encountered the same problem, so I will talk about the process here. Simply speaking, compiling PHP7 only requires 3 steps:
1. ./buildconf --force
2. ./configure
3. make && make install
There is nothing to worry about in steps 1 and 3. Configure is the key to compilation and involves PHP’s support for some libraries. Here we use the minimum support, including MySQL:
curl
gd
fpm
mysqlnd
The reason why we use curl and gd as examples is to make it clear that these third-party libraries must be installed before compiling PHP. You can directly use yum to install them in the default location, or you can compile and install them to a specified location. After yum is installed, , there is no need to specify the installation location of the library when compiling. You can search for a lot about installing these libraries. Let’s take a look at the basic configure
./configure --PRefix=/apps/php/php7.<span style="color: #800080;">0</span> --enable-mbstring --with-curl --with-gd --with-config-<span style="color: #0000ff;">file</span>-path=/apps/php/php7.<span style="color: #800080;">0</span>/etc/ --enable-fpm --enable-mysqlnd --with-pdo-mysql=mysqlnd
PHP-FPM
Regarding fpm, I believe it goes without saying that using it to support PHP is a better choice. PHP5.3.3 has built-in php-fpm, so of course it is also available in PHP7. You only need to --enable-fpm. That’s it
php-fpm parameters:
--start Start
--stop force termination
--quit smooth termination
--restart Restart
--reload smoothly reloads php’s php.ini
--logrotate Re-enable log file
MySQL support
I’ll focus on this, because I spent a little time on it, and I don’t know which version it started from. PHP no longer wants to use the mysql library to support mysql connections. It has enabled mysqlnd to support it. I heard it is faster than libmysql. Many, PHP5.x can also use libmysql. PHP7 seems to have canceled the support. The --with-mysql parameter is not available in compilation. Only --with-mysqli and --with-pdo-mysql are supported. You can check the configure parameters. Come and find out:
./configure -help | <span style="color: #0000ff;">grep</span> mysql
As you can see, PHP hopes to use mysqlnd to support MySQL, so the parameters can be written like this:
--enable-mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
mysqlnd does not require mysql support, so it can be compiled and passed without installing mysql first. Start php-fpm and check phpinfo. You can see that mysqlnd and pdo_mysql indicate that php can already support mysql (pdo is used here) , mysqli is the same)
A few questions
Compilation problem: cc: Internal error: Killed (program cc1)
This is the first time I encountered this problem. It turned out that my Alibaba Cloud server turned off swap and there was not enough memory, so I reported this error. The solution is very simple, just add the --disable-fileinfo parameter when configure.
PHP reported that the mysql service cannot be found
As it said, it was indeed not found. Take a look at the pdo_mysql.default_socket item in phpinfo
Where is mysql.sock? Let’s take a look at the real location of mysql.sock. Use the command: ps -ef|grep mysql to view:
Obviously not in the same location, my correct location is: /var/lib/mysql/mysql.sock
So, modify php.ini, find pdo_mysql.default_socket, change it to your actual location, and restart php-fpm. Unfortunately, although php.ini has this configuration, after modification, it does not work. It is best to compile When , specify the location of mysql.socket:
--with-mysql-sock=/var/lib/mysql/mysql.sock
If that still doesn’t work, you can create a soft link to mysql.sock in the /tmp directory:
<span style="color: #0000ff;">ln</span> -s /var/lib/mysql/mysql.sock mysql.sock
Restart php-fpm again, I believe it is running normally. If you need more libraries supported by PHP, you can compile again and add the required support when configure, which is --with-xxx. Remember that if it is a third-party library, you must install these libraries first.

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.
