伊戈尔·赛索耶夫的旗帜

Linux软件安装方式

yum安装

# 1.更改安装来源 https://opsx.alibaba.com/mirror 

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


# 2.yum安装新软件
yum install -y  tree bash-completion  wget vim 

rpm安装

# mount 给 /dev/cdrom 创建一个入口 /mnt/
mount /dev/cdrom /mnt/
cd /mnt/
# ls -l 缩写为ll
ll /mnt/	 

# rpm查找软件
ll /mnt/Packages/telnet-0.17-64.el7.x86_64.rpm 

# rpm安装软件
rpm -ivh  /mnt/Packages/bash-completion-2.1-6.el7.noarch.rpm 

# 删除软件 rpm -e 软件名称


注意:
rpm -qa 后面要跟上包的名字才能搜索到
	-qa  = query all
比如,rpm -qa http 搜不到,是因为包的名字叫做 httpd
rpm -qa | grep 是把搜索到的全部包的名字交给 grep 去过滤,只要包含那个字符串就会被显示出来

安装Nginx前提

关闭selinux

cp  /etc/selinux/config  /etc/selinux/config.bak 先备份

# 永久修改SELINUX并显示结果,下次重启服务器生效
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
cat /etc/selinux/config  查看修改结果

# 临时修改SELINUX并显示结果,下次重启服务器生效
setenforce 0  # 修改状态
getenforce    # Permissive 结果正确

关闭防火墙

systemctl 管理服务

#查询防火墙状态 
systemctl status  firewalld.servic

#当前正在运行的防火墙  --- 临时 
systemctl stop firewalld.service(关闭)
systemctl start firewalld.service (打开)


#让防火墙不会开机自启动 --- 永久
systemctl disable firewalld.service(禁止启动)
systemctl enable firewalld.service (自启动)

#is-active  是否正在运行 
#systemctl is-active firewalld.service 
#is-enabled   是否开机自启动 
#systemctl is-enabled firewalld.service 

定时任务

crond 定时任务
crontab -l
	-l  list 查看
crontab -e
	-e  edit 编辑
	-r  delete  删除

# 每两分钟同步一次系统时间	
*/2 * * * *  /usr/sbin/ntpdate ntp1.aliyun.com 
# 修改系统时间
date -s "20180101"
# 同步服务器时间
ntpdate ntp[1-7].aliyun.com

Nginx 安装教程

# 安装nginx
# 下载
wget http://nginx.org/download/nginx-1.12.2.tar.gz
# 解压
tar xf nginx-1.12.2.tar.gz 
cd nginx-1.12.2 

# 安装依赖
yum install pcre-devel  openssl-devel -y 

#编译安装三部曲 :1 ./configure  2 make     3 make install 

# 第一步
./configure --prefix=/application/nginx-1.12.2 --with-http_stub_status_module  --with-http_ssl_module
# 第二步
make
# 第三步
make install

echo $?  # 检查上一条命令的执行结果 返回0 表示正确

#检查语法 
/application/nginx-1.12.2/sbin/nginx  -t

#启动nginx
/application/nginx-1.12.2/sbin/nginx  
/application/nginx-1.12.2/sbin/nginx  -s reload


对比两个文件区别
diff conf/nginx.conf  conf/nginx.conf.default # 没区别

egrep -v "#|^$" /application/nginx-1.12.2/conf/nginx.conf.default >/application/nginx-1.12.2/conf/nginx.conf


 1	worker_processes  1;          
 2	events {
 3	    worker_connections  1024;
 4	}
 5	http {
 6	    include       mime.types;                #媒体类型
 7	    default_type  application/octet-stream;
 8	    sendfile        on;                      #开启高效的传输模式
 9	    keepalive_timeout  65;                   #超时时间
10	    server {                               #一个server相当于是一个网站 虚拟主机 
11	        listen       80;                   #监听的端口
12	        server_name  www.etiantian.org;            #网站名字 域名 
13	        location / {        
14	            root   html;                   #根 站点的根目录
15	            index  index.html index.htm;   #首页文件 
16	        }
21	    }
22	}

一些补充

# 连不上IP解决方案
systemctl stop  NetworkManager
systemctl disable NetworkManager
systemctl restart network

# 获取IP
dhcclient
# 查看网关
ip r
# 快捷键
esc + . 上个命令最后一个文件
# 查找目录
which ntpdate
# 从根下找
find / -type f -name "ntpdate"  
#显示命令的绝对路径
which ntpdate 
	/usr/sbin/ntpdate
find / -type f -name "ntpdate"
	/etc/sysconfig/ntpdate
	/usr/sbin/ntpdate

参考链接:http://www.cnblogs.com/jingmoxukong/p/5945200.html

posted @ 2018-04-26 20:43  iYouYue  阅读(2023)  评论(0编辑  收藏  举报