1. 程式人生 > >2018.12.10-2018.12.16

2018.12.10-2018.12.16

 1、搭建php-fpm工作方式的LAMP環境,實現wordpress正常訪問 

搭建httpd+wordpress環境   ip:172.16.100.141  將下載好的wordpress放置再/data/目錄下

~]#yum install httpd -y

~]#yum install php php-mysql -y

~]#vim /etc/httpd/conf.d/ilinux.conf

<VirtualHost 172.16.100.141:80>

ServerName www.ilinux.io

DocumentRoot /data/www/html/ilinux/

ProxyRequests off

ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.100.142/data/$1

<Directory /data/www/html/ilinux>

    Option None

    AllowOverride None

    require all granted

</Directory>

</VirtualHost>

~]#mkdir /data/www/html/ilinux -pv

~]#vim /data/www/html/ilinux/index.html

<li>172.16.100.141<li>

~]#vim /data/www/html/ilinux/phpinfo.php

<?php

    phpinfo();

?>

~]#yum install lrzsz -y

~]#rz     上傳wordpress

~]#tar -xvf wordpress -C /data/

~]#ln -sv /data/wordpress/ /data/www/html/ilinux/blog/

~]#chown apache.apache /data/wordpress

~]#chown apache.apache /var/lib/php/session/

~]#systemctlt start httpd.service

搭建mariadb-server再172.16.100.142伺服器上

~]#yum install mariadb-server -y

~]#vim /etc/my.cnf

skip-name-resolve=on

innodb-file-per-table=on

~]#mysql

mysql>SET PASSWORD FOR root@localhost = PASSWORD(xlj999);

mysql>SET PASSWORD FOR root@127.0.0.1 = PASSWORD(xlj999);

mysql>create database wordpress;

mysql>grant all privileges on wordpress.* towordpress@%identified by wordpress;

mysql>grant all privileges on wordpress.* towordpress@localhostidentified by wordpress;

mysql>grant all privileges on wordpress.* towordpress@127.0.0.1identified by wordpress;

~]#systemctl start mariadb.service

#安裝然後網頁輸入相應配置www.ilinux.io/blog

 

 

****實現php-fpm模組**** 172.16.100.142

~]#yum install php-fpm php-mysql php-mbstring php-mcrpt -y

~]#mkdri /var/lib/php/session -pv

~]#chown apache.apache /var/lib/php/session

~]#vim /etc/php-fpm.d/www.conf

listen=172.16.100.142:9000

listen.allowed_clients=172.16.100.141

~]#systemctl start php-fpm.service

~]#scp 172.16.100.141:/data/wordpress /data/www/html/ilinux/blog

~]#chown apache.apache /data/www/html/ilinux/blog/wp-config.php

 

 

 2、什麼是DML?常用SQL舉例,每個命令至少1個例子,最多不超過3個例子 

mysql>SELECT name AS student_name,gender FROM students;

mysql>SELECT name AS student_name,gender FROM students WHERE stuid>2;

mysql>SELECT stuid,name AS student_name,gender FROM students WHERE gender=M;

mysql>DELETE FROM students WHERE stuid=3;

mysql>SELECT * FROM students;

mysql>DELETE FROM students ORDER BY age DESC LIMIT 100;

mysql>UPDATE students SET classid=2;

mysql>UPDATE students SET classid=2 WHERE stuid=2;

3.簡述ftp的主動和被動模式,並實現基於pam認證的vsftpd

儲存

SATA,SAS,IDE,SCSI,USB

SCSI 

 

DAS

Dirct Attached Storage    直接附加儲存   介面型別:”block”

NAS

Network Attached Storage 網路附加儲存   介面型別:”file”

協議

CIFS(samba),NFS(Network File System)

RPC

Remote Procedure Call 遠端過程呼叫

SAN

Storage Area Network    介面型別:”block”

協議:ISCSI(IP-SAN)FCSAN,FCOE

兩類連線:

命令連線:傳輸命令

資料連線:傳輸資料

兩種模式:PORT

