CentOS編譯安裝PHP和nginx

2021-08-28 14:53:58 字數 2930 閱讀 1325

hash -r清除快取,然後執行cmake --version

將阿里雲的伺服器重置了,嘗試使用編譯安裝php

1.先更新yum,安裝依賴

yum install epel-release -y

yum update

2.安裝php的依賴,nginx的依賴(直接去網上搜的 )
yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel

wgt 

tar -zxvf php-7.2.10

4.編譯安裝
cd php-7.2.10

./configure --prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \

--enable-fpm \

--with-fpm-user=www \

--with-fpm-group=www \

--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 \

make && make install
安裝完成後, php的檔案應該是在/user/local/php/這個資料夾下

開發環境:

--enable-phpdbg\

--enable-dtrace\

生產環境:

--disable-phpdbg\

--disable-dtrace\

5.php配置檔案
php.ini-development     //測試開發環境

php.ini-production //生產環境

//自己選乙個複製到php的etc目錄下

cp php.ini-production /usr/local/php/etc/php.ini

//複製並改名

cd /user/local/php/etc

cp php-fpm.conf.default php-fpm.conf

cd usr/local/php/etc/php-fpm.d

cp www.conf.default www.conf

cd /php-7.2.10

cp ./sapi/fpm/php-fpm.service 到 /usr/lib/systemd/system/下

Centos6 編譯安裝PHP

採用原始碼安裝,可自由定製所需要的php功能模組,提高效能,也可以降低bug的發生。當然,什麼功能都不開就更安全了!安裝環境 centos6.5 x86 64最小化安裝。安裝依賴包,其中有部分軟體是由epel提供,所以要新增epel源sudo yum install gcc gcc c libxml...

centos編譯安裝PHP7

在php.net中找到最新穩定版php原始碼 這裡我選擇了最新版php 7.1.9 wget php.tar gz net get php 7.1 9.tar gz from this mirror tar xzvf php.tar gzcd php 2 配置php 解壓了php原始碼之後,我們需要...

centos編譯安裝php7

yum y install openssl openssl devel curl curl devel libjpeg libjpeg devel libpng libpng devel freetype freetype devel pcre pcre devel libxslt libxslt ...