Install JDK1.7 + tomcat7 + mysql5.5 on centos7

Source: Internet
Author: User
Tags localhost mysql

Install JDK1.7 + tomcat7 + mysql5.5 on centos7

1. Install JDK first

Step 1. Extract the tar package in the current directory

[Root @ localhost usr] # tar-xzvf jdk-7u25-linux-x64.tar.gz

Step 2: Configure Environment Variables

Add it under the etc/profile file

Export JAVA_HOME =/usr/java/jdk1.7.0 _ 25

Export CLASSPATH =/usr/java/jdk1.7.0 _ 25/lib

Export PATH = $ JAVA_HOME/bin: $ PATH

Run the following command after adding environment variables:

[Root @ localhost ~] # Source/etc/profile make the configuration file take effect immediately.

Verify that environment variables take effect

[Root @ localhost ~] # Echo $ JAVA_HOME

/Usr/java/jdk1.7.0 _ 25

[Root @ localhost ~] # Echo $ PATH

/Usr/java/jdk1.7.0 _ 25/bin:/usr/kerberos/sbin:/usr/kerberos/bin

:/Usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin: /root/bin

[Root @ localhost ~] # Echo $ CLASSPATH

/Usr/java/jdk1.7.0 _ 25/lib

Step 3: run the java-version command to verify whether the installation is successful.

[Root @ localhost tmp] # java-version

Java version "1.7.0 _ 25"

Java (TM) SE Runtime Environment (build 1.7.0 _ 25-b15)

