php安装
yum install -y bzip2 systemd-devel libxml2-devel sqlite-devel libpng-devel libcurl-devel
yum install -y oniguruma-6.8.2-1.el7.x86_64.rpm oniguruma-devel-6.8.2-1.el7.x86_64.rpm //企业八须自行下载软件包
tar xf php-7.4.12.tar.bz2
cd php-7.4.12
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --with-iconv --with-mhash --with-zlib --with-openssl --enable-mysqlnd --with-mysqli --with-pdo-mysql --disable-debug --enable-sockets --enable-soap --enable-inline-optimization --enable-xml --enable-ftp --enable-gd --enable-exif --enable-mbstring --enable-bcmath --with-fpm-systemd
make
make install
php配置
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
去掉注释
pid = run/php-fpm.pid //指定pid文件位置
cd php-fpm.d/
cp www.conf.default www.conf
拷贝主配置文件
cd php-7.4.12/
cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/php/etc/php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Aisa/Shanghai //修改时区
cd sapi/fpm
cp php-fpm.service /usr/lib/systemd/system
vim /usr/lib/systemd/system/php-fpm.service
注释此行
#ProtectSystem=full
当设置为 full 时,Systemd 将会以只读模式挂载 /usr 和 /boot 等系统文件系统,并且禁止任何对这些文件系统的写入操作,以避免系统文件被意外地修改。
systemctl daemon-reload
systemctl start php-fpm.service
netstat -antlp|grep :9000
nginx与php整合
cd /usr/local/nginx/conf/
vim nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000; //将请求运发到本机9000端口
fastcgi_index index.php; //默认索引
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; //将 PHP 的脚本文件名传递给 FastCGI 服务器
include fastcgi.conf; //配置文件
}
php动态扩展模块
添加php环境变量
vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/php/bin
export PATH
source .bash_profile
编译memcahe模块
tar xf memcache-4.0.5.2.tgz
cd memcache-4.0.5.2/
yum install -y autoconf
phpize
./configure
make
make install
cd /usr/local/php/etc
vim php.ini
extension=memcache #添加memcache模块
cp example.php memcache.php /usr/local/nginx/html/
yum install -y memcached
systemctl enable --now memcached
netstat -antlp|grep :11211
cd /usr/local/nginx/html/
vim memcache.php
$VERSION='$Id$';
define('ADMIN_USERNAME','admin'); // Admin Username
define('ADMIN_PASSWORD','westos'); // Admin Password
define('DATE_FORMAT','Y/m/d H:i:s');
define('GRAPH_SIZE',200);
define('MAX_ITEM_DUMP',50);
$MEMCACHE_SERVERS[] = 'localhost:11211'; // add more as an array
#$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array
访问
输入刚刚的用户名密码