欢迎投稿

今日深度:

centos7通过yum安装指定版本的lnmp,centos7lnmp

centos7通过yum安装指定版本的lnmp,centos7lnmp


1、安装MariaDB

[ ~] vim /etc/yum.repos.d/Mariadb.repo
# MariaDB 10.1 CentOS repository list - created2016-12-01 03:36 UTC
# http://download.mariadb.org/mariadb/repositories/
[mariadb]
name=MariaDB
baseurl=http://yum.mariadb.org/10.1/centos7-amd64
enabled=1
gpgcheck=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
//安装
[ ~] yum -y install MariaDB-server MariaDB-client
//启动MariaDB服务及配置开机启动项
[ ~] systemctl start mariadb
[ ~] systemctl enable mariadb

2、配置数据库

[ ~] mysql_secure_installation
#由于一开始安装MariaDB数据库后, root用户默认密码为空, 所以只需要按Enter键
Enter current password for root (enter for none):
#是否设置root用户的新密码
Set root password? [Y/n] y

#录入新密码
New password:

#确认新密码
Re-enter new password:

#是否删除匿名用户,生产环境建议删除
Remove anonymous users? [Y/n] y

#是否禁止root远程登录,根据自己的需求选择
Disallow root login remotely? [Y/n] y

#是否删除test数据库
Remove test database and access to it? [Y/n] y

#是否重新加载权限表
Reload privilege tables now? [Y/n] y

######## 设置客户端 ########
[ ~] vi /etc/my.cnf.d/mysql-clients.cnf
[mysql]
default-character-set=utf8
######## 设置服务端 ########
[ ~] vi /etc/my.cnf.d/server.cnf
[mysqld]
init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
# 开启慢查询 #
slow_query_log=on
slow_query_log_file=/usr/local/mysql/data/slow.log
long_query_time=1
[ ~] systemctl restart mariadb          // 重启mariadb

3、安装nginx

//启用EPEL仓库
## RHEL/CentOS 7 64-Bit ##
[ ~] wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
[ ~] rpm -ivh epel-release-7-11.noarch.rpm --force --nodeps
//查看EPEL仓库是否建立成功
[ ~] yum repolist
//安装nginx
[ ~] yum -y install nginx
[ ~] nginx -V

4、配置nginx

[ ~] vi /etc/nginx/conf/nginx.conf
user www www;                                                              // 指定拥护者及用户组
server{
     listen         80;                                                    // 监听端口
     server_name    localhost;                                             // 域名
     root           html;                                                  // 根目录
     location / {
          #root     html;
          index index.html index.htm index.php;                            // 添加index.php,支持php文件
     }

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
     #
     location ~ \.php$ {                                                   // 开启
          #root html;
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
     }
}

5、安装PHP

//nginx+php需要添加php7-fpm webtatic仓库
[ ~] rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
//安装php7-fpm以及依赖包
[ ~] yum -y install php70w-fpm php70w-cli php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel curl curl-devel openssl openssl-devel
//查看版本及扩展
[ ~] php -v
[ ~] php -m

6、配置php

[ ~] groupadd www
[ ~] useradd -g www www
[ ~] vi /etc/php-fpm.d/www.conf
######## 修改成如下 ########
user = www
group = www
# 取消注释,启用php-fpm的系统环境变量
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
[ ~] systemctl start php-fpm
[ ~] systemctl enable php-fpm

 

www.htsjk.Com true http://www.htsjk.com/mariadb/24747.html NewsArticle centos7通过yum安装指定版本的lnmp,centos7lnmp 1、安装MariaDB [ ~] vim /etc/yum.repos.d/Mariadb.repo# MariaDB 10.1 CentOS repository list - created2016-12-01 03:36 UTC# http://download.mariadb.org/mariadb/repositories/[mariadb]n...
相关文章
    暂无相关文章
评论暂时关闭