1、Nginx yum安装
1)添加Nginx到YUM源
添加CentOS 7 Nginx yum资源库,打开终端,使用以下命令:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2)安装Nginx
在你的CentOS 7 服务器中使用yum
命令从Nginx源服务器中获取来安装Nginx:
sudo yum install -y nginx
3)启动Nginx
nginx -c /etc/nginx/nginx.conf 开启Nginx
nginx -s reload 修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确
nginx -s stop :快速停止nginx
4)Nginx设置开机自启
sudo systemctl enable nginx.service
5)Nginx 配置文件所在目录
/etc/nginx/conf.d/
2、php7编译安装
1)cd /usr/local/src/
2)wget http://cn2.php.net/distributions/php-7.0.2.tar.gz
3)tar -xzxvf php-7.0.2.tar.gz
4)cd php-7.0.2
5)解压完后先不要编译,请检查是否安装了gcc ,没有的话执行yum install gcc
6)检查是否安装了libxml2 ,没有的话执行yum install libxml2
7)检查是否安装了libxml2-devel,没有的话执行yum install libxml2-devel
注:因为改为用nginx了,所以编译参数中的--with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安装PHP前,请先安装apache。
8)编译参数配置
‘./configure‘ ‘--prefix=/usr/local/php‘ ‘--with-pdo-pgsql‘ ‘--with-zlib-dir‘ ‘--with-freetype-dir‘ ‘--enable-mbstring‘ ‘--with-libxml-dir=/usr‘ ‘--enable-soap‘ ‘--enable-calendar‘ ‘--with-curl‘ ‘--with-mcrypt‘ ‘--with-gd‘ ‘--with-pgsql‘ ‘--disable-rpath‘ ‘--enable-inline-optimization‘ ‘--with-bz2‘ ‘--with-zlib‘ ‘--enable-sockets‘ ‘--enable-sysvsem‘ ‘--enable-sysvshm‘ ‘--enable-pcntl‘ ‘--enable-mbregex‘ ‘--enable-exif‘ ‘--enable-bcmath‘ ‘--with-mhash‘ ‘--enable-zip‘ ‘--with-pcre-regex‘ ‘--with-pdo-mysql‘ ‘--with-mysqli‘ ‘--with-jpeg-dir=/usr‘ ‘--with-png-dir=/usr‘ ‘--enable-gd-native-ttf‘ ‘--with-openssl‘ ‘--with-fpm-user=www-data‘ ‘--with-fpm-group=www-data‘ ‘--with-libdir=/lib/x86_64-linux-gnu/‘ ‘--enable-ftp‘ ‘--with-gettext‘ ‘--with-xmlrpc‘ ‘--with-xsl‘ ‘--enable-opcache‘ ‘--enable-fpm‘ ‘--with-iconv‘ ‘--with-xpm-dir=/usr‘
9)出现报错 Cannot find OpenSSL‘s <evp.h> 则执行 yum install openssl openssl-devel
10)出现报错 Please reinstall the libcurl distribution 则执行 yum -y install curl-devel
11)出现报错 jpeglib.h not found 则执行 yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y 和执行yum install libjpeg-devel
12)checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution 这是bzip2软件包没有安装解决办法 yum install bzip2-devel.x86_64 -y
13)configure: error: xpm.h not found. yum install libXpm-devel
14)error: Unable to locate gmp.h Fix: yum install gmp-devel
15)现象:Unable to detect ICU prefix or /usr//bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works 解决办法:yum install -y icu libicu libicu-devel
16)错误:mcrypt.h not found. Please reinstall libmcrypt. 解决办法:yum install php-mcrypt libmcrypt libmcrypt-devel
17)错误: configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path 解决办法:yum install postgresql-devel
18)错误 : configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution 解决: yum install libxslt-devel
19)配置的checking 结束后,执行: make clean && make && make install(如果出现错误:--ENABLE-OPCACHE=NO时执行export LD_LIBRARY_PATH=/usr/local/mysql/lib或export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib)
20)装完成后,我们要把源码包中的配置文件复制到PHP安装目录下,源码包中有两个配置 php.ini-development php.ini-production ,看名字就知道,一个是开发环境,一个是生产环境,我们这里就复制开发环境的
cp php.ini-development /usr/local/php/lib/php.ini
21)另外还需要设置环境变量 :修改vim /etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码
PATH=$PATH:/usr/local/php/bin
export PATH
然后执行 命令 source /etc/profile
22)php -v 就可以看到PHP版本信息了。
23)此时还需要配置PHP-fpm:
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
cp /usr/local/src/php-7.0.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
24)启动php-fpm: /usr/local/php/sbin/php-fpm
3、MySQL yum安装
1)下载MySQL源 wget http://dev.MySQL.com/get/mysql57-community-release-el7-7.noarch.rpm
2)安装MySQL源 sudo rpm -ivh mysql57-community-release-el7-7.noarch.rpm
3)安装mysql-community-server sudo yum install mysql-community-server -y
4)重启MySQL systemctl restart mysqld 注:自动启动服务用 systemctl enable mysql
nginx+php7+mysql 在centos7.3下安装