1. 程式人生 > 其它 >隨筆4

隨筆4

1、自建yum倉庫,分別為網路源和本地源
1.將iso檔案連線到主機上
mkdir /mnt/cdrom #建立掛載目錄
mount /dev/cdrom /mnt/cdrom
2.編寫yum檔案
vim /etc/yum.repos.d/CentOS-local.repo
[c6-media]
name=CentOS-$releasever
baseurl=file:///mnt/cdrom/ #路徑需與你光碟機或ISO掛載的路徑相同
gpgcheck=1
enabled=1 #enable後面值必須修改為1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7 #可以不寫這個
yum makecache
2、編譯安裝http2.4,實現可以正常訪問,並將編譯步驟和結果提交。
1.下載包
wget https://dlcdn.apache.org//httpd/httpd-2.4.51.tar.gz
tar -xvf httpd-2.4.51.tar.gz -C /usr/local/
yum -y install apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
tar -zxf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure --prefix=/usr/local/apr
make && make install
cd ;tar -zxf apr-util-1.3.12.tar.gz ;cd apr-util-1.3.12
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
make && make install
cd /usr/local/httpd-2.4.51/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make && make install
--prefix:指定將 httpd 服務程式安裝到哪個目錄下,如/usr/local/httpd
--enable-so:啟用動態載入模組支援,使 httpd 具備進一步擴充套件功能的能力。
--enable-rewrite:啟用網頁地址重寫功能,用於網站優化及目錄遷移維護。
--enable-charset-lite:啟動字符集支援,以便支援使用各種字符集編碼的網
--enable-cgi:啟用 CGI 指令碼程式支援,便於擴充套件網站的應用訪問能力。
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util/
編輯httpd.conf檔案,搜尋"#ServerName",新增ServerName localhost:80
vim /usr/local/httpd/conf/httpd.conf
啟動httpd
/usr/local/httpd/bin/apachectl start

3、利用sed 取出ifconfig命令中本機的IPv4地址
ifconfig ens33 |sed -n '/inet /s/\(.*inet \)\(.*\)\( n.*\)/\2/p'
4、刪除/etc/fstab檔案中所有以#開頭,後面至少跟一個空白字元的行的行首的#和空白字元
sed '/^# */d;/^$/d' /etc/fstab
5、處理/etc/fstab路徑,使用sed命令取出其目錄名和基名
echo /etc/fstab | sed -nr 's@^(.*)/([^/]+)/?$@\1@p' #目錄名
echo /etc/fstab | sed -nr 's@^(.*)/([^/]+)/?$@\2@p' #基名
6、列出ubuntu軟體管理工具apt的一些用法(自由總結)
apt install 安裝軟體包
apt remove 移除軟體包
apt purge 移除軟體包及配置檔案
apt update 重新整理儲存庫索引
apt search 搜尋應用程式
apt show 顯示安裝細節
apt list 列出包含條件的包(已安裝,可升級等)
apt edit-sources
apt-cache madison (包名) 檢視倉庫中軟體包有哪些版本可以安裝