Centos安装宝典

JDK安装
1.进入root模式
su root
用户密码
2.查询系统是否存在java,存在就使用 {rpm -e --nodeps 上面显示的文件名}进行删除
rpm -qa|grep java
rpm -qa|grep jdk
rpm -qa|grep gcj
3.创建文件夹来存放
mkdir /usr/local/java
mkdir /usr/local/tomcat
mkdir /usr/local/mysql
4.解压jdk
tar xf jdk文件名
5.移动jdk
mv 解压后jdk文件名/* /usr/local/java 
6.配置环境 
ls -a显示全部文件,包括隐藏文件
vi .bashrc 进入vim编辑配置环境(添加在最下面)按o进入编辑模式
export JAVA_HOME=/usr/local/java

export JAVA_BIN=$JAVA_HOME/bin

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
输入完后按ESC :wq 回车返回
source .bashrc是配置生效
java -version 查看JDK环境是否生效


tomcat安装
7.解压tomcat
tar xf tomcat文件名
8.移动jdk
mv 解压后tomcat文件名/* /usr/local/tomcat
9.tomcat配置
b、启动Tomcat(启动前先进行防火墙设置)
cd /usr/local/tomcat/bin
./startup.sh
unzip -oq controlservices.war -d /usr/local/tomcat/webapps/controlservices/  
c、关闭Tomcat
shutdown.sh

防火墙设置(如果要更新端口先进行更新端口操作)(如果要进行端口号修改,先修改端口号)

执行firewall-cmd --zone=public --add-port=端口号/tcp --permanent,提示success,表示设置成功,提示FirewallD is not runninga则表示未成功

未成功操作(systemctl status firewalld查看firewalld状态,发现当前是dead状态,即防火墙未开启。、

通过systemctl start firewalld开启防火墙,没有任何提示即开启成功。
(出现ismasked则表明firewalld服务被锁定,不能添加对应端口


执行命令systemctl unmask firewalld,即可实现取消服务的锁定
下次需要锁定该服务时执行

# systemctl mask 
systemctl stop firewalld这条指令来关闭该功能。)
再次通过systemctl status firewalld查看firewalld状态,显示running即已开启了。
再次执行执行firewall-cmd --permanent --zone=public --add-port=端口号/tcp,提示success,表示设置成功
更新防火墙规则:firewall-cmd --reload)

更新防火墙规则:firewall-cmd --reload
firewall-cmd --zone=public --list-ports查看端口号是否已经添加

10.配置端口(端口号不修改默认8080)

可以修改conf目录下的文件server.xml,修改Connector元素(Tomcat的默认端口是8080),需要重新启动Tomcat服务生效。

vim /usr/local/tomcat/conf/server.xml


11、访问Tomcat

http://ip:端口号/

http://localhost:80/


12、添加应用


cd /usr/local/tomcat/webapps
把war加入到webapps中,tomcat会自动解压war包


更新程序
先进入启动tomcat
cd /usr/local/tomcat/
./startup.sh
查看服务号关闭tomcat
ps -ef|grep java
kill -9 root后面的服务号
再次查看
ps -ef|grep java
如果没有就进行原来项目的删除
进入webapps
cd /usr/local/tomcat/webapps
rm -rf 项目名称
rm -f 项目名称.war
最后上传新的到webapps下
chmod 更新权限


mysql安装
rpm -qa|grep mariadb
先用rpm -qa|grep mysql查看mysql是否存在
如果存在就用 rpm -e --nodeps 上面查出的文件名进行删除
ps -ef|grep mysqld
sudo killall mysqld杀死进程
13.解压mysql
tar xf mysql包名 

14.移动到mysql包中
mv 解压后mysql文件名/* /usr/local/mysql

16.为centos添加mysql用户组和mysql用户(-s /bin/false参数指定mysql用户仅拥有所有权,而没有登录权限):
groupadd mysql
useradd -r -g mysql -s /bin/false mysql

17.进入安装mysql软件的目录
cd /usr/local/mysql

18.修改当前目录拥有者为新建的mysql用户
chown -R mysql:mysql ./

19.安装mysq(记住随机密码)
./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
20.开启mysql服务:
./support-files/mysql.server start

21.将mysql进程放入系统进程中
cp support-files/mysql.server /etc/init.d/mysqld

22.重新启动mysql服务
service mysqld restart

15.为mysqk建立连接
ln -s /usr/local/mysql/bin/mysql /usr/bin

23.使用随机密码登录mysql数据库
mysql -u root -p

24.进入mysql操作行,为root用户设置新密码
alter user 'root'@'localhost' identified by '123456';

25.允许数据库远程连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;

26.刷新权限
flush privileges;

27.创建数据库
create database 数据库名;

28.进入数据库
use 数据库名;

29.设置编码
set names utf8;

30.导入sql文件
source 导入.sql文件路径;

31.退出mysql
exit;
配置3306端口开放
firewall-cmd --zone=public --add-port=端口号/tcp --permanent
firewall-cmd --zone=public --add-port=端口号/tcp --permanent
返回success为成功
更新防火墙规则:firewall-cmd --reload
firewall-cmd --zone=public --list-ports查看端口号是否已经添加

32.添加系统路径
vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH  (最下面)
source /etc/profile

34.配置mysql自动启动(未实现,缺少my.cnf文件)
(1)第一种方法
chkconfig --list | grep mysqld
chkconfig mysqld on
(2)第二种
修改系统配置文件
cd /usr/local/mysql/support-files
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysql
vim /etc/init.d/mysql
修改以下内容

basedir=/usr/local/mysql
datadir=/data/mysql)
chmod 755 /etc/init.d/mysql
chkconfig --add mysql
chkconfig --level 345 mysql on
/etc/init.d/mysql start

查看mysql状态

service mysql status

--停止mysql

service mysql stop

--启动mysql

service mysql start


36.电脑重启之后
cd /usr/local/mysql
./support-files/mysql.server start
cd /usr/local/tomcat/bin
./startup.sh

37.写入my.cnf文件(sql-mode="")
sudo vi /etc/my.cnf


**********************************************(修改端口配置)
[mysqld]

character_set_server=utf8

init_connect='SET NAMES utf8'
port=3307
~          

*********************************************

[client]
socket=/usr/local/mysql/mysql.sock
[mysqld]
sql-mode=""
lower_case_table_names=1
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.


38
cd www , 意思是 到www目录; 
cd .. , 意思是到上一级目录; 
cd - ,意思是返回到上次的目录,类似windows返回 ; 
cd /,意思是回到根目录。


**************************************************(不关也可以)

systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
--------------------- 


修改文件权限
chmod 777 文件名
修改文件所属用户
chgrp root 文件名
修改文件所属用户组
chown [-R] root 文件或目录

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
文名: CentOS宝典 原名: CentOS Bible 别名: CentOS,Linux,Bible,宝典 作者: Christopher Negus, Timothy Boronczyk资源格式: PDF 版本: 第1版 出版社: Wiley书号: 978-0-470-48165-3发行时间: 2009年 地区: 美国 语言: 英文 简介:   CentOS (Community Enterprise Operating System)   社区企业操作系统   redhat.com发布redhat 9(简写为rh9)后,不再开发redhat 10,11...,全面转向redhat enterprise linux(简写为rhel)的开发,和以往不同的是,新的rhel 3要求用户先购买lisence,redhat.com承诺保证产品的稳定性,安全性。rhel 3二进制代码不再提供下载,而是作为redhat 服务的一部分,但源代码依然是open。所以有了centos ,whitebox,dao 等等一批open source的企业版本,其中centos最为活跃。   CentOS计划所推出──全名为"社区企业操作系统"(Community Enterprise Operating System)的这个计划是在2003年红帽决定不再提供免费的技术支持及产品认证之后的部份"红帽重建者"(Red Hat rebuilders)之一。   CentOS和Linueox、组装Linux (White box Linux)、Tao Linux 、X/OS Linux,及科学Linux (Scientific Linux)等都以红帽所发布的源代码原件重建Red Hat Enterprise Linux的翻版,并修正了已经发现了的redhat的bug。   CentOS是"Caos Linux"独立计划的一个分枝,在Lawrence Berkeley 国家实验室担任管理员与程序设计师的Kurtzer 表示。但后来Caos基金会最受欢迎的计划变成是RHEL的重建。 Authoritative guide to a rapidly growing Linux distribution This is one of the first, if not the first comprehensive guide to the CentOS Linux operating system. Linux guru Tim Bornocyzyk, thoroughly covers the topic whether you're a Linux novice or a regular who now wants to master this increasingly popular distribution. First find out how to install and configure CentOS. From there, you'll cover a wealth of Linux and CentOS tools, functions, and techniques, including: how to work in the GNOME and KDE desktop environments; how to use the Linux shell, file system, and text editor; how to configure CUPS printers, Samba for file and printer sharing and other features using GUI tools; and more. CentOS (Community ENTerprise Operating System) is a Linux operating system maintained by a small team of core developers based on Red Hat Enterprise Linux (RHEL) Lead author Christopher Negus is the bestselling Linux author of such books as Fedora 10 and Red Hat Enterprise Linux Bible and Linux 2009 Edition Bible; he is also a member of the Red Hat Enterprise Linux training team Tech edited by key member of the CentOS development team, Ralph Angenendt, and foreword written by lead CentOS developer, Karanbir Singh. Learn how to set up users, automate system tasks, back up and restore files, and prepare for the latest security issues and threats; also learn how to use and customize the desktop menus, icons, window manager, and xterm; and how to create and publish formatted documents Explores available Linux multimedia applications for graphics, audio, video and CD burning The DVD includes complete copy of the most current CentOS Distribution – CentOS 5.3 For getting the most out of CentOS Linux, this is the book you need to succeed. 目录: Introduction. Part I Getting Started. Chapter 1: An Overview of CentOS. Chapter 2: Installing CentOS. Chapter 3: Getting Started with the Desktop. Chapter 4: Using Linux Commands. Part II Using CentOS. Chapter 5: Accessing and Running Applications. Chapter 6: Publishing with CentOS. Chapter 7: Music, Video, and Images in Linux. Chapter 8: Using the Internet and the Web. Part III Adminstration. Chapter 9: Understanding System Administration. Chapter 10: Setting up and Maintaining User Accounts. Chapter 11: Automating System Tasks. Chapter 12: Creating Backups and Restoring Data. Chapter 13: Security. Part IV Networking. Chapter 14: Setting Up Network Connections and LANs. Chapter 15: Setting Up an Internet Connection. Chapter 16: Setting Up Printers and Printing. Chapter 17: Setting Up a File Server. Chapter 18: Setting Up a Mail Server. Chapter 19: Setting Up an FTP Server. Chapter 20: Setting Up a Web Server. Chapter 21: Setting Up an LDAP Address Book Server. Chapter 22: Setting Up a DHCP Boot Server. Chapter 23: Setting Up a MySQL Database Server. Chapter 24: Making Servers Public with DNS. Appendix A: About the Media. Index.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值