In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "how to install mysql, Nginx and Tomcat services". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor learn how to install mysql, Nginx and Tomcat services.
one。 Features of MySQL1.1 MySQL Services Foundation 1.1.1 MySQL
Multi-thread and multi-user
Based on Cpact S (client / server) architecture
Easy to use and fast to query
Safe and reliable
1.1.2 required software installation package
1. Ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
2 、 cmake-2.8.6.tar.gz
3 、 mysql-5.5.22.tar.gz
1.1.3 main installation steps for MySQL
1. Uninstall mysql-server,mysql and install the ncurses package
2. Compile and install the cmakepackage
3. Compile and install MySql with source code
4. Other adjustments after installation
5. Add as a system service and start the service
1.1.4 MySQL build configuration command
1. Uninstall mysql-server,mysql and install the ncurses package
# rpm-Q mysql-server mysql / / confirm that mysql-server and mysql are not installed using RPM
# rpm-ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm / / install the ncurses-devel package
two。 Compile and install the cmakepackage
# tar zxf cmake-2.8.6.tar.gz
# cd cmake-2.8.6
#. / configure
# gmake & & gmake install
3. Source code compilation and installation
# groupadd mysql / / add mysql group
# useradd-M-s / sbin/nologin mysql-g mysql / / add the user mysql of the mysql group
# tar zxf mysql-5.5.22.tar.gz-C / usr/src/
# cd / usr/src/mysql-5.5.22/
# cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql / / specify the compilation installation location
-DSYSCONFDIR=/etc
-DDEFAULT_CHARSET=utf8 / / sets the default font
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
# make
# make install
4. Other adjustments after installation
# chown-R mysql:mysql / usr/local/mysql / / set the directory permissions of the database
# cp support-files/my-medium.cnf / etc/my.cnf / / create a configuration file
# / usr/local/mysql/scripts/mysql_install_db
-- user=mysql-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data/ initialize the database
# echo "PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile / / set environment variables
#. / etc/profile / / execute the configuration of environment variables
1.2 add as system service, start service
# cp support-files/mysql.server / etc/rc.d/init.d/mysqld
# chmod + x / etc/rc.d/init.d/mysqld / / add executable permissions
# chkconfig-- add mysqld / / add mysqld system service
# service mysqld start / / start mysql
# / etc/init.d/mysql status / / View the startup status of mysql
# netstat-anpt | grep mysqld / / View mysql service port
1.3 access to MySQL database
# mysql-u root [- p] / /-u is followed by a login user, and-p is a password login
# mysql-u root-p password / / set the password of the database user name
# mysql > exit / / exit the MySQL operating environment
1.4 maintain database and user permissions 1.4.1 set user permissions
GRANT permission list ON database name. Table name TO username @ source address [IDENTIFIED BY 'password']
/ / if the user does not exist, create a new user
SHOW GRANTS FOR user name @ Source address / / View the user's permissions
REVOKE permission list ON database name. Table name FROM user name @ Source address / / revoke the user's permissions
1.4.2 backup and recovery of database
1. Backup of database
Mysqldump-u username-p [password] [option] [database name] [table name] > / backup path / backup file name
Common options:-- all-databases,-- opt
# mysqldump-u root-p mysql user > / mysoft/mysql-user.sql / / back up the table
# mysqldump-u root-p-databases mysql > / mysoft/mysql.sql / / backup Library
# mysqldump-u root-p-opt-- all-databases > all-data.sql / / back up all libraries
two。 Recovery of database
Mysql-u root-p [database name]
< /备份路径/备份文件名 #mysql -u root -p test < /mysoft/mysql-user.sql #mysql -u root -p < /mysoft/mysql.sql 二. Apache2.1 Apache网站服务基础2.1.1所需软件包 1、bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm 2、bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm 3、bind-libs-9.8.2-0.17.rc1.el6_4.6.x86_64 4、bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64 //安装dns 5、httpd-2.2.17.tar.gz //安装httpd服务器 6、awstats-7.3.tar.gz //安装AWStats分析系统 2.1.2 httpd服务的主要配置文件和目录 服务目录 /usr/local/httpd/ 主配置文件 /usr/local/httpd/conf/httpd.conf 网页目录 /usr/local/httpd/htdocs/ 服务脚本 /usr/local/httpd/bin/apachectl 执行程序 /usr/local/htppd/bin/httpd 访问日志 /usr/local/httpd/log/access_log 错误日志 /usr/local/httpd/log/error_log 2.2 httpd服务器安装2.2.1httpd服务器主要安装步骤 1、卸载安装的httpd软件包 2、源码编译安装 3、优化执行路径 4、添加httpd系统服务 2.2.2httpd服务器的安装配置命令 1.卸载安装的httpd软件包 #rpm -qa httpd //查询已安装的httpd软件包 #rpm -e httpd -nodeps //若已安装,卸载 2.源码编译安装 #tar zxf httpd-2.2.17.tar.gz -C /usr/src/ //解压httpd软件包 #cd /usr/src/httpd-2.2.17 #./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi #make && make install 3.优化执行路径 #ln -s /usr/local/httpd/bin/* /usr/local/bin //创建bin目录下的链接 #ls -l /usr/local/bin/httpd /usr/local/bin/apachectl //查看链接 #httpd -v = /usr/local/httpd/bin/httpd-v 4.添加httpd系统服务 # cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd //拷贝配置文件到启动项 # vi /etc/init.d/httpd //进入启动项配置 #!/bin/bash # chkconfig: 35 85 15 # description: Startup script for the Apache HTTP Server …… # chkconfig --add httpd //添加httpd服务 # chkconfig --list httpd //列出httpd服务设置 2.3 Web站点部署 首先确定网站名称、ip地址,并在dns中设置 2.3.1配置主配置文件 #vim /usr/local/httpd/conf/httpd.conf ServerName http://test.benet.com //指定网站名 #/usr/local/httpd/bin/apachectl -t //语法检查 2.3.2启动httpd服务 #/etc/init.d/httpd start //启动httpd服务 #netstat -anpt |grep httpd //查看httpd运行端口 2.3.3 部署网页文档 #vim /usr/local/httpd/htdocs/index.html 2.4部署AWStats分析系统2.4.1安装AWStats软件包 #tar zxf awstats-7.3.tar.gz //解压awstats软件包 #mv awstats-7.3 /usr/local/awstats //移动awstats包到指定路径 2.4.2 建立站点统计配置文件 #cd /usr/local/awstats/tools/ #chmod +x awstats_configure.pl //添加可执行权限 #./awstats_configure.pl //执行交互式配置过程 >/ usr/local/httpd/conf/httpd.conf / / enter the main profile path
Y confirm to modify the daily type
Y confirm to create a new site statistics profile
> http://test.benet.com / / specify the name of the target site to be counted
> / / enter twice.
/ / if you need to count other site logs, you can execute a script to create a new configuration file
2.4.3 modify site statistics profile
# vim / etc/awstats/awstats.test.bente.com.conf
LogFile= "/ usr/local/httpd/logs/access_log" / / specify the log file path
DirData= "/ var/lib/awstats" / / specifies the directory where statistics are stored
# mkdir / var/lib/awstats
2.4.4 perform log analysis and set up cron scheduled tasks
# chmod + x awstats_updateall.pl / / add executable permissions
#. / awstats_updateall.pl / / execute configuration file
# crontab-e
# / usr/local/awstats/tools/awstats_updateall.pl
# / etc/init.d/crond start
# chkconfig-- level 35 crond on
2.4.5 access to the AWStats test
Httpd:// http://test.benet.com/awstats/awstats.pl?config=test.benet.com
# vim / usr/local/httpd/htdocs/aws.html
/ / create an automatic jump html web page
Http://test.benet.com/awb.html
2.5 httpd service access control restrictions 2.5.1 client address restrictions
# vim / usr/local/httpd/conf/httpd.conf
……
Order deny,allow / / define control order
Deny from 192.168.37.130 / / set the deny address
2.5.2 user authorization restrictions
1. Create a user authentication database
# cd / usr/local/httpd/
# bin/htpasswd-c / usr/local/httpd/conf/.awspwd webadmin
/ /-c New files are added or new users are added
# cat / usr/local/httpd/conf/.awspwd
# bin/htpasswd / usr/local/httpd/conf/.awspwd webuser1
two。 Add a user authorization configuration to the main profile
# vim / usr/local/httpd/conf/httpd.conf
……
AuthName "AWStats Directory"
AuthType Basic / / authentication type is basic authentication
AuthUserFile / usr/local/httpd/conf/.awspwd / / Certification File path
Require valid-user / / users allowed to access
/ var/www/html/benetcom/index.html
# echo "http://www.accp.com" > / var/www/html/accpcom/index.html"
Add a separate virtual host profile
# vim / usr/local/httpd/conf/extra/httpd-vhosts.conf
Order allow,deny / / defines the access control order, which is allowed first and then denied. All are denied by default.
Allow from all / / allow everyone to access this area
NameVirtualHost 192.168.37.131 / / add virtual hostname
DocumentRoot / var/www/html/benetcom / / document root directory
ServerName http://test.benet.com / / website name
ErrorLog logs/www.benet.com.error_log / / error log save directory
Customlog logs/www.benet.com.access_log common / / access log save directory
DocumentRoot / var/www/html/accpcom
ServerName http://test.accp.com
ErrorLog logs/www.benet.com.error_log
Customlog logs/www.benet.com.access_log common
Add a separate configuration file to the main configuration file
# vim / usr/local/httpd/conf/httpd.conf
Include conf/extra/httpd-vhosts.conf
2.6.2 Virtual host based on ip address
# ifconfig eth2 192.168.37.133/24
# ifconfig eth3 192.168.37.134swap 24 / / configure the Nic with ip address respectively
Establish dns parsing
# vim / etc/named.conf
Zone "http://test1.com" IN {
Type master
File "test1.com.zone"
}
Zone "http://test2.com" IN {
Type master
File "test2.com.zone"
}
# vim / var/named/test1.com.zone
$TTL 86400
@ SOA test1.com. Admin.test1.com. (
2011030301
4H
30M
12H
1D
)
@ IN NS http://www.benet.com.
Www IN A 192.168.37.133
# vim / var/named/test2.com.zone
$TTL 86400
@ SOA test2.com. Admin.test2.com. (
2011030301
4H
30M
12H
1D
)
@ IN NS www.benet.com.
Www IN A 192.168.37.134
Set up a test web page
# mkdir / var/www/html/test1com
# mkdir / var/www/html/test2com
# echo "http://www.test1.com" > / var/www/html/test1com/index.html"
# echo "http://www.test2.com" > / var/www/html/test2com/index.html"
Add a separate virtual host profile
# vim / usr/local/httpd/conf/extra/httpd-iphosts.conf
Order allow,deny
Allow from all
/ / configure virtual host
DocumentRoot / var/www/html/test1com
ServerName http://www.test1.com
ErrorLog logs/www.test1.com.error_log
Customlog logs/www.test1.com.access_log common
DocumentRoot / var/www/test2/accpcom
ServerName http://www.test2.com
ErrorLog logs/www.test2.com.error_log
Customlog logs/www.test2.com.access_log common
Load a standalone configuration file in the main configuration file
# vim / usr/local/httpd/conf/httpd.conf
Include conf/extra/httpd-iphosts.conf
one。 Nginx+tomcat load balancing 3.1 Topology Diagram
3.2 Service environment
Server1 and Server2 use Tomcat as the application server, and need to configure java environment
Server3 uses Nginx as its load balancer
The three servers are Centos operating systems.
3.3 required software installation package
1 、 jdk-7u65-linux-x64.gz
2 、 apache-tomcat-7.0.54.tar.gz
3 、 pcre-devel
4 、 zlib-devel
5 、 openssl-devel
6 、 nginx-1.6.0.tar.gz
3.4 Tomcat configuration 3.4.1 Tomcat main directories and configuration files
Bin/: stores script files for starting and shutting down Tomcat
Conf/: stores various global configuration files of the server, such as server.xml and web.xml
Lib/: stores the library files (JARS package files) needed for Tomcat operation.
Logs/: stores Tomcat-related log files
The release directory of the webapps/:Web application, where Web application files are placed by default
The working directory of work/:Tomcat, which stores the servlet class files generated by compiling JSP files by default
Temp/: stores temporary files running by Tomcat
3.4.2 main profile description
Catalina.policy: permission control profil
Catalina.properties:Tomcat property profile
Context.xml: configure the mapping between physical directory and virtual directory when web application is deployed.
Logging.properties: log log related configuration fil
Server.xml: main profile
Tomcat-users.xml: administrative users who configure Tomcat (manage and view tomca through web
Operation and deployed webApp)
The web.xml:Web application description file is the configuration file for the Web application
3.4.3 main configuration steps of tomcat (need to configure 2 sets)
1. Install jdk and configure Java environment
2. Install and configure tomcat
3. Set up a web test site for java
3.4.5 Tomcat configuration command
1. Install jdk and configure the Java environment
# tar xf jdk-7u65-linux-x64.gz / / decompress the jdk package
# mv jdk1.7.0_65/ / usr/local/java / / move the extracted jdk package to the specified path
# vim / etc/profile.d/java.sh / / create a java.sh script
Export J**A_HOME=/usr/local/java
Export PATH=$PATH:$J**A_HOME/bin / / add the / bin subdirectory under the java root directory to the PATH environment variable
# source / etc/profile.d/java.sh / / execute java.sh script
# java-version / / View java version
# rpm-qa | grep java / / check whether to install java
# rpm-e-nodeps tzdata-java-2012c-1.el6.noarch
two。 Install and configure tomcat
# tar zxvf apache-tomcat-7.0.54.tar.gz
# mv apache-tomcat-7.0.54 / usr/local/tomcat7
# / usr/local/tomcat7/bin/startup.sh / / start tomcat. Add auto-start rc.local to restart
# netstat-anpt | grep 8080 / / tomcat default running port is 8080
Login to http://192.168.1.1:8080 test Tomcat successful
3. Set up a web test site for java
# mkdir-pv / web/webapp1
# vim / web/webapp1/index.jsp
L
JSP test1 page
# vim / usr/local/tomcat7/conf/server.xml
3.5 nginx server configuration 3.5.1 establish yum source
# mkdir / media/cdrom
# mount / dev/cdrom / media/cdrom
# vim / etc/yum.repos.d/local.repo
[local]
Name=RHEL DVD
Baseurl= file:///media/cdrom
Enabled=1
Gpgcheck=0
# yum-y install pcre-devel zlib-devel openssl-devel / / install related software packages
3.5.2 extract and install nginx
# groupadd www / / create a group
# useradd-g www www-s / bin/false / / create a user
# tar zxf nginx-1.6.0.tar.gz
# cd nginx-1.6.0
#. / configure-prefix=/usr/local/nginx-user=www-group=www
-with-file-aio-with-http_stub_status_module-with-http_gzip_static_module
-with-http_flv_module-with-http_ssl_module
# make & & make install
3.5.3 configuring nginx.conf
# vim / usr/local/nginx/conf/nginx.conf
Add in http {}
Upstream tomcat_server {
Server 192.168.1.1 8080 weight=1; / / specify server and weight
Server 192.168.1.2:8080 weight=1
}
Location / {
Root html
Index index.html index.htm
Proxy_pass = "http://tomcat_server/">http://tomcat_server; / / sets the server to forward
}
# / usr/local/nginx/sbin/nginx-t / / Test nginx configuration file
3.5.4 start the nginx service
# / usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.conf
# killall-s HUP nginx
# ps aux | grep nginx / / View nginx service process
# netstat-anpt | grep nginx / / View port number and PID process number
At this point, I believe you have a better understanding of "how to install mysql, Nginx and Tomcat services". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.