新买了台服务器,随便倒腾,记录一下。
如果既想获得 RHEL 的高质量、高性能、高可靠性,又需要方便易用(关键是免费)的软件包更新功能,那么 Fedora Project 推出的 EPEL(Extra Packages for Enterprise Linux)正好适合你。
EPEL 是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。
不用去换原来yum源,安装后会产生新repo
epel会有很多源地址,如果一个下不到,会去另外一个下
# yum search epel Loaded plugins: fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository epel is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: mirrors.cloud.aliyuncs.com * epel: mirrors.cloud.aliyuncs.com * extras: mirrors.cloud.aliyuncs.com * updates: mirrors.cloud.aliyuncs.com * webtatic: us-east.repo.webtatic.com ================================= N/S matched: epel ================================= epel-release.noarch : Extra Packages for Enterprise Linux repository configuration epel-rpm-macros.noarch : Extra Packages for Enterprise Linux RPM macros python3-pkgversion-macros.noarch : Convenience macros for Fedora/EPEL Python 3 : packages building Name and summary matches only, use "search all" for everything.
通过yum搜索的结果中epel-release.noarch就是我们需要的软件包。
安装可以不用包含软件包名称中点“.”后面的部分,当然包含也没有问题。点“.”后面的部分只是提供软件包适应系统架构。noarch为通用型,还有x86_64为64位的系统,i686为32位系统使用。
通过下面命令进行安装。
# yum install epel-release Loaded plugins: fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository epel is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: mirrors.cloud.aliyuncs.com * epel: mirrors.cloud.aliyuncs.com * extras: mirrors.cloud.aliyuncs.com * updates: mirrors.cloud.aliyuncs.com * webtatic: uk.repo.webtatic.com Package epel-release-7-9.noarch already installed and latest version Nothing to do
想知道epel-release这个包包含哪些内容,就使用rpm命令查询列出。-q 表示查询,-l 标识列出软件包的所包含的文件。
# rpm -ql epel-release /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel.repo /usr/lib/systemd/system-preset/90-epel.preset /usr/share/doc/epel-release-7 /usr/share/doc/epel-release-7/GPL
可以看出最主要的就是/etc/yum.repos.d/epel.repo这个文件了,默认已经启用。不确定的话可以用vi等命令查看编辑。
enabled=1
说明已经启用
启用之后就可安装EPEL源中提供的软件了。
通过使用yum install XXXXX
命令安装,会自动搜索所有可用的软件源,并提示可用的软件包。
# rpm -Uvh Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm Preparing... ################################# [100%] package webtatic-release-7-3.noarch is already installed
# yum install php71w
从这里获取所需版本的PHP的下载地址。
# wget -O php7.tar.gz url/get/from/last/step
# tar -xvf php7.tar.gz
# cd php-7.x.x
# 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
嫌麻烦的可以从这一步起参考PHP官方安装说明
# ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/etc \ --enable-fpm \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-soap \ --with-libxml-dir \ --with-xmlrpc \ --with-openssl \ --with-mcrypt \ --with-mhash \ --with-pcre-regex \ --with-sqlite3 \ --with-zlib \ --enable-bcmath \ --with-iconv \ --with-bz2 \ --enable-calendar \ --with-curl \ --with-cdb \ --enable-dom \ --enable-exif \ --enable-fileinfo \ --enable-filter \ --with-pcre-dir \ --enable-ftp \ --with-gd \ --with-openssl-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib-dir \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-gd-jis-conv \ --with-gettext \ --with-gmp \ --with-mhash \ --enable-json \ --enable-mbstring \ --enable-mbregex \ --enable-mbregex-backtrack \ --with-libmbfl \ --with-onig \ --enable-pdo \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir \ --with-pdo-sqlite \ --with-readline \ --enable-session \ --enable-shmop \ --enable-simplexml \ --enable-sockets \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-libxml-dir \ --with-xsl \ --enable-zip \ --enable-mysqlnd-compression-support \ --with-pear \ --enable-opcache
这里可能会报很多错误,一个个解决即可。这里有大部分的解决方法。
列出几个常见的
checking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir= configure: error: freetype.h not found. Fix: Reconfigure your PHP with the following option. --with-xpm-dir=/usr checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found. Fix: yum install libXpm-devel checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.h Fix: yum install gmp-devel
# make && make install
没有报错就表示安装完成。
# vi /etc/profile
在末尾追加
PATH=$PATH:/usr/local/php/bin export PATH
执行命令使得改动立即生效
# source /etc/profile
把所需的几个配置文件放到需要的位置
# cp php.ini-production /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/ # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # chmod +x /etc/init.d/php-fpm
# /etc/init.d/php-fpm start
# php -v PHP 7.1.4 (cli) (built: Apr 30 2017 11:20:19) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies # which php /usr/local/php/bin/php
connect() to unix:/var/run/php-fpm/php-fpm.sock failed (2: No such file or directory) while connecting to upstream
参考这里的解决方案
# cp /etc/php-fpm.d/www.conf.rpmsave /etc/php-fpm.d/ # vi /etc/php-fpm.d/www.conflisten 改为 listen = 127.0.0.1:9000; nginx 配置文件也改 # vi /etc/nginx/conf.d/yoursite.com.conf fastcgi_pass 127.0.0.1:9000; 重启php-fpm 和 nginx # sudo /etc/init.d/php-fpm restart # sudo systemctl restart nginx
评论专区