Linux-CentOS7下安装LNMP环境笔记
CentOS版本号: 7.6
1. 设置yum源
rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
PHP源官方地址: https://webtatic.com/
mysql源官方地址: https://dev.mysql.com/downloads/repo/yum/
2.安装nginx1.1 php7.1 mysql5.7
安装之前先
清除yum缓存: yum clean all
生成yum缓存 : yum makecache
yum -y install nginx
yum -y install mysql-community-server
yum -y install php71w-devel php71w php71w-cli php71w-common php71w-gd php71w-ldap php71w-mbstring php71w-mcrypt php71w-pdo php71w-mysqlnd php71w-fpm php71w-opcache php71w-pecl-redis php71w-bcmath
3.启动软件
systemctl start nginx
systemctl start mysql | systemctl start mysqld
systemctl start php-fpm
具体的nginx,php-fpm的配置这里省略,下面只重点说一下mysql的配置
- mysql5.7 初始密码获取
启动mysql之后,通过命令 grep 'temporary password' /var/log/mysqld.log
可以拿到root用户的初始密码
- 修改初始密码
root用户首次登录mysql是需要修改初始密码才能进行后续的操作的
初始密码必须包括数字、大小写字母且长度不能小于8位
set password = password('ryUl1_33au_n0krQ')
- 创建用户且授权
grant all privileges on db_sb.* to "dbsb"@"%" identified by "ryUl1_33au_n0krQ"
上面命令会自动创建dbsb用户且授权db_sb库的所有表的权限
4.设置开机自动启
systemctl enable mysqld
systemctl enable nginx
systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
查看软件安装相关目录或者文件: rpm nginx -ql
以上都是在关闭了系统的防火墙和selinux下操作的
参考:
https://www.linuxidc.com/Linux/2018-01/150669.htm
https://webtatic.com/packages/php71/
升级PHP版本
查看安装的PHP yum list installed | grep php
匹配卸载7.1版本:
yum remove php71w*
yum remove mod_php71w
安装72版本
yum -y install mod_php72w php72w-devel php72w-cli php72w-common php72w-gd php72w-ldap php72w-mbstring php72w-mcrypt php72w-pdo php72w-mysqlnd php72w-fpm php72w-opcache php72w-pecl-redis php72w-bcmath
没有可用软件包 php72w-mcrypt。72版本移除了mcrypt