Java HotSpot (TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

The above information indicates that the installation is successful.

Ii. install Tomcat 7

In fact, tomcat does not need to be installed. Download the tar package of tomcat directly, use tar-xvzf tomcat7.xx.tar.gz to decompress the package, and directly upload the war file of the java project to the webapps directory of tomcat, go to the bin directory under the tomcat directory and run the command to start tomcat :. /startup. sh is that simple.

Iii. Install mysql

1. Install cmake

[Root @ localhost/] # yum install cmake

[Root @ localhost ~] #/Usr/sbin/groupadd mysql

[Root @ localhost ~] #/Usr/sbin/useradd-g mysql

[Root @ localhost ~] # Tar xvf mysql-5.5.16.tar.gz
[Root @ localhost ~] # Cd mysql-5.5.16/


[Root @ localhost ~] # Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/tmp/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/var/mysql/data \
-DMYSQL_USER = mysql

If the following error is reported during this step

-- MySQL 5.5.16
-- Cocould NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline. cmake: 83 (MESSAGE ):
Curses library not found. Please install appropriate package,

Remove CMakeCache.txt and rerun cmake. On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

Solution:

[Root @ localhost mysql] # yum install ncurses-devel.x86_64
[Root @ localhost mysql] # make clean
[Root @ localhost mysql] # rm-rf CMakeCache.txt
[Root @ localhost mysql] # cmake.-LH
--
-- MySQL 5.5.21
-- Processing ing done
-- Generating done
-- Build files have been written to:/data/mysql
-- Cache values
// Choose the type of build, options are: None (CMAKE_CXX_FLAGS or
CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel
CMAKE_BUILD_TYPE: STRING = RelWithDebInfo

// Install prefix
CMAKE_INSTALL_PREFIX: PATH =/usr/local/mysql

// Set to true if this is a community build
COMMUNITY_BUILD: BOOL = ON

// Enable profiling
ENABLED_PROFILING: BOOL = ON

// Enable debug sync (debug builds only)
ENABLE_DEBUG_SYNC: BOOL = ON

// Enable gcov (debug, Linux builds only)
ENABLE_GCOV: BOOL = OFF

// Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer), RPM, DEB, SVR4
INSTALL_LAYOUT: STRING = STANDALONE

// Default MySQL data directory
MYSQL_DATADIR: PATH =/usr/local/mysql/data

// MySQL maintainer-specific development environment
MYSQL_MAINTAINER_MODE: BOOL = OFF

// Link ARCHIVE statically to the server
WITH_ARCHIVE_STORAGE_ENGINE: BOOL = OFF

// Link BLACKHOLE statically to the server
WITH_BLACKHOLE_STORAGE_ENGINE: BOOL = OFF

// Use dbug/safemutex
WITH_DEBUG: BOOL = OFF

// Compile MySQL with embedded server
WITH_EMBEDDED_SERVER: BOOL = OFF

// Options are: none, complex, all string
WITH_EXTRA_CHARSETS: STRING = all

// Link FEDERATED statically to the server
WITH_FEDERATED_STORAGE_ENGINE: BOOL = OFF

// Link INNOBASE statically to the server to statically compile innodb
WITH_INNOBASE_STORAGE_ENGINE: BOOL = ON

// Use bundled libedit
WITH_LIBEDIT: BOOL = ON

// Compile with tcp wrappers support
WITH_LIBWRAP: BOOL = OFF

// Link PARTITION statically to the server static compilation PARTITION
WITH_PARTITION_STORAGE_ENGINE: BOOL = ON

// Link PERFSCHEMA statically to the server
WITH_PERFSCHEMA_STORAGE_ENGINE: BOOL = ON

// Generate PIC objects
WITH_PIC: BOOL = OFF

// Use bundled readline
WITH_READLINE: BOOL = OFF

// Options are: no, bundled, yes (prefer OS library if present otherwise use bundled), system (use OS library)
WITH_SSL: STRING = no

// Compile MySQL with unit tests
WITH_UNIT_TESTS: BOOL = ON

// Valgrind instrumentation
WITH_VALGRIND: BOOL = OFF

// Use bundled zlib
WITH_ZLIB: STRING = bundled


Shell> cmake-L

Gives a brief overview of important configuration parameters (dump to stdout)

Shell> cmake-LH

Does the same but also provides a short help text for each parameter.

Shell> cmake-LAH

Dumps all config parameters (including advanced) to the stdout.

MYSQL parameters;
Http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

MYSQL compilation Parameters
Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_DATADIR =/data/dbdata \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_PARTITION_STORAGE_ENGINE = 1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE = 1 \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DMYSQL_UNIX_ADDR =/usr/local/mysql/tmp/mysql. sock \
-DMYSQL_TCP_PORT = 3306 \
-DENABLED_LOCAL_INFILE = 1 \
-DWITH_EXTRA_CHARSETS = all \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_SSL = yes

[Root @ localhost ~] Make.

[Root @ localhost ~] # Make
[Root @ localhost ~] # Make install
# End of source-build specific instructions
# Postinstallation setup
Shell> cd/usr/local/mysql
Shell> chown-R mysql. mysql/usr/local/mysql
[Root @ localhost mysql] # scripts/mysql_install_db -- user = mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
Support-files/mysql. server to the right place for your system

Please remember to set a password for the MySQL root USER!
To do so, start the server, then issue the following commands:

./Bin/mysqladmin-u root password 'new-password'
./Bin/mysqladmin-u root-h localhost. localdomain password 'new-password'

Alternatively you can run:
./Bin/mysql_secure_installation

Which will also give you the option of removing the test
Databases and anonymous user created by default. This is
Stronugly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon:
Cd ..;./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
Cd./mysql-test; perl mysql-test-run.pl

Please report any problems with the./bin/mysqlbug script!
Shells> cp support-files/my-medium.cnf/etc/my. cnf
Shell> bin/mysqld_safe -- user = mysql &
# Next command is optional
// Check whether MYSQL is started properly

[Root @ localhost mysql] # ps-ef | grep mysql
Root 12381 2182 0 00:00:00 pts/0/bin/sh bin/mysqld_safe -- user = mysql
Mysql 12637 12381 0 00:00:00 pts/0/usr/local/mysql/bin/mysqld -- basedir =/usr/local/mysql -- datadir =/data/dbdata -- plugin-dir = /usr/local/mysql/lib/plugin -- user = mysql -- log-error =/data/dbdata/localhost. localdomain. err -- pid-file =/data/dbdata/localhost. localdomain. pid -- socket =/usr/local/mysql/tmp/mysql. sock -- Ports = 3306
Root 12706 2236 0 00:00:00 pts/1 grep mysql
Shell> cp support-files/mysql. server/etc/init. d/mysql. server

[Root @ localhost ~] # Chmod + w/usr/local/mysql
[Root @ localhost ~] # Chown-R mysql: mysql/usr/local/mysql # change the directory owner and group

[Root @ localhost ~] # Ln-s/usr/local/mysql/lib/libmysqlclient. so.16/usr/lib/libmysqlclient. so.16
[Root @ localhost ~] # Cd support-files/
[Root @ localhost ~] # Cp my-large.cnf/etc/my. cnf # select the default configuration file suitable for large servers
[Root @ localhost ~] # Cp mysql. server/etc/init. d/mysqld # copy the Startup File

Add mysql to startup
[Root @ localhost ~] # Chmod + x/etc/init. d/mysqld
[Root @ localhost ~] # Vi/etc/init. d/mysqld (edit this file, find and modify the following variable content :)
Basedir =/usr/local/mysql
Datadir =/var/mysql/data


[Root @ localhost ~] # Chkconfig -- add mysqld
[Root @ localhost ~] # Chkconfig -- level 345 mysqld on


Start mysql
[Root @ localhost ~] # Service mysqld start

Set a password for mysql. The default password for mysql is null.

Log on to the mysql system,
# Mysql-uroot-p
Enter password: [Enter the original password] the default password is blank. Press Enter.
Mysql> use mysql;
Mysql> update user set password = passworD ("test") where user = 'root ';
Mysql> flush privileges;
Mysql> exit;

After mysql is installed, remote access is disabled by default.

Log on to the mysql system,
# Mysql-uroot-p

Enter password: After the password is entered

Mysql> use mysql;

Mysql> update user set host = '%' where user = 'root ';

Mysql> select host, user from user;

Mysql> flush privileges;
Mysql> exit;

This is the end of the process. The first write is messy and I hope to help you.

Ps:

Run the rpm-ql software name to check the software installation location.

Rpm-qa | grep software name to check whether the software is installed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.