1.从PHP官网(http://cn2.php.net) 下载,我在此选择7.1.3版本。
先 yum install freetype*
freetype库是三方库,需要单独安装,如果系统中已经安装则无需安装
查看命令:
1
rpm -ip freetype
或
1
whereis freetype
下载地址: https://www.freetype.org/download.html
最好使用.net域名下的,.org很容易造成超时。
这里以:
https://sourceforge.net/projects/freetype/files/freetype2/2.7.1/freetype-2.7.1.tar.gz/download
为例:
1
2
3
4
5
tar -zxf freetype-2.7.1.tar.gz
cd freetype-2.7.1/builds/unix
./configure --prefix=/usr/local/freetype/2.7.1 --without-harfbuzz
make
make install
说明:如果不进入builds/unix目录下编译会提示:make: Nothing to be done for `unix'. 当然也没有什么影响。
安装freetype需要包:
external bzip2 libpng harfbuzz
groupadd www
useradd -g www www
2.安装之前需要安装依赖包,我这里直接用yum安装。
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN pcre-devel --enable-maintainer-zts
yum install php-mcrypt libmcrypt libmcrypt-devel
yum -y install libxslt libxslt-devel
3.装完依赖包后进入PHP目录用./configure --help查看安装选项,我在这里用
./configure --prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --with-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-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
然后执行make,make install。 执行 #whereis php出现内容代表成功。 cp php.ini-production /usr/local/php/etc/php.ini 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
4.设置启动服务
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
chkconfig --list php-fpm
5.添加php全局变量 使用Vim打开~/.bashrc,在末尾添加如下内容: export PATH=/usr/local/php/bin:$PATH export PATH=/usr/local/php/sbin:$PATH 保存退出执行 source ~/.bashrc 6.配置PHP与nginx 编辑php.ini文件,找到 ;cgi.fix_pathinfo=1 去掉前面的分号,将1改为0,保存退出。 编辑nginx.conf文件 server { listen 80; server_name localhost; #自己的网站 #charset koi8-r; #access_log logs/host.access.log main; location / { root html; #项目地址 index index.php index.html index.htm; }
找到下面模块,去掉前面的#号,将/scripts改为“$document_root”,这里的“$document_root”就是指前面“root”所指的站点路径 #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} 重启nginx和PHP服务。
--prefix=/usr/local/php \ [php安装的根目录] --exec-prefix=/usr/local/php \ [php执行文件所在目录] --bindir=/usr/local/php/bin \ [php/bin目录] --sbindir=/usr/local/php/sbin \ [php/sbin目录] --includedir=/usr/local/php/include \ [php包含文件所在目录] --libdir=/usr/local/php/lib/php \ [php/lib目录] --mandir=/usr/local/php/php/man \ [php/man目录] --with-config-file-path=/usr/local/php/etc \ [php的配置目录] --with-mysql-sock=/tmp/mysql.sock \ [php的Unix socket通信文件] --with-mcrypt \ [是php里面重要的加密支持扩展库,linux环境下该库在默认情况下不开启] --with-mhash \ [Mhash是基于离散数学原理的不可逆向的php加密方式扩展库,其在默认情况下不开启] --with-openssl \ [OpenSSL 是一个安全套接字层密码库] --with-mysqli=shared,mysqlnd \ [php依赖mysql库] --with-pdo-mysql=shared,mysqlnd \ [php依赖mysql库] --with-gd \ [gd库] --with-iconv \ [关闭iconv函数,种字符集间的转换] --with-zlib \ [zlib是提供数据压缩用的函式库] --enable-zip \ [打开对zip的支持] --enable-inline-optimization \ [优化线程] --disable-debug \ [关闭调试模式] --disable-rpath \ [关闭额外的运行库文件] --enable-shared \ [启用动态库] --enable-xml \ [开启xml扩展] --enable-bcmath \ [打开图片大小调整,用到zabbix监控的时候用到了这个模块] --enable-shmop \ [共享内存] --enable-sysvsem \ [内存共享方案] --enable-mbregex \ [开启多字节正则表达式的字符编码。] --enable-mbstring \ [开启多字节字符串函数] --enable-ftp \ [开启ftp] --enable-gd-native-ttf \ [开启gd库原有字体] --enable-pcntl \ [PHP的进程控制支持实现了Unix方式的多进程创建] --enable-sockets \ [开启套节字] --with-xmlrpc \ [打开xml-rpc的c语言] --enable-soap \ [开启简单对象访问协议简单对象访问协议] --without-pear \ [开启php扩展与应用库] --with-gettext \ [开户php在当前域中查找消息] --enable-session \ [允许php会话session] --with-curl \ [允许curl扩展] --with-openssl \ [允许openssl 扩展 下载composer 会用到] --with-jpeg-dir \ [指定jpeg安装目录yum安装过后不用再次指定会自动找到] --with-freetype-dir \ [指定freetype安装目录yum安装过后不用再次指定会自动找到] --enable-opcache \ [开启使用opcache缓存] --enable-fpm \ [开启fpm] --with-fpm-user=nginx \ [php-fpm的用户] --with-fpm-group=nginx \ [php-fpm的用户组] --without-gdbm \ [数据库函数使用可扩展散列和类似于标准UNIX dbm的工作] --enable-fast-install \ [为快速安装优化] --disable-fileinfo
