系統:centos6 配置mirror阿里雲 https://opsx.alibaba.com/mirrorphp
遠程管理首選:ssh 帳戶密碼登陸(ssh user@host) 或者 本地私鑰鏈接服務器公鑰(推薦)html
=>ssh服務自己配置(禁止掉root、只容許密鑰):etc/ssh/sshd_config 前端
【SSH初次適用】java
密鑰對
2. ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
代理
3. eval "$(ssh-agent -s)"
註冊私鑰
4. ssh-add ~/.ssh/id_rsa
填充公鑰
5. cat id_rsa.pub | clip
6. GitHub > profile > SSH keys 添加就好啦。
7. ssh-copy-id 192.168.10.10mysql
1. 【虛擬機上網初始化】編輯 => 虛擬網絡編輯器 => 橋接模式(獨立虛擬機) => 選擇一張已經聯網的網卡。linux
………………………………………………………………【JDK】nginx
【清除自帶jdk】c++
rpm -qa | grep jdk git
sudo yum remove 查詢結果sql
【權限全開】
sudo chmod 777 安裝包
【安裝】默認路徑 usr/java/
sudo rpm -ivh 安裝包
【環境變量】
sudo vim /etc/profile
export JAVA_HOME=/usr/java/路徑
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
………………………………………………………………【JDK】
………………………………………………………………【Tomcat】
【windows 和 虛擬機共享目錄】C:\Users\sunw31\Documents\Virtual Machines\vms
【tar -zvxf 壓縮包】z=gz v=verbose x=extract f=force
【環境配置】
export CATALINA_HOME=/developer/apache-tomcat-7.0.73
【CATALINA_BASE 默認系統盤idea.system下】只能修改 idea.properties 的 idea.system 從而改變路徑 CATALINA_BASE。
【配置 UTF-8 字符集】
cd $CATALINA_HOME/conf
vim server.xml
找到配置 <Connector port="8080" 增長屬性 URIEncoding="UTF-8"
【驗證】bin/startup.sh 看一下。
ifconfig 拿 ip 訪問下,訪問不了看下防火牆。
………………………………………………………………【Tomcat】
………………………………………………………………【Maven】
tar -zvxf
/etc/profile
export MAVEN_HOME=/developer/apache-maven-xxx
【settings.xml】nexus + mirror
【經常使用命令】
mvn clean
mvn compile
mvn package
mvn clean package -Dmaven.test.skip=true
………………………………………………………………【Maven】
………………………………………………………………【vsftpd】
【安裝】sudo yum -y install vsftpd
【檢查】rpm -qa | grep vsftpd
【配置文件位置】/etc/vsftpd/vsftpd.conf
【建立虛擬用戶】意思是說 這個用戶有權限上傳 下載 rwx...
cd /
mkdir ftpfile
useradd ftpuser -d /ftpfile -s /sbin/nologin
chown -R ftpuser.ftpuser /ftpfile
sudo passwd ftpuser
cd ftpfile下 建立一個 index.html 等下訪問看到
【配置加入虛擬用戶 分離主配置 】
cd /etc/vsftpd
sudo vim chroot_list 寫個內容 "ftpuser"
【關閉selinux】sudo vim /etc/selinux/config
SELINUX=disabled
sudo setenforce 0
【若是 505 錯誤】sudo setsebool -P ftp_home_dir 1 而後重啓機器
【參考配置】
本項目要用到的配置項: 1)local_root=/ftpfile(當本地用戶登入時,將被更換到定義的目錄下,默認值爲各用戶的家目錄) 2)anon_root=/ftpfile(使用匿名登入時,所登入的目錄) 3)use_localtime=YES(默認是GMT時間,改爲使用本機系統時間) 4)anonymous_enable=NO(不容許匿名用戶登陸) 5)local_enable=YES(容許本地用戶登陸) 6)write_enable=YES(本地用戶能夠在本身家目錄中進行讀寫操做) 7)local_umask=022(本地用戶新增檔案時的umask值) 8)dirmessage_enable=YES(若是啓動這個選項,那麼使用者第一次進入一個目錄時,會檢查該目錄下是否有.message這個檔案,若是有,則會出現此檔案的內容,一般這個檔案會放置歡迎話語,或是對該目錄的說明。默認值爲開啓) 9)xferlog_enable=YES(是否啓用上傳/下載日誌記錄。若是啓用,則上傳與下載的信息將被完整紀錄在xferlog_file 所定義的檔案中。預設爲開啓。) 10)connect_from_port_20=YES(指定FTP使用20端口進行數據傳輸,默認值爲YES) 11)xferlog_std_format=YES(若是啓用,則日誌文件將會寫成xferlog的標準格式) 12)ftpd_banner=Welcome to mmall FTP Server(這裏用來定義歡迎話語的字符串) 13)chroot_local_user=NO(用於指定用戶列表文件中的用戶是否容許切換到上級目錄) 14)chroot_list_enable=YES(設置是否啓用chroot_list_file配置項指定的用戶列表文件) 15)chroot_list_file=/etc/vsftpd/chroot_list(用於指定用戶列表文件) 16)listen=YES(設置vsftpd服務器是否以standalone模式運行,以standalone模式運行是一種較好的方式,此時listen必須設置爲YES,此爲默認值。建議不要更改,有不少與服務器運行相關的配置命令,須要在此模式下才有效,若設置爲NO,則vsftpd不是以獨立的服務運行,要受到xinetd服務的管控,功能上會受到限制) 17)pam_service_name=vsftpd(虛擬用戶使用PAM認證方式,這裏是設置PAM使用的名稱,默認便可,與/etc/pam.d/vsftpd對應) userlist_enable=YES(是否啓用vsftpd.user_list文件,黑名單,白名單均可以 18)pasv_min_port=61001(被動模式使用端口範圍最小值) 19)pasv_max_port=62000(被動模式使用端口範圍最大值) 20)pasv_enable=YES(pasv_enable=YES/NO(YES) 若設置爲YES,則使用PASV工做模式;若設置爲NO,則使用PORT模式。默認值爲YES,即便用PASV工做模式。 FTP協議有兩種工做方式:PORT方式和PASV方式,中文意思爲主動式和被動式。 1、PORT(主動)方式的鏈接過程是:客戶端向服務器的FTP端口(默認是21)發送鏈接請求,服務器接受鏈接,創建一條命令鏈路。 當須要傳送數據時,客戶端在命令鏈路上用 PORT命令告訴服務器:「我打開了****端口,你過來鏈接我」。因而服務器從20端口向客戶端的****端口發送鏈接請求,創建一條數據鏈路來傳送數據。 2、PASV(被動)方式的鏈接過程是:客戶端向服務器的FTP端口(默認是21)發送鏈接請求,服務器接受鏈接,創建一條命令鏈路。 當須要傳送數據時,服務器在命令鏈路上用 PASV命令告訴客戶端:「我打開了****端口,你過來鏈接我」。因而客戶端向服務器的****端口發送鏈接請求,創建一條數據鏈路來傳送數據。 從上面能夠看出,兩種方式的命令鏈路鏈接方法是同樣的,而數據鏈路的創建方法就徹底不一樣。而FTP的複雜性就在於此。 )
sudo vim /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). local_root=/product/ftpfile #chroot_local_user=YES anon_root=/product/ftpfile use_localtime=YES #匿名 #anonymous_enable=YES anonymous_enable=NO # # Uncomment this to allow local users to log in. local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. #anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # The target log file can be vsftpd_log_file or xferlog_file. # This depends on setting xferlog_std_format parameter xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # The name of log file when xferlog_enable=YES and xferlog_std_format=YES # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log #xferlog_file=/var/log/xferlog # # Switches between logging into vsftpd_log_file and xferlog_file files. # NO writes to vsftpd_log_file, YES to xferlog_file xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: ftpd_banner=Welcome to mmall FTP Server # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). chroot_local_user=NO chroot_list_enable=YES # (default follows) chroot_list_file=/etc/vsftpd/chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES #pasv_enable=YES pasv_min_port=61001 pasv_max_port=62000
【配置防火牆端口範圍】 + iptables 起到一個限制的做用
sudo vim /etc/vsftpd/vsftpd.conf
pasv_min_port=61001
pasv_max_port=62000
【防火牆配置】sudo vim /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Fri Jan 6 16:53:09 2017 #*filter #:INPUT ACCEPT [174:12442] #:FORWARD ACCEPT [0:0] #:OUTPUT ACCEPT [96:10704] #-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT #-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT #-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT #COMMIT # Completed on Fri Jan 6 16:53:09 2017 #------------------------------------ # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT #ssh port -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT #vsftpd -A INPUT -p TCP --dport 61001:62000 -j ACCEPT -A OUTPUT -p TCP --sport 61001:62000 -j ACCEPT -A INPUT -p TCP --dport 20 -j ACCEPT -A OUTPUT -p TCP --sport 20 -j ACCEPT -A INPUT -p TCP --dport 21 -j ACCEPT -A OUTPUT -p TCP --sport 21 -j ACCEPT #mysql port -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT #tomcat remote debug port -A INPUT -p tcp -m tcp --dport 5005 -j ACCEPT -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT #nginx -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
sudo service iptables restart
【驗證 very secure ftp daemon】
sudo service vsftd restart
=>瀏覽器 ftp://ifconfig ftpuser 123456
=>終端 ftp ip 一樣輸入密碼
=> filezilla
………………………………………………………………【vsftpd】
………………………………………………………………【nginx】
反向代理服務器 => 負載均衡服務器 => 郵件代理服務器 => 前端靜態和動態分離
【安裝依賴】
yum -y install gcc-c++ zlib zlib-devel pcre-devel openssl openssl-devel
【tar -zvxf】
【默認安裝】/usr/local/nginx 查 whereis nginx
cd 進入 ./configure (可選指定本身想要的安裝路徑 --prefix=/developer/nginx )
make
make install
【經常使用命令】
測試或檢查配置文件 nginx/sbin/nginx -t
啓動命令 nginx/sbin/nginx 啓動後 ps aux | grep nginx 打開瀏覽器看下
中止命令 nginx/sbin/nginx -s stop
重啓命令 nginx/sbin/nginx -s reload
平滑重啓(熱) kill -HUP pid
查看進程 ps -ef | grep nginx
【開發防火牆 80端口】
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
【驗證】
啓動 ${nginx}/sbin/nginx
重啓 ${nginx}/sbin/nginx -s reload ==========
http://ifconfig 訪問 80 端口
………………………………………………………………………………………………………………………………
【配置可維護的 vhost】nginx 虛擬域名的配置
sudo vim /usr/local/nginx/conf/nginx.conf
追加 include vhost/*.conf;
cd /usr/local/nginx/conf
mkdir vhost
【建立域名轉發配置文件】
learning.istone.com.conf
istone.com.conf
img.istone.com.conf
s,istone.com.conf
【沒有本身的域名 能夠先用 Host 須要重啓瀏覽器】
【linux桌面下】sudo vim /etc/hosts
192.168.222 www.izxvf.com
【建立 vhost conf 域名轉發】從nginx.conf 分離出來 include部分
cd /usr/local/nginx/conf/vhost/
sudo vim www.izxvf.com.conf
server { listen 80; autoindex on; server_name www.istone.com; access_log /usr/local/nginx/logs/access.log combined; index index.html index.htm index.jsp index.php; #error_page 404 /404.html; if ( $query_string ~* ".*[\;'\<\>].*" ){ return 404; } location / { proxy_pass http://127.0.0.1:8080; add_header Access-Control-Allow-Origin *; } }
【修改完配置重啓一下】記住 chrome 強制 https 因此能夠刪除一下 chrome://net-internals/#hsts
【vhost 圖片服務器轉發】
cd vhost
sudo vim image.izxvf.com.conf
server { listen 80; autoindex off; server_name image.istone.com; access_log /usr/local/nginx/logs/access.log combined; index index.html index.htm index.jsp index.php; #error_page 404 /404.html; if ( $query_string ~* ".*[\;'\<\>].*" ){ return 404; } location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* { deny all; } location / { root /ftpfile/ftpfile/; add_header Access-Control-Allow-Origin *; } }
【vhost 靜態資源服務器 示例】autoindex off 關掉索引
server { listen 80; autoindex off; server_name s.happymmall.com; access_log /usr/local/nginx/logs/access.log combined; index index.html index.htm index.jsp index.php; if ( $query_string ~* ".*[\;'\<\>].*" ){ return 404; } location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* { deny all; } location / { root /product/front/; add_header Access-Control-Allow-Origin *; } }
………………………………………………………………【nginx】
………………………………………………………………【nginx + vsftpd】
經過程序上傳文件到 vsftpd
而後 nginx 獲得 文件 url。
………………………………………………………………【nginx + vsftpd】
………………………………………………………………【mysql】
【安裝】yum -y install mysql-server
【默認配置】/etc/my.cnf
【字符集配置】
sudo vim /etc/my.cnf
[mysqld]
default-character-set=utf8mb4
character-set-server=utf8mb4
【5.1 版本中文亂碼】
my.ini 的 [mysql] 和 [mysqld] 【default-character-set=utf8】
【5.5 版本中文亂碼】
my.ini 的 [mysqld] 更改成 【character-set-server=utf8】
【自啓動配置】
chkconfig mysqld on
chkconfig --list mysqld 查看 on 狀態 2到5位。
【防火牆配置】入站 開放 3306
【啓動 mysqld 服務】service mysqld start
【查看目前 mysql 用戶】select user,host,passwd from mysql.user;
=> 【刪除匿名用戶 執行下】delete from mysql.user where user='';
=>【刷薪後生效】flush privileges;
【修改下密碼】set passwd for root@localhost=passwd('youpasswd');
【添加一個用戶】
insert into mysql.user(Host,User,Password) values ("localhost","yourusername",password("yourpassword"));
=>【刷薪後生效】flush privileges
【建立新的數據庫】create database `mmall` default character set utf8 collate utf8_general_ci;
【查看已經有的全局權限】select * from mysql.user \G -- 有可能已經賦值了Y 可是 N。
【賦予全部權限】grant all privileges on mmall.* to yourusername@127.0.0.1 identified by 'yourpassword'
【開通外網權限】grant all privileges on mmall.* to yourusername@'%' identified by 'yourpassword'
【賦予部分權限】grant select,update,insert ...
=>【刷薪後生效】flush privileges
………………………………………………………………【mysql】
………………………………………………………………【git】
【安裝依賴】sudo yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install
【配置】git config --global user.name "your"
git config --gloabl user.email "@email"
【其餘配置】
[kdiff3軟件]git config --global merge.tool "kdiff3"
【windows 和 linux 換行符】git config --global core.autocrlf false;
【git gui 亂碼】git config --global gui.encoding utf-8
【git status 亂碼】git config --global core.quotepath off
【windows 設置一下】git config --global core.ignorecase false
【ssh key pair】
ssh-keygen -t rsa -C "i@email."
ssh-add ~/.ssh/id_rsa
=> 報錯 eval `ssh-agent` 再 ssh-add ~... => ssh-add -l
【驗證】git --version
【git 經常使用命令】
git branch -r
git checkout 要切換分支
git branch 當前分支
………………………………………………………………【git】
========================================【數據庫設計】
有些設計技巧 => 放到個人 《數據庫概要設計》那邊總結 https://www.cnblogs.com/chenhui7373/p/9076608.html
========================================【數據庫設計】