用的都是最新版的包 : php7 mysql5.7 nginx1.8 zabbix3.2.6
替换源为阿里云的源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum clean all yum makecache
配置MySQL5.7
yum install -y autoconf make automake imake cmake gcc gcc-c++ libaio libaio-devel bzr bison expat-devel libtool ncurses5-devel gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel yum -y install pcre* yum -y install openssl* yum -y install epe-release yum clean all
cd /usr/local/src wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm yum localinstall mysql57-community-release-el7-7.noarch.rpm -y
安装mysql5.7
sed -i 's/^mirr/#mirr/g' /etc/yum.repos.d/epel.repo sed -i 's/^#\(base\)/\1/' /etc/yum.repos.d/epel.repo yum -y install mysql-server
安装成功后,mysql5.7第一次初始化,有个默认密码。获取默认密码方法:
grep 'temporary password' /var/log/mysqld.log #这里会获得一个类似乱码的东西
执行命令初始化
mysql_secure_installation #这里会要求你输入上面那个类似乱码的东西
之后一步一步的 会有好多问题 随便点吧....具体的我也不太懂,但是需要注意 mysql5.7对密码有要求 要包含大小写特殊字符并且超过8个字符才能当密码
比如 : Zabbix,123 类似这种才能通过!
配置PHP7
cd /usr/local/src
wget -c http://cn2.php.net/distributions/php-7.0.5.tar.gz
下载包
tar -zxvf php-7.0.5.tar.gz #解压
cd php-7.0.5/
这里将只安装一些常用的扩展,大家可以根据自己的实际需要进行增减,可以通过以下密令查看PHP安装是具体有有些扩展和选项:
./configure --help
安装前先看要用到哪些模块,然后yum install
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
然后安装
./configure --prefix=/usr/local/php7 --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mysqli --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring
--enable-xml --enable-session --enable-ftp --enable-pdo -enable-tokenizer --enable-zip && make && make install
如果报错说libmcrypt这个玩意儿没有,那么就:
yum -y install libmcrypt libmcrypt-devel
然后我们来copy配置文件
cp php.ini-development /usr/local/php7/lib/php.ini #注意这个lib目录 如果上面没有指定 就是默认是lib 但是你可以自己指定配置文件在哪,比如在etc下啊啥啥的
#--with-config-file-path=PATH这个命令在上面指定配置文件在哪里
vim /usr/local/php7/lib/php.ini
mysqli.default_socket = /var/lib/mysql/mysql.sock
date.timezone = PRC #这个配置前面有注释,注释掉,搜索的话搜date.timezone
/usr/local/php7/bin/php -v #测试一下版本
复制php配置文件,用默认的即可
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
vim /usr/local/php7/etc/php-fpm.conf #更改内容
user = nginx
group = nginx
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
vim /usr/lib/systemd/system/php-fpm.service #照着写上,配置文件如果不一样就把下面的代码写上
PIDFile=/usr/local/php7/var/run/php-fpm.pid
ExecStart=/usr/local/php7/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7/etc/php-fpm.conf
重新载入并且启动php
systemctl daemon-reload #重载进程
systemctl enable php-fpm #设置永久开启
systemctl start php-fpm #开启服务
配置Nginx1.8
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx #安装
systemctl enable nginx #永久开启 systemctl start nginx #启动
如果无法下载 vim /etc/hosts 206.251.255.63 nginx.org