PHP安装
LNMP架构安装PHP需要开启php-fpm服务。
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.6.31.tar.gz
tar zxvf php-5.6.31.tar.gz
useradd -s /sbin/nologin php-fpm
cd php-5.6.31
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-socket=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
make && make install
cp php.ini-production /usr/local/php-fpm/etc/php.ini
vim /usr/local/php/etc/php-fpm.conf //写入如下内容
[global] pid = /usr/local/php-fpm/var/run/php-fpm.pid error_log = /usr/local/php-fpm/var/log/php-fpm.log [www] listen = /tmp/php-fcgi.sock listen.mode = 666 user = php-fpm group = php-fpm pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 rlimit_files = 1024
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
chkconfig php-fpm on 将php-fpm服务加入开机启动
[root@localhost php-5.6.31]# chkconfig --list
mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关 netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关 network 0:关 1:关 2:开 3:开 4:开 5:开 6:关 php-fpm 0:关 1:关 2:开 3:开 4:开 5:开 6:关
13 . /usr/local/php-fpm/sbin/php-fpm -t 检查php-fpm语法错误
[root@localhost php-5.6.31]# /usr/local/php-fpm/sbin/php-fpm -t [19-Oct-2017 09:44:49] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful
14 . service php-fpm start //启动服务
[root@localhost php-5.6.31]# service php-fpm start Starting php-fpm done
15 . ps aux | grep php-fpm //查看进程
[root@localhost php-5.6.31]# ps aux |grep php-fpm root 34095 0.0 0.3 123556 4944 ? Ss 09:44 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf) php-fpm 34096 0.0 0.3 123556 4708 ? S 09:44 0:00 php-fpm: pool www php-fpm 34097 0.0 0.3 123556 4708 ? S 09:44 0:00 php-fpm: pool www php-fpm 34098 0.0 0.3 123556 4708 ? S 09:44 0:00 php-fpm: pool www php-fpm 34099 0.0 0.3 123556 4708 ? S 09:44 0:00 php-fpm: pool www php-fpm 34100 0.0 0.3 123556 4712 ? S 09:44 0:00 php-fpm: pool www php-fpm 34101 0.0 0.3 123556 4712 ? S 09:44 0:00 php-fpm: pool www php-fpm 34102 0.0 0.3 123556 4712 ? S 09:44 0:00 php-fpm: pool www php-fpm 34103 0.0 0.3 123556 4712 ? S 09:44 0:00 php-fpm: pool www php-fpm 34104 0.0 0.3 123556 4712 ? S 09:44 0:00 php-fpm: pool www php-fpm 34105 0.0 0.3 123556 4712 ? S 09:44 0:00 php-fpm: pool www php-fpm 34106 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34107 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34108 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34109 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34110 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34111 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34112 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34113 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34114 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www php-fpm 34115 0.0 0.3 123556 4716 ? S 09:44 0:00 php-fpm: pool www root 34119 0.0 0.0 112680 976 pts/0 R+ 09:45 0:00 grep --color=auto php-fpm
16 . 查看php-fpm状态
[root@load-balancer ~]# systemctl status php-fpm ● php-fpm.service - LSB: starts php-fpm Loaded: loaded (/etc/rc.d/init.d/php-fpm; bad; vendor preset: disabled) Active: active (running) since 四 2017-11-30 09:37:01 HKT; 1h 28min ago Docs: man:systemd-sysv-generator(8) CGroup: /system.slice/php-fpm.service ├─2463 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf) ├─2464 php-fpm: pool www ├─2465 php-fpm: pool www ├─2466 php-fpm: pool www ├─2467 php-fpm: pool www ├─2468 php-fpm: pool www ├─2469 php-fpm: pool www ├─2470 php-fpm: pool www ├─2471 php-fpm: pool www ├─2472 php-fpm: pool www ├─2473 php-fpm: pool www ├─2474 php-fpm: pool www ├─2475 php-fpm: pool www ├─2476 php-fpm: pool www ├─2477 php-fpm: pool www ├─2478 php-fpm: pool www ├─2479 php-fpm: pool www ├─2480 php-fpm: pool www ├─2481 php-fpm: pool www ├─2482 php-fpm: pool www └─2483 php-fpm: pool www 11月 30 09:37:01 load-balancer systemd[1]: php-fpm.service: control process exited, code=exited status=1 11月 30 09:37:01 load-balancer systemd[1]: Unit php-fpm.service entered failed state. 11月 30 09:37:01 load-balancer systemd[1]: php-fpm.service failed. 11月 30 09:37:01 load-balancer systemd[1]: Starting LSB: starts php-fpm... 11月 30 09:37:01 load-balancer php-fpm[2460]: Starting php-fpm done 11月 30 09:37:01 load-balancer systemd[1]: Started LSB: starts php-fpm.
php 编译安装中出现的一些报错及解决办法
1 checking for cc... no checking for gcc... no configure: error: in `/usr/local/src/php-5.6.31': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details >[root@load-balancer php-5.6.31]# yum install -y gcc 2 checking libxml2 install dir... yes checking for xml2-config path... configure: error: xml2-config not found. Please check your libxml2 installation. >[root@load-balancer php-5.6.31]# yum install -y libxml2-devel 3 configure: error: Cannot find OpenSSL's <evp.h> >[root@load-balancer php-5.6.31]# yum install -y openssl-devel 4 checking for cURL in default path... not found configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/ >[root@load-balancer php-5.6.31]# yum install -y libcurl-devel 5 configure: error: jpeglib.h not found. >>[root@load-balancer php-5.6.31]# yum install -y libjpeg-turbo-devel 6 configure: error: png.h not found. >[root@load-balancer php-5.6.31]# yum install -y libpng-devel 7 configure: error: freetype-config not found. >[root@load-balancer php-5.6.31]# yum install -y freetype-devel 8 checking for mcrypt support... yes configure: error: mcrypt.h not found. Please reinstall libmcrypt. >>yum install -y epel-release //未安装epel扩展包的需要先安装epel包 >yum install -y libmcrypt-devel