在Linux系统搭建web服务器
一.安装jdk
在/usr/local下创建Java目录
mkdir /usr/local/java
mv jdk-8u191-linux-x64.tar.gz /usr/local/java
将压缩包解压
tar -zxvf jdk-8u191-linux-x64.tar.gz
配置环境变量
vi /etc/profile
在最后加上下面几行
JAVA_HOME=/usr/local/java/jdk1.8.0_191
JRE_HOME=/usr/local/java/jdk1.8.0_191/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
让配置文件生效
source /etc/profile
查看Java是否安装成功
java -vesion
二.安装tomcat
在/usr/local下创建tomcat目录
mkdir /usr/local/tomcat
mv apache-tomcat-8.5.34.tar.gz /usr/local/java
将压缩包解压
tar -zxvf apache-tomcat-8.5.34.tar.gz
启动tomcat
cd /usr/local/tomcat/apache-tomcat-8.5.34/bin
./startup.sh
查看日志文件
cd /usr/local/tomcat/apache-tomcat-8.5.34/logs
cat catalina.out 查看日志文件
cd /usr/local/tomcat/apache-tomcat-8.5.34/confg
修改tomcat端口默认为8080
vi server.xml 修改tomcat端口默认为8080
关闭防火墙
systemctl stop firewalld
登录192.168.81.201.8080查看是否连接到tomcat
部署Javaweb项目 到Tomcat服务器
就是将编写好的JavaWeb应用打包成war包,然后发布到tomcat服务器的webapps目录下
三.安装mysql
1.下载
下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads
下载版本:我这里选择的5.6.33,通用版,linux下64位也可以直接复制64位的下载地址wget http://dev.mysql.com/get/Downloa ... bc2.5-x86_64.tar.gz
2、解压
解压:tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
复制解压后的mysql目录:cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
3、添加用户组和用户
添加用户组:groupadd mysql
添加用户mysql 到用户组mysql:useradd -g mysql mysql
4、安装
因为我们是编译安装需要生成configure文件需要下载编译工具
yum install autoconf -y
安装时的一些错误
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
解决: yum -y install perl perl-devel
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:yum -y install libaio-devel
cd /usr/local/mysql/
mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
5.#修改启动脚本
vi /etc/init.d/mysqld
6.#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
7.#启动服务
service mysqld start
8.#测试连接
./mysql/bin/mysql -uroot
9.#加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
10.#启动mysql
service mysqld start
关闭mysql
service mysqld stop
查看运行状态
service mysqld status
11、远程连接错误
11.1 sqlyog连接时,报1130错误,是由于没有给远程连接的用户权限问题
解决1:更改 ‘mysql’数据库‘user’表‘host’项,从‘localhost’改成‘%’。
use mysql;
select 'host' from user where user='root';
update user set host = '%' where user ='root';
flush privileges;
解决2:直接授权
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;
11.2 安装时的一些错误
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
解决: yum -y install perl perl-devel
Installing MySQL system tables…/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:yum -y install libaio-devel
12、其他
配置环境变量
vi /etc/profile
export PATH=....:/usr/local/mysql/bin
————————————————
|
|