Table of Contents
PHP installation configuration
Add epel source
Installation dependencies
About php configuration
Home Backend Development PHP Problem How to compile and install php5.6.31

How to compile and install php5.6.31

Jan 21, 2022 am 10:42 AM
centos

How to compile and install php5.6.31: 1. Add epel source; 2. Install dependencies; 3. Download and decompress php5.6.31; 4. Modify php-fpm.conf; 5. Start php-fpm. Can.

How to compile and install php5.6.31

The operating environment of this article: CentOS 7 system, php version: 5.6.31 nginx version: 1.7.3 mysql version: 5.6.62, DELL G3 computer

How to compile and install php5.6.31?

CentOS 7 Compile and install PHP5.6.31:

There are already nginx and mysql on the server, so I decided to use PHP Nginx mysql For this combination, I read a lot of information on the Internet. Since I don’t know much about Linux and PHP, and I don’t know how PHP is related to nginx and mysql, I encountered various reasons (either PHP was installed incorrectly, or the package was not installed), It took a lot of time, but after the deployment, I found that these three are installed separately (well~~ can they be installed together), you only need to configure PHP after installation, and configure nginx (associated with PHP). Ran. As for mysql, as long as it is turned on and the connection database in the php project is configured, you can connect directly. So this article mainly focuses on the installation of php.

Regarding the installation of nginx and mysql, some development libraries for Linux need to be installed before starting the installation. I will not repeat them here. They are all in the reference link.

PHP installation configuration

nginx itself cannot handle PHP. It is just a WEB server. When a request is received, if it is a PHP request, it is sent to the PHP interpreter for processing and the result is returned. to the client.

nginx generally sends the request to the fastcgi management process for processing. The fastcgi management process selects the cgi sub-process processing result and returns it to nginx.

What is PHP-FPM? PHP-FPM is a FASTCGI manager for PHP. It is only used for PHP. The new version has integrated php-fpm. php-fpm provides better php process management, can effectively control memory and processes, and can smoothly reload php configuration. . When configuring, you can enable php-fpm with the -enable-fpm parameter. Other parameters can be found here. As for what fastcgi is and its relationship with php-fpm, please refer to the link https://segmentfault.com/q/1010000000256516

Preparation before installation

Add epel source

1

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Copy after login

Installation dependencies

1

2

3

4

5

yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-develyum -y install gcc gcc-c++ glibcyum -y install libmcrypt-devel mhash-devel libxslt-devel \

libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \

zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \

ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \

krb5 krb5-devel libidn libidn-devel openssl openssl-devel

Copy after login

Downloadphp-5.6.31

1) Unzip the installation package to /usr/local/src

1

cd /usr/local/srctar -zvxf php-5.6.31.tar.gz

Copy after login

2) Enter the installation directory, Installation

1

cd php-5.6.31./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt \--enable-mbstring --enable-pdo --with-curl --disable-debug  --disable-rpath \--enable-inline-optimization --with-bz2  --with-zlib --enable-sockets \--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \--with-gd --with-jpeg-dir --with-freetype-dir --enable-calendarmake && make install

Copy after login

1

CentOS 中下载php: wget http://php.net/get/php-5.6.30.tar.gz/from/this/mirror

Copy after login

The above completes the installation of php-fpm. The installation process will take some time.

About php configuration

1. Provide configuration files for php

1

cp php.ini-production /usr/local/php/etc/php.ini

Copy after login

Note: php.ini-production is still in /usr/local/src/php-5.6. 31 directory

2. Provide configuration file for php-fpm

1

2

cd /usr/local/phpcp etc/php-fpm.conf.default etc/php-fpm.conf

vim etc/php-fpm.conf

Copy after login

Modify php-fpm.conf

1

2

user = www

group = www

Copy after login

If the www user does not exist, add the www user first ( The default running user is nobody)

1

2

groupadd www

useradd -g www www

Copy after login

If this step is not configured, the browser will report an error when opening the php file

"The page you are looking for is temporarily unavailable . Please try again later”

Modify

1

2

3

4

5

pm.max_children = 150

pm.start_servers = 8

pm.min_spare_servers = 5

pm.max_spare_servers = 10

pid = /usr/local/php/var/run/php-fpm.pid

Copy after login

3. Start php-fpm

Execute

1

/usr/local/php/sbin/php-fpm

Copy after login

Use the following command to verify ( If there are several php-fpm processes in the output of this command, it means the startup is successful):

1

ps aux | grep php-fpm

Copy after login

The result is as shown below:

3, nginx and php -fpm integration

Edit nginx configuration file

1

vim /usr/local/nginx/conf/nginx.conf

Copy after login

The initial content is as follows:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

# nginx运行的用户名

user nginx;

# nginx启动进程,通常设置成和cpu的数量相等,这里为自动

worker_processes auto;

 

# errorlog文件位置

error_log /var/log/nginx/error.log;

# pid文件地址,记录了nginx的pid,方便进程管理

pid /run/nginx.pid;

 

# Load dynamic modules. See /usr/share/nginx/README.dynamic.

# 用来加载其他动态模块的配置

