How to start Linux PHP source code installation: 1. Download the PHP source code and unzip the file package; 2. Install dependencies, compile and install; 3. Configure PHP; 4. Set environment variables; 5. Start PHP testing .
The operating environment of this article: linux5.9.8 system, PHP7.1.4 version, DELL G3 computer
How to install and start the linux php source code ?
#php source code installation steps under linux
1. Download the php source code
Download address: http://cn.php. net/downloads.php
2. Installation
1. Move the downloaded binary package to the /usr/local directory and decompress the file package
tar zxvf php-7.1.4.tar.gz
2. Enter decompression /usr/local/php-7.1.4 in the php folder, install dependencies, compile and install
yum install libxml2 libxml2-devel ./configure --prefix=/usr/local/php --with-zlib --enable-zip --with-openssl --enable-fpm --enable-mbstring --with-libdir=lib64 --without-pear --disable-phar make make test (编译完后可以允许一下make test命令,检测编译是否有问题) make install
Summary information after the installation is completed:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ Installing PHP CLI binary: /usr/local/php/bin/ Installing PHP CLI man page: /usr/local/php/php/man/man1/ Installing PHP FPM binary: /usr/local/php/sbin/ Installing PHP FPM defconfig: /usr/local/php/etc/ Installing PHP FPM man page: /usr/local/php/php/man/man8/ Installing PHP FPM status page: /usr/local/php/php/php/fpm/ Installing phpdbg binary: /usr/local/php/bin/ Installing phpdbg man page: /usr/local/php/php/man/man1/ Installing PHP CGI binary: /usr/local/php/bin/ Installing PHP CGI man page: /usr/local/php/php/man/man1/ Installing build environment: /usr/local/php/lib/php/build/ Installing header files: /usr/local/php/include/php/ Installing helper programs: /usr/local/php/bin/ program: phpize program: php-config Installing man pages: /usr/local/php/php/man/man1/ page: phpize.1 page: php-config.1 Installing PDO headers: /usr/local/php/include/php/ext/pdo/
3, php configuration
#php的配置文件为 php.ini cp /usr/local/php-7.1.4/php.ini-production /usr/local/php/lib/php.ini #使得另一种方法来管理服务: cp /usr/local/php-7.1.4/sapi/fpm/php-fpm /etc/init.d/php-fpm #添加执行权限 chmod +x /etc/init.d/php-fpm #php-fpm的配置文件 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
Modify the maximum limit on the number of php-fpm processes according to the machine configuration, which is limited to /usr/local/php/etc/php-fpm.d/www.conf
Use netstat -napo |grep " php-fpm" | wc -l Check the current number of fastcgi processes. If the number is close to the upper limit configured in conf, you need to increase the number of processes.
But you can’t increase it endlessly. You can adjust the number of php-fpm sub-processes to 100 or more according to the server memory. On a server with 4G memory, 200 is enough.
pm.max_children = 200 pm.start_servers = 10 pm.min_spare_servers = 8 pm.max_spare_servers = 12
4. Set environment variables
vi /etc/profile
After opening, add the following configuration at the bottom of the document:
export PATH=/usr/local/php/bin:$PATH :wq!保存退出,执行如下命令,使更改生效 source /etc/profile
5. Start php test
#启动 /etc/init.d/php-fpm start #测试php cd /usr/local/nginx/html vi test.php
Add the following content:
<?php echo phpinfo(); ?>
:wq! Save and exit.
Browser input: http://10.62.32.123/test.php
If the PHP Version 7.1.4 interface appears, the detailed configuration interface of PHP is displayed, indicating that the installation is correct
6. Restart and stop php
php 7.1.4 The source code has already embedded php-fpm, you only need to add compilation parameters when configure.
The compilation parameters for php-fpm include –enable-fpm –with-fpm-user=www –with-fpm-group=www –with-libevent-dir=libevent location.
However, php-fpm under php 7.1.4 no longer supports commands such as /usr/local/php/sbin/php-fpm (start|stop|reload) that php-fpm previously had. You need to use Signal control:
The master process can understand the following signals:
SIGINT, SIGTERM Terminate immediately
SIGQUIT Terminate smoothly
SIGUSR1 Reopen the log file
SIGUSR2 Smoothly reload all worker processes and reload configuration and binary modules
Example:
php-fpm 关闭: kill -SIGINT `cat /usr/local/php/var/run/php-fpm.pid` php-fpm 重启: kill -SIGUSR2 `cat /usr/local/php/var/run/php-fpm.pid`
View the number of php-fpm processes:
ps aux | grep -c php-fpm netstat -anpo | grep "php-cgi" | wc -l netstat -anop | grep "php-fpm" | wc -l
3. Appendix
Instructions related to php compilation options:
./configure --prefix=/usr/local/php \ #指定安装目录 --with-config-file-path=/usr/local/php/etc \ #指定配置文件的目录,默认在php/lib下满\ --enable-fpm \启用php的fpm --enable-mbstring \ 启用多字节字符串支持 --with-libdir=lib64 \ --without-pear \禁用pear扩展 --disable-phar \ 禁用pear扩展的phar函数库 --enable-mysqlnd \ 启用php的mysql驱动 --with-mysqli=mysqlnd \ 指定mysql --with-pdo-mysql=mysqlnd \指定mysql
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to install and start linux php source code. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),