centos7 编译php环境记录

in 日常随笔学习笔记 with 0 comment 访问: 110 次

安装编译工具

yum -y install gcc gcc-c++ autoconf automake make

安装依赖

yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel pcre-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel sqlite-devel libsqlite3-dev oniguruma-devel

下载安装包

wget http://php.net/distributions/php-7.4.0.tar.gz
tar -zxvf php-7.4.0.tar.gz
cd php-7.4.0

创建用户组

groupadd www
useradd -g www www

编译参数

根据自己需求更改--prefix--with-config-file-path

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --enable-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm --enable-mbstring
make
make install

文件配置修改与路径

/usr/local/php/etc
/usr/local/php/bin/php
/usr/local/php/sbin/php-fpm
cp php.ini.develop php.ini
cp php-fpm.conf.default php-fpm.conf
cp www.conf.default www.conf

注意 php-fpm.conf 中的pid记得要打开配置好,比如我的pid = /usr/local/php/var/run/php-fpm.pid

查看状态

ps aux | grep php-fpm

重启

killall php-fpm
/usr/local/php/bin/php-fpm

安装其他扩展

在编译的过程中我发现加了--enable-mbstring参数会报错,于是决定先安装其他扩展,回过头再单独安装,但是总是编译报错,后来发现是没有make clean:

  1. make clean
  2. 进入源码的ext/mbstring/目录
  3. 执行/usr/local/php/bin/phpize生成configure
  4. ./configure --with-php-config=/usr/local/php/bin/php-config
  5. make && make install
  6. 在php.ini中添加extension=mbstring(extension_dir用默认的就行)

nginx

根据实际情况选择nginx版本下载源码

根据自己需求更改--prefix 以及其他参数

wget http://nginx.org/download/nginx-1.17.9.tar.gz
tar zxvf nginx-1.17.9.tar.gz
./configure --prefix=/usr/local/nginx --user=www --group=www
make
make install

启动和停止

/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx -s stop
killall nginx

mysql8.0 (yum 安装)

wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum update
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
yum list mysql
yum -y install mysql-community-server
systemctl start mysqld
grep 'temporary password' /var/log/mysqld.log
msyql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your passowrd';
FLUSH PRIVILEGES;
create user 'litblc'@'%' identified by 'your pwd';
grant all privileges on fmock.* to 'litblc'@'%' with grant option;
vi /etc/my.cnf
default_authentication_plugin=mysql_native_password

相关文章Centos7 mini 配置 php7+nginx+mysql 最详细过程,为linux小白送福利

赞赏支持
Responses