include /usr/share/nginx/modules/*.conf;

 

# 工作模式和连接数上限

events {

    # 每个worker_processes的最大并发链接数

    # 并发总数:worker_processes*worker_connections

    worker_connections 1024;

}

 

# 与提供http服务相关的一些配置参数类似的还有mail

http {

    # 设置日志的格式

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

 

    # access_log记录访问的用户、页面、浏览器、ip和其他的访问信息

    access_log  /var/log/nginx/access.log  main;

 

    # 这部分下面会单独解释

    # 设置nginx是否使用sendfile函数输出文件

    sendfile            on;

    # 数据包最大时发包(使用Nagle算法)

    tcp_nopush          on;

    # 立刻发送数据包(禁用Nagle算法)

    tcp_nodelay         on;

    # 链接超时时间

    keepalive_timeout   65;

    # 这个我也不清楚...

    types_hash_max_size 2048;

 

    # 引入文件扩展名与文件类型映射表

    include             /etc/nginx/mime.types;

    # 默认文件类型

    default_type        application/octet-stream;

 

    # Load modular configuration files from the /etc/nginx/conf.d directory.

    # See http://nginx.org/en/docs/ngx_core_module.html#include

    # for more information.

    include /etc/nginx/conf.d/*.conf;

 

    # http服务上支持若干虚拟主机。

    # 每个虚拟主机一个对应的server配置项

    # 配置项里面包含该虚拟主机相关的配置。

    server {

        # 端口

        listen       80 default_server;

        listen       [::]:80 default_server;

        # 访问的域名

        server_name  _;

        # 默认网站根目录(www目录)

        root         /usr/share/nginx/html;

 

        # Load configuration files for the default server block.

 

        include /etc/nginx/default.d/*.conf;

 

        # 默认请求

        location / {

        }

 

        # 错误页(404)

        error_page 404 /404.html;

            location = /40x.html {

        }

 

        # 错误页(50X)

        error_page 500 502 503 504 /50x.html;

            location = /50x.html {

        }

    }

}

Copy after login

We only need to change the configurationserver## The # part is fine. Enter vim editing mode, or use FlashFXP to share the configuration file to the desktop to make changes.

Only three changes are needed

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

server {

        listen       80 default_server;

        listen       [::]:80 default_server;

        # 这里改动了,也可以写你的域名,我用的是IP地址

        server_name  192.168.0.222;

        root         /usr/share/nginx/html;

 

        # Load configuration files for the default server block.

        include /etc/nginx/default.d/*.conf;

 

        location / {

            # 这里改动了 定义首页索引文件的名称

            index index.php index.html index.htm;

        }

 

        error_page 404 /404.html;

            location = /40x.html {

        }

 

        error_page 500 502 503 504 /50x.html;

            location = /50x.html {

        }

 

        # 这里新加的

        # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI协议默认配置.

        # Fastcgi服务器和程序(PHP,Python)沟通的协议.

        location ~ \.php$ {

            # 设置监听端口

            fastcgi_pass   127.0.0.1:9000;

            # 设置脚本文件请求的路径

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            # 引入fastcgi的配置文件

            include        fastcgi_params;

        }

    }

Copy after login

Restart the nginx server

1

nginx -s reload

Copy after login

At this time, nginx and php have been jointly configured, but we do not know the actual configuration effect How about, at this time we can write a small test script to verify it.

As mentioned before, /usr/share/nginx/html is the root directory of Nginx website. We can create a php test script in this directory.

# phpinfo.php is the name of the file I want to create

1

vi /usr/share/nginx/html/phpinfo.php

Copy after login

After opening the editor, enter

1

2

<?php

phpinfo();// 测试信息?>

Copy after login
After saving and exiting, enter http in the browser: //192.168.0.222/phpinfo.php, my IP here is 192.168.0.222, you can change it to your own. As shown in the figure, an interface similar to the following appears:


Nginx and php have been configured.

4. Reasons for errors in the installation process

When I installed according to the process, an error occurred: mcrypt.h not found. Please reinstall libmcrypt

It is because php-mcrypt libmcrypt The libmcrypt-devel packages are not installed. The errors that occur are usually caused by missing libraries or packages. Just install them.

At this point, PHP has been configured. I wish you a smooth installation. By the way, I wish you all a Happy New Year in advance!

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to compile and install php5.6.31. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the backup methods for GitLab on CentOS What are the backup methods for GitLab on CentOS Apr 14, 2025 pm 05:33 PM

Backup and Recovery Policy of GitLab under CentOS System In order to ensure data security and recoverability, GitLab on CentOS provides a variety of backup methods. This article will introduce several common backup methods, configuration parameters and recovery processes in detail to help you establish a complete GitLab backup and recovery strategy. 1. Manual backup Use the gitlab-rakegitlab:backup:create command to execute manual backup. This command backs up key information such as GitLab repository, database, users, user groups, keys, and permissions. The default backup file is stored in the /var/opt/gitlab/backups directory. You can modify /etc/gitlab

How to optimize CentOS HDFS configuration How to optimize CentOS HDFS configuration Apr 14, 2025 pm 07:15 PM

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

Centos stops maintenance 2024 Centos stops maintenance 2024 Apr 14, 2025 pm 08:39 PM

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

How to check CentOS HDFS configuration How to check CentOS HDFS configuration Apr 14, 2025 pm 07:21 PM

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

Centos install mysql Centos install mysql Apr 14, 2025 pm 08:09 PM

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

Centos configuration IP address Centos configuration IP address Apr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

What are the common misunderstandings in CentOS HDFS configuration? What are the common misunderstandings in CentOS HDFS configuration? Apr 14, 2025 pm 07:12 PM

Common problems and solutions for Hadoop Distributed File System (HDFS) configuration under CentOS When building a HadoopHDFS cluster on CentOS, some common misconfigurations may lead to performance degradation, data loss and even the cluster cannot start. This article summarizes these common problems and their solutions to help you avoid these pitfalls and ensure the stability and efficient operation of your HDFS cluster. Rack-aware configuration error: Problem: Rack-aware information is not configured correctly, resulting in uneven distribution of data block replicas and increasing network load. Solution: Double check the rack-aware configuration in the hdfs-site.xml file and use hdfsdfsadmin-printTopo

See all articles