php+nginx环境搭建
PHP安装教程参考:https://www.cnblogs.com/kyuang/p/6801942.html
1、安装基础环境:
yum -y install gcc bison bison-devel zlib-devel libmcrypt-devel mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel gcc gcc-c++ glibc oniguruma oniguruma-devel
安装(下载地址:https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/)
快速部署安装:(安装位置:/usr/local/libmcrypt&&oniguruma)
cd /usr/local && wget https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz && tar -zxvf libmcrypt-2.5.8.tar.gz && cd libmcrypt-2.5.8/ && ./configure –prefix=/usr/local/libmcrypt && make && make install && cd .. && rm -rf libmcrypt-2.5.8 && rm -rf libmcrypt-2.5.8.tar.gz &&cd /usr/local/ &&wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz&&tar -zxf oniguruma-6.9.4.tar.gz &&cd oniguruma-6.9.4&&./autogen.sh && ./configure –prefix=/usr&&make && make install&&cd ..&&rm -rf oniguruma-6.9.4.tar.gz &&rm -rf oniguruma-6.9.4
3、安装php(下载地址:https://www.php.net/downloads.php)(安装位置:/usr/local/php)
cd /usr/local/ && wget https://www.php.net/distributions/php-7.4.30.tar.gz && tar -zxvf php-7.4.30.tar.gz && cd /usr/local/php-7.4.30 && ./configure -disable-fileinfo –prefix=/usr/local/php –with-curl –enable-zip –with-zlib –with-zlib-dir –enable-ftp –with-openssl –enable-mysqlnd –with-mysqli –with-pdo-mysql=mysqlnd –enable-mbstring –enable-fpm && make && make install &&cd .. &&rm -rf php-7.4.30.tar.gz
4、为php提供配置文件(在安装目录下拷贝配置文件放到:/usr/local/php/etc/)
cp /usr/local/php-7.4.30/php.ini-production /usr/local/php/etc/php.ini
5、为php-fpm提供配置文件
创建www用户,已有忽略:groupadd www && useradd -g www www
配置文件修改:(存放位置:/usr/local/php/etc/)
cd /usr/local/php/etc && cp php-fpm.conf.default php-fpm.conf && vim php-fpm.conf
在;pid = run/php-fpm.pid下方添加或解掉注释修改为:
pid = /usr/local/php/var/run/php-fpm.pid
cd /usr/local/php/etc/php-fpm.d && cp -r www.conf.default www.conf && vim www.conf
修改子配置内容:(目录在:/usr/local/php/etc/php-fpm.d/)
user = www #启动进程的帐户和组
group = www #启动进程的帐户和组
#测试php-fpm配置
/usr/local/php/sbin/php-fpm -t
/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf -t
#启动php-fpm
/usr/local/php/sbin/php-fpm
/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf
#查看php-fpm运行状态
ps -A | grep php-fpm
#查看9000端口占用情况
netstat -tunlp | grep 9000
延伸教程“通过启动脚本控制PHP-FPM开关”:(个别情况下能开不能关??)https://www.cnblogs.com/brad93/p/16700749.html
nginx安装:https://www.cnblogs.com/brad93/p/16620709.html