Server:20/tcp連線客戶端的命令連線使用的埠向後的第一個可用埠

被動模式:PASV

Server:開啟一個隨機埠,並等待客戶端連線

PAM: Pluggable Authenticate Module    /etc/pam.d/   認證框架

協議:C/S

Server

WindowsServ-U,FilezillaLinuxwuftpd,proftpd,pureftpd,vsftpd(Very Secure FTP daemon)

 

Client

Windowsftp,Fillzilla,CuteFTP,FlashFXPLinuxlftp,ftp,Fillzilla,gftp

 

URL

SCHEMA://username:[email protected]:Port/PATH/TO/FILE

路徑對映

使用者家目錄:每個使用者的URL/對映到當前的家目錄

vsftpdftp使用者的身份執行,預設為ftp使用者,匿名使用者的預設路徑即ftp使用者的家目錄/var/ftp     ftp,anonymous

~]#ls /usr/lib64/security/

 

~]#ldd /usr/sbin/vsftpd

 

~]#ls /etc/pam.d/

 

~]#yum install mariadb-devel pam-devel -y

~]#yum groupinstall “Development Tools” “Server Platform Development”

下載pam_mysql-0.7RC1.tar.gz

~]#tar xvf pam_mysql-0.7RC1.tar.gz

 

~]#cd pam_mysql-0.7RC1

~]#./configure --help

~]#./configure --with-mysql=/usr --with-pam=/usr --with-pam-mods-dir=/usr/lib64/security

~]#make && make install

~]#ls /usr/lib64/security

 

~]#vim /etc/my.cnf.d/server.cnf

skip_name_resolve=ON

innodb_file_per_table=ON

log_bin=mysql-bin

~]#systemctl start mariadb.service

~]#mysql

mysql>grant all privileges on vsftpd.* to ‘vsftpd’@’127.0.0.1’ identified by ‘vsftpd’;

mysql>flush privileges;

mysql>create database vsftpd;

mysql>use vsftpd;

mysql>CREATE TABLE users(id INT UNSIGNED NOT NUL AUTO_INCREMENT PRIMARY KEY,name VARCHAR(100) NOT NULL,password CHAR(48)NOT NULL,UNIQUE KEY(name));

mysql>DESC users;

mysql>INSERT INTO users(name,password) VALUES(‘tom’,PASSWORD(‘mageedu’)),(‘jerry’,PASSWORD(‘jerry’));

mysql>SELECT * FROM users;

mysql>\q

~]#useradd -d /ftproot/vuser vuser

~]#finger vuser

~]#mkdir /ftproot/vuser/pub

~]#vim /etc/pam.d/vsftpd.vusers

auth required /usr/lib64/security/pam_mysql.so user=vsftpd passwd=mageedu host=127.0.0.1 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2

account required /usr/lib64/security/pam_mysql.so user=vsftpd passwd=mageedu host=127.0.0.1 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2

~]#vim /etc/vsftpd/vsftpd.conf

pam_service_name=vsftpd.vusers

guest_enable=YES

guest_username=vuser

~]#chmod a-w /ftproot/vuser/

不能上傳檔案

~]#vim /etc/vsftpd/vsftpd.conf

user_config_dir=/etc/vsftpd/vusers_config/

~]#vim /etc/vsftpd/vusers_config/tom

anon_upload_enable=YES

anon_mkdir_write_enable=YES

 4、簡述NFS服務原理及配置 

__________________Server_________________________172.16.100.135

~]#lsmod

~]#lsmod | grep nfs

~]#yum info nfs-utils

NFS utilities and supporting clients and daemons for the kernel NFS server

#####安裝nfs-utils########

~]#yum install nfs-utils -y

~]#rpm -ql nfs-utils

#####編輯/etc/exports檔案######

~]#vim /etc/exports

~]#ls /etc/exports.d/

~]#vim /etc/exports

~]#mkdir /data/mysql -pv

~]#man exports

~]#vim /etc/exports

