1 源的配置

1.换成国内的源,可以提高下载速度

首先备份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)

cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

运行以下命令生成缓存

yum clean all
yum makecache

参考地址: http://mirrors.163.com/.help/centos.html

2.添加更多的源

CentOS由于很追求稳定性,所以官方源中自带的软件不多,因而需要一些第三方源:epel是对官方源的补充,可以提供更新更丰富的rpm包;官方不提供php7的rpm包,php7有两个源可以选择,一个是webtatic提供的,也就是php70w,另一个可以使用remi源,我使用的是webtatic提供的

安装相应的源(webtatic依赖epel)

CentOS/RHEL 7.x:

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

2 安装软件

注意:前提是有可用的源,出于安全和稳定等原因,有些软件包是本身的源不具备的

2.1 安装php7

yum install php70w php70w-fpm php70w-mysql

php -v //查看是否安装成功

其它一些可以安装的扩展等

yum install php70w-devel
yum install php70w-pdo php70w-xml php70w-mbstring

2.2 安装nginx

yum install nginx
nginx -v

2.3 安装mysql

yum install mariadb-server -y  //安装
systemctl start mariadb.service //启动
systemctl enable mariadb.service //设置开机启动
mysql_secure_installation //初始化设置

2.4 安装vsftp (ftp登录配置)

yum install vsftpd

相关操作

禁止匿名登陆

vim /etc/vsftpd/vsftpd.conf 将配置文件中第11行

anonymous_enable=YES
anonymous_enable=NO

允许root账户登录,编辑/etc/vsftpd/user_list和/etc/vsftpd/ftpusers两个设置文件脚本,将root账户前加上#号变为注释。(即让root账户从禁止登录的用户列表中排除)

开启vsftpd

service vsftpd start

本地客户端filezilla,百度自行下载配置

3 开机启动设置

systemctl enable mariadb.service
systemctl enable php-fpm.service
systemctl enable nginx.service
systemctl enable vsftpd.service

相关操作

查看开机启动情况

systemctl list-unit-files
systemctl list-unit-files | grep fpm

设置为开机启动

systemctl enable mariadb.service

取消开机启动

systemctl disable mariadb.service

4 其它一些配置

4.1 git的设置

下载git

yum install git

生成密钥,位置在~/.ssh文件夹下

ssh-keygen -t rsa -C "your_email@example.com"

全局配置

git config [--global] user.name "name"
git config [--global] user.email "email address"

4.2 mysql本地登录

步骤:

登陆mysql

mysql -uroot -p123456

切换到mysql这个数据库

mysql> use mysql;

查看root用户配置

mysql> select host,user from user where user='root';

如果查询结果中不包含以下记录,请添加,否则请忽略次步骤

+--------------------+------+
| host | user |
+--------------------+------+
| % | root |
+--------------------+------+

添加方法:

mysql> update user set host = '%' where user = 'root' and host = '127.0.0.1';

+--------------------+------+
| host | user |
+--------------------+------+
| % | root |
| ::1 | root |
| localhost | root |
| vm\_33\_19\_centos | root |
+--------------------+------+

使配置生效

mysql> flush privileges;

配置完成,客户端重新登录成功;

4.3 基本nginx配置

server{
  #分别写了www和不带www的域名
  server_name www.zhengde.site zhengde.site;
  listen 80;
  #工程根目录
  root /var/data/blog/;
  charset UTF-8;
  #日志文件位置,自己选择
  access_log /var/log/nginx/blog/access.log;
  error_log /var/log/nginx/blog/error.log;   index index.php index.html index.htm;   #error_page 500 502 503 504 404 /missing.html;
  #error_page 403 =404 /missing.html;   #主要作用是xxxx/index.php/控制器/方法,一般的index.php是隐藏的,不写这句就找不到了
  location / {
    try_files $uri /index.php$is_args$args;
  }   location ~ \.php$ {
    #这个要看你监听的位置
  fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  
  #二选一,第一种写法
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    #二选一,第二种写法,但是需要在外层创建 fastcgi.conf文件
    # include fastcgi.conf;
  }
}

