PHP environment installation

PHP environment installation

PHP language concept address:
First of all, to create a new virtual machine, we use CentOS-7-x86_64-DVD-1511 by default.
Mirror address:
link: https://pan.baidu.com/s/1Myl_GXnUg7t3OR01mCuMrQ
extraction code: 1511

①Install virtual machine, configure ip, yum source

Install virtual machine, configure ip, configure yum source address tutorial

②Modify the host name

Here we set the host name as php

[root@localhost /]# hostnamectl set-hostname php (modify the hostname)
[root@localhost /]# bash (refresh the shell command line)
[root@php /]# su-(log in again)
[root@php ~] # hostnamectl (View host information)

Insert picture description here

③Close the firewall and SELinux service

Firewall and SELinux opening and closing tutorial

[root@php ~]# setenforce 0 (settings off, 1 on, 0 off)
[root@php ~]# systemctl stop firewalld (turn off the firewall)
[root@php ~]# getenforce (view process Enforcing is on, Permissive is off)
Permissive

Install and configure basic services

[root@php ~]# yum -y install gcc gcc-c++ libxml2-devel libcurl-devel openssl-devel bzip2-devel (install the required compiler)

Use the file transfer tool (the blogger uses xftp) to put the libmcrypt installation package in the /usr/local/src directory. The
link to the libmcrypt installation package (here we use the version libmcrypt-2.5.8.tar.gz):
link : Https://pan.baidu.com/s/1kEF881Gy5QvpAYAafTRj7Q
Extraction code: 2580

[root@php ~]# cd /usr/local/src/  (进入目录)
[root@php src]# ls      (查看当前目录列表)
libmcrypt-2.5.8.tar.gz
[root@php src]# tar -zxvf libmcrypt-2.5.8.tar.gz    (解压)
[root@php libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt && make && make install    (编译安装)

Install PHP environment

Put the PHP installation package in the /usr/local/src directory with a file transfer tool (xftp) in advance using a file transfer tool (
here we use the version php-5.6.27.tar.gz):
link : Https://pan.baidu.com/s/10GWA0Q0rfcszFulE-iVhAA
Extraction code: 5627

[root@php src]# ls
libmcrypt-2.5.8  libmcrypt-2.5.8.tar.gz  php-5.6.27.tar.gz
[root@php src]# tar -zxvf php-5.6.27.tar.gz    (解压PHP安装包)
[root@php src]# cd php-5.6.27
(运行下面这个超长命令)
[root@php src]# ./configure --prefix=/usr/local/php5.6 --with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm \
--enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir \
--with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash \
--with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts

If there is no error, you can compile and install

[root@php php-5.6.27]# make && make install (compile and install)

Insert picture description here
Wait a long time here, wait for the installation to complete

Create user ID

[root@php php-5.6.27]# groupadd -g 1001 nginx  (配置指定所属组)
[root@php php-5.6.27]# useradd -u 900 nginx -g nginx -s /sbin/nologin    (配置指定用户组)
[root@php php-5.6.27]# tail -l /etc/passwd    (查看信息)

Insert picture description here

Configure PHP environment

[root@php php-5.6.27]# cp php.ini-production /etc/php.ini       (对文件重名名)
[root@php php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm     (对文件重命名)
[root@php php-5.6.27]# chmod +x /etc/init.d/php-fpm   (赋予文件执行权限)
[root@php php-5.6.27]# chkconfig --add php-fpm   (添加PHP服务到启动列表)
[root@php php-5.6.27]# chkconfig php-fpm on   (设置开机自启)
[root@php php-5.6.27]# cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf   (对文件重命名)

Modify the configuration file

[root@php php-5.6.27]# grep -n'^'[aZ] /usr/local/php5.6/etc/php-fpm.conf
(This command is used to view the places that need to be modified, the following figure shows Just need to be modified)

Insert picture description here

[root@php php-5.6.27]# vi /usr/local/php5.6/etc/php-fpm.conf
(Refer to the following to modify the configuration file)
25 (line): pid = run/php-fpm.pid
149 (line): user = nginx
150 (line): group = nginx
164 (line): listen= 192.168.128.144:9000 # (192.168.128.144 is the virtual machine ip)
224 (line): pm = dynamic
235 (line ): pm.max_children= 50
240 (line): pm.start_servers = 5
245 (line): pm.min_spare_servers = 5
250 (line): pm.max_spare_servers = 35

Start the PHP service

[root@php php-5.6.27]#  yum -y install net-tools  (安装该工具)
[root@php php-5.6.27]# service php-fpm start   (启动PHP服务)
Starting php-fpm  done
[root@php php-5.6.27]# netstat -ntpl   (查看端口)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 192.168.128.144:9000    0.0.0.0:*               LISTEN      15527/php-fpm: mast 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1455/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2613/master         
tcp6       0      0 :::22                   :::*                    LISTEN      1455/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      2613/master         

There is port 9000, indicating that the PHP configuration is successful

Guess you like

Origin blog.csdn.net/planetoid_a/article/details/108981915