安装openJdk
https://www.cnblogs.com/ymlyxp/p/15876892.html
查看yum中jdk版本
yum search java|grep jdk
安装openjdk1.8 出现Y按Y
yum install java-1.8.0-openjdk
java -version
安装开发环境(默认在usr/lib/jvm)
yum install java-1.8.0-openjdk-devel.x86_64
修改/etc/profile文件:
vi /etc/profile
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-xxxx 这就是刚刚说的那个路径的名称JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
source /etc/profile
安装 nginx
https://blog.csdn.net/qq_34200979/article/details/123016644
安装包目录 进人
/usr/local/
添加源
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装Nginx
sudo yum install -y nginx
启动Nginx并设置开机自动运行
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
开放端口
https://blog.csdn.net/qq_33088807/article/details/122088273
(打开防火墙)
systemctl start firewalld.service
(允许http服务)
sudo firewall-cmd --add-service=http --permanent
(打开80端口、如果是mysql就打开3306端口)
sudo firewall-cmd --add-port=80/tcp --permanent
(端口重新加载)
sudo firewall-cmd --reload
(查看端口开放情况)
sudo firewall-cmd --list-all
发现 services: 出现 http 服务,ports:出现了80 端口:
yum方式安装后默认配置文件的路径
/etc/nginx/nginx.conf
nginx网站默认存放目录
/usr/share/nginx/html
网站默认主页路径
/usr/share/nginx/html/index.html
启动nginx
service nginx start
停止nginx
service nginx stop
重载nginx
service nginx reload
查看进程apache/httpd
ps -ef | grep nginx
查看服务端口
netstat -anpl | grep 'nginx'
安装mysql
https://www.jb51.net/article/216796.htm
安装包目录 进人
/usr/local/
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz
解压
tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz
复制一份mysql #详解: mv 当前文件名称 修改的文件夹名称
mv mysql-8.0.25-linux-glibc2.12-x86_64 mysql-8.0.25
创建mysql 存放数据目录
mkdir -p /data/mysqldata/
创建用户组
groupadd mysql
创建用户
useradd -r -g mysql mysql
赋权限 #chown 用户名:用户组 -R /data/mysqldata
chown mysql:mysql -R /data/mysqldata
chmod 750 /data/mysqldata/ -R
配置mysql环境
vim /etc/profile
export PATH=$PATH:你的MySQL解压路径/mysql-8.0.25/bin:你的MySQL解压路径/mysql-8.0.25/lib
export PATH=$PATH:/usr/local/mysql-8.0.25/bin:/usr/local/mysql-8.0.25/lib/
重新加载profile
source /etc/profile
配置mysql 编辑my.cnf文件(默认就有)
vim /etc/my.cnf
[mysql]
default-character-set=utf8mb4
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
[mysqld]
port=3306
server-id=3306
user=mysql
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
basedir=/usr/local/mysql-8.0.25
datadir=/data/mysqldata/mysql
log-bin=/data/mysqldata/mysql/mysql-bin
innodb_data_home_dir=/data/mysqldata/mysql
innodb_log_group_home_dir=/data/mysqldata/mysql
character-set-server=utf8mb4
lower_case_table_names=1
autocommit=1
symbolic-links=0
[mysqld_safe]
log-error=/data/mysqldata/mysql/mysql.log
pid-file=/data/mysqldata/mysql/mysql.pid
初始化mysql
cd /usr/local/mysql-8.0.25/bin
初始化mysql
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql-8.0.25/ --datadir=/data/mysqldata/mysql --user=mysql --initialize
一定要记住mysql初始密码 每个人都不一样
复制 mysql.server 文件
cp /usr/local/mysql-8.0.25/support-files/mysql.server /etc/init.d/mysql
cp /usr/local/mysql-8.0.25/support-files/mysql.server /etc/init.d/mysqld
赋予权限
chown 777 /etc/my.cnf
chmod +x /etc/init.d/mysql
chmod +x /etc/init.d/mysqld
检查一下/var/lib/mysql是否存在,否进行创建 #目录和my.cnf保持一致
mkdir /var/lib/mysql
赋予权限 #目录和my.cnf保持一致
chown -R mysql:mysql /var/lib/mysql/
启动数据库
service mysql start #或者 systemctl mysql start
开放mysql端口号 查看3306端口号是否开放
firewall-cmd --zone=public --query-port=3306/tcp
开放3306端口
sudo firewall-cmd --add-port=3306/tcp --permanent
重启
sudo firewall-cmd --reload
查看
sudo firewall-cmd --list-all
修改密码和远程访问
mysql -u root -p
----mysq初始化密码
修改root密码 修改root用户只能本地连接
ALTER USER 'root'@'localhost' IDENTIFIED with mysql_native_password BY 'root2022';
刷新权限
flush privileges
修改root远程连接(生产别这么搞)
update mysql.user set user.Host='%' where user.User='root';
刷新权限
flush privileges
|