Centos7 安裝MySQL
下載MySQL源
- 再網(wǎng)頁復(fù)制此鏈接: https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
- mkdir /home/mysql && cd /home/mysql
- wget
https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
下載
- yum localinstall mysql80-community-release-el7-1.noarch.rpm
- yum install mysql-community-server
運(yùn)行
- 啟動MySQL: systemctl start mysqld
- 重啟MySQL: systemctl restart mysqld
- 停止MySQL: systemctl stop mysqld
- 設(shè)置開機(jī)啟動: systemctl enable mysqld
修改初始密碼
- grep 'temporary password' /var/log/mysqld.log 來查看默認(rèn)的初始密碼
- 登錄MySQL, 修改密碼: alter user 'root'@'localhost identified by 'PASSWORD';
- ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';
添加遠(yuǎn)程登錄
- 選擇數(shù)據(jù)庫: use DataBase;
- grant all on . to 'root'@'%'; 或者: update user set host='%' where user='root';
- flush privileges; 刷新權(quán)限
卸載MySQL
- yum remove mysql-community-server
- 刪除文件: rm -rf /var/lib/mysql
- rm /etc/my.cnf
- rm -rf /usr/share/mysql-8.0
CentOS7防火墻firewalld配置
-
啟動: systemctl start firewalld
-
停止: systemctl stop firewalld
-
重啟: systemctl restart firewalld.service
-
查看防火墻的狀態(tài): systemctl status firewalld
- 設(shè)置開機(jī)啟動: systemctl enable firewalld.service
- 設(shè)置開機(jī)禁用: systemctl disable firewalld
- 查看是否開機(jī)啟動: systemctl is-enabled firewalld.service
- 查看已啟動的服務(wù)列表: systemctl list-unit-files|grep enabled
- 查看啟動失敗的服務(wù)列表:systemctl --failed
- 查看版本:firewall-cmd --version
- 查看幫助:firewall-cmd --help
- 顯示狀態(tài):firewall-cmd --state
-
查看所有打開的端口:firewall-cmd --zone=public --list-ports
-
更新防火墻規(guī)則:firewall-cmd --reload
- 查看區(qū)域信息:firewall-cmd --get-active-zones
- 查看指定接口所屬區(qū)域:firewall-cmd --get-zone-of-interface=eth0
-
開放某個端口: firewall-cmd --zone=public --add-port=80/tcp --permanent
- 查看80端口:firewall-cmd --zone=public --query-port=80/tcp
- firewall-cmd --zone=public --add-port=8888/tcp --permanent
- firewall-cmd --zone=public --add-port=8080/tcp --permanent
- firewall-cmd --zone=public --add-port=21/tcp --permanent
- firewall-cmd --zone=public --add-port=22/tcp --permanent
- firewall-cmd --zone=public --add-port=3306/tcp --permanent
- firewall-cmd --zone=public --add-port=443/tcp --permanent
-
刪除80端口:firewall-cmd --zone=public --remove-port=80/tcp --permanent
-
開放端口區(qū)間:firewall-cmd --permanent --zone=public --add-port=8080-9999/tcp //永久
- 重新載入使配置立即生效:firewall-cmd --reload
Centos7 安裝 Nginx
- 安裝pcre庫是為了使Nginx支持具備URL重寫功能的Rewite模塊艳狐,如不安裝則Nginx無法使用此模塊功能(典型功能為偽靜態(tài))yum -y install pcre-devel
- 安裝編譯需要的組件: yum -y install zlib-devel openssl-devel
- 創(chuàng)建軟件配套專用的用戶(禁止登錄及不創(chuàng)建家目錄) : [root@localhost ~]# useradd www -s /sbin/nologin -M
- 切換目錄 : cd /usr/src/
- 下載: wget http://nginx.org/download/nginx-1.12.2.tar.gz && tar -zxf nginx-1.12.2.tar.gz
--2018-03-02 13:05:56-- http://nginx.org/download/nginx-1.12.2.tar.gz
- cd nginx-1.12.2
- 編譯配置文件 : ./configure --user=www --group=www --prefix=/usr/local/nginx-1.12.2 --with-mail_ssl_module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module
- 編譯 : make && make install
- 創(chuàng)建軟鏈接 : ln -s /usr/local/nginx-1.12.2/ /usr/local/nginx
centOS7 安裝JDK11
- 檢查自帶的jdk : rpm -qa |grep jdk
- 如果有輸出信息,批量卸載系統(tǒng)自帶 : rpm -qa | grep java | xargs rpm -e --nodeps
- 將JDK壓縮文件包上傳到服務(wù)器
- 在 /usr/java 目錄中解壓壓縮包
- vim /etc/profile 在最后面添加(目的就是將Java以及tomcat添加為環(huán)境變量):
# java 的配置
export JAVA_HOME=/usr/java/jdk-11.0.6
export CLASPATH=$JAVA_HOME/lib
export CATALINA_HOME=/home/jefxff/www/tomcat/tomcat-a
export CATALINA_2_HOME=/home/jefxff/www/tomcat/tomcat-b
export PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME:$CATALINA_2_HOME
- 執(zhí)行: source /etc/profile
編輯tomcat/server.xml以及nginx/nginx/conf進(jìn)行配置
配置 tomcat-a 和 tomcat-b
- 將tomcat上傳到服務(wù)器/home/jefxff/www/tomcat/, 并且復(fù)制一份, 分別為 tomcat-a 和 tomcat-b
- 配置tomcat-a 和 tomcat-b 的 server.xml
- tomcat-a : server:10800; http:1005; ajp:1009; ajp中添加secretRequired=""
- tomcat-b : server:20800; http:2005; ajp:2009; ajp中添加secretRequired=""
- 配置 tomcat-b /bin/catalina.sh, 在頂部添加
- export CATALINA_BASE=$CATALINA_2_BASE
- export CATALINA_HOME=$CATALINA_2_HOME
- export TOMCAT_HOME=$TOMCAT_2_HOME
配置 /usr/local/nginx/conf/nginx.conf
# 配置tomcat服務(wù)
upstream tomcatServer{
ip_hash;
server localhost:1080 weight=1;
server localhost:2080 weight=1;
}
# 在location / 下面添加
proxy_pass http://tomcatServer;
編寫用于啟動的小腳本
#! /bin/bash
case $1 in
"start" )
echo "[ 啟動 ] nginx..."
/usr/local/nginx/sbin/nginx
echo "[ 啟動 ] Tomcat-a..."
/home/jefxff/www/tomcat/tomcat-a/bin/startup.sh
echo "[ 啟動 ] Tomcat-b..."
/home/jefxff/www/tomcat/tomcat-b/bin/startup.sh
;;
"stop")
echo "[ 關(guān)閉 ] nginx..."
/usr/local/nginx/sbin/nginx -s stop
echo "[ 關(guān)閉 ] Tomcat-a..."
/home/jefxff/www/tomcat/tomcat-a/bin/shutdown.sh
echo "[ 關(guān)閉 ] Tomcat-b..."
/home/jefxff/www/tomcat/tomcat-b/bin/shutdown.sh
;;
"*")
echo "輸入指令錯誤..."
;;
esac
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者