首先先需要安装一些基础的依赖包gcc gcc-c++ pcre zlib openssl等
先安装编译器
yum install gcc gcc-c++
然后安装pcre pcre-devel zlib openssl openssl-devel等
yum -y install pcre-devel openssl openssl-devel libxml2 libxml2-devel curl curl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel
一:安装nginx
下载nginx
wget https://nginx.org/download/nginx-1.12.2.tar.gz
解压 tar xvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx
make
make install
启动nginx
/usr/local/nginx/sbin/nginx
二:安装php
下载php
wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
解压 tar xvf php-5.6.32.tar.gz
cd php-5.6.32
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-libdir=lib64 --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=www --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-opcache --enable-pcntl --enable-soap --enable-zip --enable-calendar --enable-bcmath --enable-exif --enable-ftp --enable-intl --with-openssl --with-zlib --with-curl --with-gd --with-zlib-dir=/usr/lib --with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-gettext --with-mhash --with-ldap
make
make install
安装的时候忘了配置php.ini的路径了,最好加上 --with-config-file-path=/usr/local/php/etc
php安装完成后把/usr/local/php/etc/php-fpm.conf.default 复制到 /usr/local/php/etc/php-fpm.conf
把源码中的php.ini-development复制到/usr/local/php/etc/php.ini
添加用户
useradd php-fpm
groupadd www
gpasswd -a php-fpm www
启动php-fpm
/usr/local/php/sbin/php-fpm
三:安装mysql
下载mysql
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
解压
tar xvf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar -C mysql-5.7.20-1.el7.x86_64
安装时按顺序,有依赖关系
rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.20-1.el7.x86_64.rpm
在安装这几个包期间,如果遇到冲突,就把已安装的包卸载掉。比如安装mysql-community-common-5.7.20-1.el7.x86_64.rpm 与mariadb-libs冲突,先查看
$ rpm -qa | grep mariadb-libs
mariadb-libs-5.5.56-2.el7.x86_64
再卸载
$ rpm -e mariadb-libs-5.5.56-2.el7.x86_64
然后再安装mysql-community-common-5.7.20-1.el7.x86_64.rpm
安装完成后启动mysql
systemctl start mysqld.service
查看是否启动
netstat -ln | grep 3306
修改my.cnf配置文件
vim /etc/my.cnf 加上这几句
validate_password=off #关闭密码验证,方便修改密码。似乎没啥用,修改密码时仍然需要输入密码
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
重启mysql
systemctl restart mysqld.service
在mysql的错误日志中生成了一个临时密码 cat /var/log/mysqld.log | grep password
A temporary password is generated for root@localhost: d2nN>mQHgoiE
使用临时密码登陆数据库,修改mysql密码
mysql -uroot -p
mysql> set password=password('新密码');
mysql> flush privileges;
mysql安装完毕。