每次搭各類環境都很痛苦,遇到各類問題,所以寫下此篇記錄下centos7下一些環境的搭建過程、遇到的問題及解決方法,有其餘環境的搭建也會進行更新。本文不值得看,但能夠收藏下,已備不時之需。本文主要參考了 從0開始 獨立完成企業級Java電商網站開發服務端
修改成國內的yum源能夠加快下載速度php
參考文章html
對於騰訊雲的雲服務器沒必要改, 默認是騰訊的源java
wget https://download.oracle.com/otn/java/jdk/8u231-b11/5b13a193868b4bf28bcb45c792fce896/jdk-8u231-linux-x64.rpm
(不能這樣下載, 由於有個什麼破協議,須要先下載而後傳上去)mysql
上傳到服務器能夠用scp命令linux
scp root@107.172.27.254:/home/test.txt . //下載文件 scp test.txt root@107.172.27.254:/home //上傳文件 scp -r root@107.172.27.254:/home/test . //下載目錄 scp -r test root@107.172.27.254:/home //上傳目錄
rpm -qa | grep jdk
yum remove xxx
chmod 777 jdk.xxx.rpm # 這裏直接給了最高權限,你們慎重
rpm -ivh jdk.xxx.rpm
在/etc/profile加的變量以下nginx
# 這裏 JAVA_HOME爲java的安裝目錄 export JAVA_HOME=/usr/java/jdk1.8.0_202-amd64 export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar
java -version
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz
# 這個我以前沒配過,貌似用處不大 export CATALINA_HOME=/devlib/apache-tomcat-8.5.50
# ${CATALINA_HOME}/conf/server.xml URIEncoding="UTF-8" <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
# 進入 ${CATALINA_HOME}/bin ./startup.sh # 訪問http://${ip}:8080/
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
mvn -version
yum -y install vsftpd
cd /etc/vsftpd vim chroot_list
將新增的ftpuser加到配置文件中sql
若是遇到550則執行 setsebool -P ftp_home_dir 1shell
配置說明參考數據庫
http://learning.happymmall.co...apache
注意幾個點:
加一行這個配置就能夠
allow_writeable_chroot=YES
# 這是centos7, 6是不同的 啓動: systemctl start firewalld 關閉: systemctl stop firewalld 查看狀態: systemctl status firewalld 開機禁用 : systemctl disable firewalld 開機啓用 : systemctl enable firewalld 開放端口 firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,沒有此參數重啓後失效) 關閉端口 firewall-cmd --zone=public --remove-port=80/tcp --permanent 查看開放的端口 firewall-cmd --zone=public --list-ports 更新防火牆規則: firewall-cmd --reload
·
service vsftpd start
#設置開機啓動 systemctl enable vsftpd.service #啓動 systemctl start vsftpd.service #中止 systemctl stop vsftpd.service #查看狀態 systemctl status vsftpd.service #重啓 systemctl restart vsftpd.service
yum install -y gcc gcc -v
yum install -y pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
yum install -y gcc pcre-devel zlib zlib-devel openssl openssl-devel
歷史版本http://nginx.org/download/
wget http://nginx.org/download/nginx-1.13.6.tar.gz
./configure # 加--prefix=/usr/nginx能夠指定安裝目錄 whereis nginx能夠查詢安裝目錄, 默認在/usr/local/
/nginx/sbin/nginx -t
/nginx/sbin/nginx
/nginx/sbin/nginx -s stop 或 nginx -s quit
/nginx -s reload
ps -ef|grep nginx
kill -HUP 進程號
在/usr/local/nginx/conf/nginx.conf增長 include vhost/*.conf 這樣方便每一個域名配搞個配置文件
server { default_type 'text/html'; charset utf-8; listen 80; # 開索引 autoindex on; server_name learning.happymmall.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:81/aa; # 真實環境別這麼寫 add_header Access-Control-Allow-Origin *; } }
server { listen 80; # 注意這裏禁止索引了 autoindex off; server_name img.happymmall.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 /product/ftpfile/img/; add_header Access-Control-Allow-Origin *; } }
yum install -y mysql-server
(centos7下這樣不行, 軟件源裏邊沒有這個,須要下載源再裝,以下)
參考文章https://www.cnblogs.com/codin...
用上面配置vsftpd自啓動的方法也能夠
chkconfig mysqld on # 2-5須要時on chkconfig --list mysqld
啓動:systemctl start mysqld.service 中止:systemctl stop mysqld.service 重啓:systemctl restart mysqld.service 查看服務狀態:systemctl status mysqld.service
刪除/var/lib/mysql 再啓動
mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
修改/etc/my.cnf 在[mysqld]下面加一行skip-grant-tables
登陸後改root密碼, 而後去掉這一行
改密碼的方法
alter user'root'@'localhost' IDENTIFIED BY '你的密碼';
https://www.cnblogs.com/gycho...
建立用戶 create user 'test1'@'localhost' identified by '‘密碼'; flush privileges;刷新權限 其中localhost指本地纔可鏈接 能夠將其換成%指任意ip都能鏈接 也能夠指定ip鏈接 修改密碼 Alter user 'test1'@'localhost' identified by '新密碼'; flush privileges; 受權 grant all privileges on *.* to 'test1'@'localhost' with grant option; with gran option表示該用戶可給其它用戶賦予權限,但不可能超過該用戶已有的權限 好比a用戶有select,insert權限,也可給其它用戶賦權,但它不可能給其它用戶賦delete權限,除了select,insert之外的都不能 這句話可加可不加,視狀況而定。 all privileges 可換成select,update,insert,delete,drop,create等操做 如:grant select,insert,update,delete on *.* to 'test1'@'localhost'; 第一個*表示通配數據庫,可指定新建用戶只可操做的數據庫 如:grant all privileges on 數據庫.* to 'test1'@'localhost'; 第二個*表示通配表,可指定新建用戶只可操做的數據庫下的某個表 如:grant all privileges on 數據庫.指定表名 to 'test1'@'localhost'; 查看用戶受權信息 show grants for 'test1'@'localhost'; 撤銷權限 revoke all privileges on *.* from 'test1'@'localhost'; 用戶有什麼權限就撤什麼權限 刪除用戶 drop user 'test1'@'localhost';
(持續更新...)