/data/mysql  172.16.0.67(rw,anonuid=1001,anongid=1001)  172.16.0.0/16(ro)

#######啟動nfs########

~]#systemctl start nfs.service

~]#ss -tnl

 

~]#vim /etc/sysconfig/nfs      #可以修改配置檔案

~]#useradd -u 1001 centos

~]#mkdir /data/mysql/test

~]#chown -R 1001.1001 /data/mysql/test

~]#exprotfs -rav #############重新匯出  不重啟

 

 

 

 

 

 

 

____________________________Client_________________________172.16.100.137

~]#yum install showmount -y

~]#showmount -e 172.16.100.135

Export list for 172.16.100.135:

/data/mysql 172.16.100.0/24

~]#mount -t nfs 172.16.100.135:/data/mysql  /mnt

~]#mount

 

~]#

 5、簡述samba服務,並實現samba配置

簡述samba服務:

smb:Service message block

cifs:common internet filesystem

 

samba功能:

檔案系統共享

印表機共享

NetBIOS協議

程式環境:

服務端程式包:samba  samba-common samba-libs

主配置檔案:/etc/samba/smb.conf ,samba-common包提供

主程式:

nmbd:NetBIOS name server

smbd:SMB/CIFS service

Unit FIle

smb.service

nmb.service

監聽的埠:

137/udp,138/udp

139/tcp,445/tcp

客戶端程式:

smbclient:互動式命令列客戶端,類似於lftp

mount.cifs:掛在cifs檔案系統的專用命令

 

共享檔案系統配置

有三類

[homes] :為每個samba使用者定義是否能夠通過samba服務訪問自己的家目錄

[printers]:定義列印服務

[shared_fs]:定義共享的檔案系統

常用指令

comment :註釋資訊

path:當前共享所對映的檔案系統路徑

browseable:是否可瀏覽,指是否而可被使用者檢視

guest ok :是否允許來賓賬號訪問

public :是否公開所有使用者

writable :是否可寫

write list :擁有寫許可權的使用者列表

使用者名稱

@組名

+組名

samba 使用者管理: smbpasswd [options] USERNAME

-a :新增

-x :刪除

-d :禁用

-e :啟用

pdbedit

-L :列出samba服務中的所有使用者

-a :新增使用者為samba使用者

-x :刪除使用者

-t :從標準輸出接受字串作為使用者密碼

檢視伺服器端的共享:

smbclient -L SMB-Server [-U Username];

互動式檔案訪問:

smbclient //SMB-Server/Share_Name [-U Username]

掛在訪問:

mount -t cifs //SMB_Server/Share_Name -o username=USERNAME,password=PASSWORD

注意:掛在操作的使用者,與-o選項中的指定使用者直接產生對映關係。此時,訪問掛載 點是以-o選項中的username指定的使用者身份進行,與本地使用者無關

顯示smbstatus命令

-b : 顯示簡要格式資訊

-v : 顯示詳細格式資訊

服務配置:

*****172.16.100.141*****

~]#yum install sabma -y

~]#rpm -ql samba | less

~]#rpm -ql samba-common | less

~]#vim /etc/samba/smb.conf

[mysql_file]

        comment = mysql_file_data

        path = /data/mysql_data

        write list = tqgaorui5

        browseable = yes

        writeable = yes

        force group = @tom_group

~]#useradd tqgaorui5

~]#smbpasswd -a tqgaorui5

~]#systemctl start nmb.service

~]#systemctl start smb.service

~]#groupadd -g 1001 tom_group

~]#cat /etc/group

*****172.16.100.142*****

~]#yum install samba-client -y

~]#smbclient -L 172.16.100.141 -U tqgaorui5

~]#smbcllient -t cifs //172.16.100.141/mysql_file /data/mysql_data -o tqgaorui5,password=redhat

~]#mount

~]#vim /etc/fstab

//172.16.100.141/mysql_file /data/mysql_data cifs defaults 0 0

~]#useradd tom

~]#id tom

uid=1001(tom) gid=1001(tom) 組=1001(tom)