每次搭各类环境都很痛苦,遇到各类问题,所以写下此篇记录下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';
(持续更新...)