PHP安装
网站下载压缩包:http://cn2.php.net/distributions/php-7.2.0.tar.gz 上传镜像
切换目录:cd /usr/local/src
解压:tar –zxvf /root/php -7.2.0.tar.gz(可以用tab键补全)
安装与配置:
yum install -y libxml2-devel
yum install -y openssl openssl-devel
yum install -y bzip2 bzip2-devel
yum install -y libpng libpng-devel
yum install -y freetype freetype-devel
yum install -y epel-release
yum install -y libmcrypt-devel
yum -y install libjpeg-devel
yum install -y libcurl-devel
useradd -s /sbin/nologin php-fpm
切换目录:cd php-7.2.0/
以下内容是一条命令:
./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-mysql-sock=/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 --disable-ipv6 --with-pear --with-curl --with-openssl
make && make install
复制:cp php.ini-production /usr/local/php-fpm/etc/php.ini
修改配置文件:vi /usr/local/php-fpm/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
/usr/local/php-fpm/sbin/php-fpm –t(后面有test is successful 表示成功)
复制:cp /usr/local/src/php-7.2.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
赋权:chmod 755 /etc/init.d/php-fpm
useradd -s /sbin/nologin php-fpm(如果显示以下情况表示已经存在)
启动服务:service php-fpm start
设置自动开启服务:chkconfig php-fpm on
查看php带有的所有服务:ps aux |grep php-fpm
systemctl status php-fpm (如果出错就用下一条命令或用systemctl start php)
表示出错
表示正确
service php-fpm status(如下表示正确)