10-29 15:08 php nginx 技巧 centos8安装php7.4 #### 安装依赖 ```shell yum config-manager --set-enabled PowerTools yum install 'dnf-command(config-manager)' yum -y install gcc gcc-c++ yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel freetype-devel openldap-devel openldap openldap-devel yum install sqlite-devel yum -y install oniguruma oniguruma-devel yum install libxslt libxslt-devel ``` #### 下载php 打开[官网](https://www.php.net/ "官网")选择相应的版本。 `wget https://www.php.net/distributions/php-7.4.11.tar.gz` #### 编译安装 创建/usr/lib目录`cp -frp /usr/lib64/libldap* /usr/lib/` ```shell ./configure --prefix=/usr/local/php \ --enable-fpm \ --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --enable-mysqlnd-compression-support \ --with-iconv-dir \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir \ --enable-xml \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --enable-mbregex \ --enable-mbstring \ --enable-intl \ --with-mcrypt \ --with-libmbfl \ --enable-ftp \ --with-gd \ --enable-gd-jis-conv \ --enable-gd-native-ttf \ --with-openssl \ --with-mhash \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --with-gettext \ --disable-fileinfo \ --enable-opcache \ --with-pear \ --enable-maintainer-zts \ --with-ldap=shared \ --without-gdbm ``` (参数具体介绍 见`./configure --help`) `make && make install` #### 设置全局变量 ```shell ls -s /usr/local/php/bin/* /usr/local/bin/ ls -s /usr/local/php/sbin/* /usr/local/sbin/ ``` ### 生成php.ini 编译安装PHP的时候,一般不会自动生成`php.ini`文件的,所以需要我们手动生成。 使用命令`php --ini`查看存放目录。然后将源码包中的配置文件(php.ini-production或php.ini-development)拷贝到该目录下重命名为`php.ini`即可。 #### 启动php-fpm ```shell cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf php-fpm ```