1)前期准备:为了安装顺利,建议先使用yum安装依赖库
[root@opd ~]#yum install -y make cmake gcc gcc-c++ autoconf automake libpng-devel libjpeg-devel zlib libxml2-devel ncurses-devel bison libtool-ltdl-devel libiconv libmcrypt mhash mcrypt libmcrypt-devel pcre-devel openssl-devel freetype-devel libcurl-devel
一、修改 yum 源
[root@localhost ~]# rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@localhost ~]# rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
二、安装 Nginx、MySQL、PHP
[root@localhost ~]# yum -y install nginx
[root@localhost ~]# yum -y install mysql-community-server
[root@localhost ~]# yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.
三、配置
1、配置 MySQL
MySQL 安装完成之后,在 /var/log/mysqld.log 文件中给 root 生成了一个默认密码
通过下面的方式找到root 默认密码,然后登录 MySQL 进行修改:
[root@localhost ~]# systemctl start mysqld # 启动 MySQL
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log # 查找默认密码
2017-04-10T02:58:16.806931Z 1 [Note] A temporary password is generated for root@localhost: iacFXpWt-6gJ
#登录 MySQL:
[root@localhost ~]# mysql -uroot -p'iacFXpWt-6gJ'
#修改root 默认密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyPass1!';
或者:
mysql> set password for 'root'@'localhost'=password('123abc');
注:
MySQL5.7 默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 错误
配置默认编码为 utf8:
修改 /etc/my.cnf 配置文件,在 [mysqld] 下添加编码配置,配置完成后重启:
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
[root@localhost ~]# systemctl restart mysqld # 重启 MySQL
设置开机启动:
[root@localhost ~]# systemctl enable mysqld
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket 文件:/var/run/mysqld/mysqld.pid
安装nginx
下载nginx:wget http://nginx.org/download/nginx-1.6.2.tar.gz
解压安装包:tar zxvf nginx-1.6.2.tar.gz
进入安装包目录:cd nginx-1.6.2
编译安装:./configure 默认地址 /usr/local/nginx
安装:make
安装:make install
nginx配置:
cd /usr/local/nginx/conf
可以检测配置的是否正确:
/usr/local/nginx/sbin/nginx -t
启动nginx
/usr/local/nginx/sbin/nginx
停止服务器
/usr/local/nginx/sbin/nginx -s stop 或 /usr/local/nginx/sbin/nginx -s quick
网页访问: 127.0.0.1
网友评论