美文网首页
linux常用命令集

linux常用命令集

作者: 不负卿的伤 | 来源:发表于2019-09-28 08:49 被阅读0次
    #########  面向CentOS7/8  ##############
    systemctl start httpd
    # 启动httpd服务
    systemctl status httpd
    #查看http状态
    systemctl list-unit-files
    centos7查看开机自启项(左边是服务名称,右边是状态,enabled是开机启动,disabled是开机不启动。)
    systemctl list-unit-files | grep enabled
    # 仅查看启动项
    firewall-cmd --zone=public --add-port=2333/tcp --permanent
    # 开放2333端口
    firewall-cmd --reload
    # 重新载入防火墙
    firewall-cmd --zone=public --query-port=2333/tcp
    # 查看端口 
    
    rewrite ^(.*)$ https://${server_name}$1 permanent; 
    # centos7 nginx 80端口转发443
    
    # ssh免密登录:
    
    
    # centos7网络时间同步 
    
     yum -y install ntp ntpdate
    
     ntpdate cn.pool.ntp.org
    
     hwclock --systohc
    
    # 递归更改目录及目录中文件权限(-R为递归,755为权限)
    chmod -R 755 file-dir-name
    
    #  查看用户
    cut -d : -f 1 /etc/passwd
    
    # 查看用户组
    cut -d : -f 1 /etc/group
    
    # 查看用户权限
    id nfsuser(用户名)
    
    # uid反查用户名
    getent passwd uid
    
    # 删除usertest这个用户
    userdel -r usertest
    
    
    ######################  -----CentOS7部署LNMP环境-----    ###########################
    # yum安装nginx
    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    
    yum -y install nginx
    
    systemctl start nginx && systemctl enable nginx
    
    vim /etc/nginx/nginx.conf
    gzip后面追加:
    server {
     listen       80;
     root   /usr/share/nginx/html;
     server_name  localhost;
     #charset koi8-r;
     #access_log  /var/log/nginx/log/host.access.log  main;
    
     location / {
           index index.php index.html index.htm;
     }
     #error_page  404              /404.html;
    
     error_page   500 502 503 504  /50x.html;
     location = /50x.html {
       root   /usr/share/nginx/html;
     }
     #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    
     location ~ .php$ {
       fastcgi_pass   127.0.0.1:9000;
       fastcgi_index  index.php;
       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       include        fastcgi_params;
     }
    }
    
    # 安装php
    rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
    
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    
    yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64
    
    systemctl start php-fpm && systemctl enable php-fpm
    
    echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php
    
    systemctl restart nginx
    
    访问http://ip测试
    
    # 安装mariadb
    rpm -qa | grep -i mariadb
    
    yum -y remove mariadb*
    
    vi /etc/yum.repos.d/MariaDB.repo
    
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.4/centos7-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    
    yum -y install MariaDB-client MariaDB-server && systemctl start mariadb
    
    systemctl enable mariadb
    
    # 或者安装mysql5.7
    
    wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
    yum -y localinstall mysql57-community-release-el7-11.noarch.rpm 
    yum -y install mysql-community-server
    systemctl start mysqld && systemctl enable mysqld
    # 查看初始密码
    grep 'temporary password' /var/log/mysqld.log
    #登陆,这里使用初始密码进行登陆并修改密码;
    mysql -uroot -p
    #  设置密码
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySQLP@ssw0rd';
    # 这里如果想要设置低复杂度的密码可使用:
    set global validate_password_policy=0;和 set global validate_password_length=1;
    
    mysql8.0使用:  set global validate_password.policy=0;  和set global validate_password.length=1;
    mysql8.0创建用户
    create user 'user'@'%' identified with mysql_native_password by 'MySQLUserP@ssw0rd';
    grant all privileges on *.* to 'root'@'%' with grant option;
    
    # 然后设置密码即可
    # 刷新权限
    FLUSH PRIVILEGES;
    #输入 \q  退出
    
    ####################LNMP环境结束########################
    
    # 配置java1.8环境变量
    
    export JAVA_HOME=/usr/share/jdk1.8
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export PATH=$PATH:$JAVA_HOME/bin
    
    
    
    mysql初次启动初始密码 root下提升普通用户权限

    相关文章

      网友评论

          本文标题:linux常用命令集

          本文链接:https://www.haomeiwen.com/subject/srcrxctx.html