4.4 certbot安装(用于生成https证书,不用可忽略)

sudo yum install certbot-nginx
certbot certonly --webroot -w /data/blog -d xxxx.cn -w /data/blog -d www.xxxx.cn -w /data/blog -d xxxx.cn -w /data/blog -d www.xxxx.cn

centos使用--centos7.3配置LNMP的更多相关文章

  1. CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)

    CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL) 一.准备篇: /etc/init.d/iptables stop #关闭防火墙 关闭SELINUX vi /etc/sel ...

  2. CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)

    准备篇 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dp ...

  3. linux CentOS7.2配置LNMP

    转自http://www.centoscn.com/CentosServer/www/2014/0904/3673.html 准备篇: CentOS 7.0系统安装配置图解教程 http://www. ...

  4. 阿里云里Centos 7 PHP7环境配置 LNMP

    首先更新系统软件</str> $ yum update 安装nginx</str></str> 1.安装nginx源 $ yum localinstall http ...

  5. 阿里云 Centos 7 PHP7环境配置 LNMP

    首先更新系统软件 $ yum update 安装nginx 1.安装nginx源 $ yum localinstall http://nginx.org/packages/centos/7/noarc ...

  6. CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)

    一 安装篇 1. 安装nginx yum check-update #更新yum源 yum remove httpd* php* #删除系统自带的软件包 yum install nginx #安装ng ...

  7. CentOS7.2配置LNMP环境并安装配置网站WordPress

    1,安装环境查看 2,安装MySQL5.7.22 下载MySQL wget https://downloads.mysql.com/archives/get/file/mysql-5.7.22-1.e ...

  8. CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)

    以下全部转载于  http://blog.csdn.net/lane_l/article/details/20235909 本人于今晚按照该文章使用centos 6.7 64bit安装成功,做个备份, ...

  9. CentOS安装与配置LNMP

    本文PDF文档下载:http://www.coderblog.cn/doc/Install_and_config_LNMP_under_CentOS.pdf 本文EPUB文档下载:http://www ...

随机推荐

  1. word中已删除设置是否显示

        我们打开别人发过来的文档时经常会出现如下图所示,其实这个不是文档的异常,只是word设置显示了修订版标记,如果我们需要去除这个,只需要在审阅-修订功能下面选择显示最终版即可(测试用的10版,其 ...

  2. 修改jupyter notebook的工作路径

    两种方法 一 修改jupyter notebook快捷方式的属性 ①根据下图找到jupyter的快捷方式:jupyter notebook→更多→打开文件位置 ②右键打开属性-将目标一栏中最后的%US ...

  3. first 和firstordefault的用法 简介

    https://www.cnblogs.com/1312mn/p/9212325.html

  4. string find简析

    原文链接 #include <string>#include <iostream>using namespace std; void main(){ ////find函数返回类 ...

  5. Git笔记(pull/push)

    一.从远程服务器上获取分支 git pull <远程主机名> <远程分支>:<本地分支> 例如 git pull origin master:loacal_bran ...

  6. Extjs4.2 tabPosition left 相关

    解决tabPosition:left 标签的方向问题   <%@ page language="java" import="java.util.*" pa ...

  7. hdu_1452_Happy 2004 (乘法逆元

    Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your ...

  8. zabbix服务端安装配置

    1.安装好httpd,mysql,php yum install httpd php mysql mysql-devel php-xmlwriter php-gd php-mbstring php-b ...

  9. Mysql5.7.25在windows下安装

    在网上看到了很多安装方法,也试了很多,md,网上资源多了也是有各种坑,这里只说在windows下安装mysql5.7.25 一.下载安装包 链接:https://dev.mysql.com/downl ...

  10. 近年来爆发的CVE漏洞编号

    1.Office漏洞 Office漏洞是大部分APT组织最喜爱的漏洞,Office在个人办公电脑使用量大,对针对性目标是最佳的外网入口,效果也是最直接的. CVE编号  漏洞类型 使用组织 CVE-2 ...