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