FTP Service Setup and configuration
Introduction to FTP
FTP is the abbreviation for the file Transfer Protocol (document Transfer Protocol), which is used to control the two-way transmission of files over the Internet.
The primary role of FTP is to have the user connect to a remote computer (which runs an FTP server program), view the files on the remote computer, and then copy the files from the remote computer to the local computer, or transfer the files from the local computer to the remote computer.
Small companies use more, large enterprises without FTP, because unsafe.
Using VSFTPD to build an FTP service
Bring your own vsftpd on CentOS
Installation: Yum install-y vsftpd
Create a User: Useradd-s/sbin/nologin virftp//-s Specify his shell so for the sake of security, the purpose of creating this ordinary user is to allow these virtual users to do a mapping, because you want to log on to this machine to transfer data, so you need a user
Edit file: Vim/etc/vsftpd/vsftpd_login//This file we call the virtual user's password file, need to define his user name and password, odd behavior user name, even behavior password, multiple users write multiple lines, the content format is as follows:
TestUser1
Aminglinux
User1
987654321
Edit Change Permissions: chmod 600/etc/vsftpd/vsftpd_login cannot be read by all users
Convert the text password file to a computer-recognized binary: db_load-t-T hash-f/etc/vsftpd/vsftpd_login/etc/vsftpd/vsftpd_login.db
directory where the virtual user configuration file is created: mkdir/etc/vsftpd/vsftpd_user_conf
This directory is also custom, so go to the config file to define
Go to this directory first: cd/etc/vsftpd/vsftpd_user_conf
Create and edit a user's profile: Vim TestUser1// Create user profile to match your user name, Add the following://comment
local_root=/home/virftp/testuser1//define a virtual user's home directory
anonymous_enable=no//whether to allow secret users
write_enable=yes//whether writable is allowed
local_umask=022//what is the right to create a new directory for a new file, consistent with the system
anon_upload_enable=no//allow secret users to upload
anon_mkdir_write_enable=no//allow secret users to create directories and write
idle_session_timeout=600//How much time the upload is out of date disconnect
data_connection_timeout=120//data transfer out of time
max_clients=10//the maximum number of clients
Create a virtual user's home directory: Mkdir/home/virftp/testuser1
In touch a file: Touch/home/virftp/testuser1/aming.txt
Change permissions: Chown-r virftp:virftp/home/virftp because finally you want to map to virftp this user
Edit the configuration file, define its password file where: vim/etc/pam.d/vsftpd//At the front Plus
Auth sufficient/lib64/security/pam_userdb.so Db=/etc/vsftpd/vsftpd_login
Account Sufficient/lib64/security/pam_userdb.so Db=/etc/vsftpd/vsftpd_login
Edit VFSTPD's master profile: vim/etc/vsftpd/vsftpd.conf
Change Anonymous_enable=yes to Anonymous_enable=no do not allow secret users
Change #anon_upload_enable=yes to Anon_upload_enable=no
Change #anon_mkdir_write_enable=yes to Anon_mkdir_write_enable=no
At the bottom, add the following:
Chroot_local_user=yes
Guest_enable=yes
Guest_username=virftp
Virtual_use_local_privs=yes
User_config_dir=/etc/vsftpd/vsftpd_user_conf
Allow_writeable_chroot=yes
Systemctl start vsftpd//Start VSFTPD Service
Test FTB
Installing the Client software: Yum install-y lftp
lftp [email protected]
Execute command LS to see if normal output
viewing logs/var/log/messages and/var/log/secure if not normal
Install FileZilla client software under Windows and test
Use PURE-FTBD to build FTB service
Yum Install-y epel-release
Yum Install-y pure-ftpd
Change the configuration file: vim/etc/pure-ftpd/pure-ftpd.conf//find pureftpd.pdb This line, the beginning of the # Delete
Stop this service: Systemctl stop vsftpd
Start service: Systemctl start pure-ftpd
Create Test Catalog: mkdir/data/ftp
Create a normal directory: Useradd-u 1010 PURE-FTP
Change the genus group: Chown-r pure-ftp:pure-ftp/data/ftp
PURE-PW useradd ftp_usera-u pure-ftp-d/data/ftp
PURE-PW MKDB
Create a test file: Touch/data/ftp/123.txt
Login: lftp [email protected] LS to see if there are 123.txt files
PURE-PW list/userdel/usermod/passwd
Tomcat Configuration
about Tomcat
1.Tomcat is a core project of the Apache Software Foundation (Apache Software Foundation) Jakarta Project, developed by Apache, Sun, and other companies and individuals.
2.java program written by TOMCAT+JDK to run the website
3.tomcat is a middleware that really works, parsing Java scripts is the JDK
4.JDK (Java Development Kit) is the core of the entire Java, which contains the Java Runtime environment and a stack of Java-related tools as well as the Java Foundation Library.
5. The most mainstream JDK is the JDK released by Sun, in addition to the fact that IBM has published Jdk,centos can also be installed with Yum OpenJDK
Installing the JDK
JDK version 1.6,1.7,1.8
Official website http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Download the jdk8 and put it in the/usr/local/src/directory
Steps:
1. Advanced to: cd/usr/local/src/directory
2. Then transfer to Linux with Xftp
3. Unzip the JDK file: Tar zxvf jdk-8u144-linux-x64.tar.gz
4. Put it in the usr/local/directory and rename it to JDK1.8:MV jdk1.8.0_144/usr/local/jdk1.8
5. Edit the configuration file (set environment variable): vi/etc/profile//Last Face increase
java_home=/usr/local/jdk1.8/
Java_bin=/usr/local/jdk1.8/bin
Jre_home=/usr/local/jdk1.8/jre
Path= $PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin
Classpath=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar
6. Entry into force: Source/etc/profile
7. Verify that the installation is successful: Java-version the following results prove that the installation was successful
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/9F/76/wKioL1mdMg_yWI4TAAAnRg1ae3U450.png "title=" 37] oi73zi@{}efs{u) W '} ' J.png "alt=" Wkiol1mdmg_ywi4taaanrg1ae3u450.png "/>
Installing Tomcat
Go to: Cd/usr/local/src directory:
Download Tomcat:wget http://apache.fayea.com/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz
Decompression: Tar zxvf apache-tomcat-8.5.20.tar.gz
Move it to the local/directory and change it to the name TOMCAT:MV Apache-tomcat-8.5.20/usr/local/tomcat
Start tomcat:/usr/local/tomcat/bin/startup.sh (Close:/usr/local/tomcat/bin/startdown.sh)
View process: PS aux|grep java PS aux|grep Tomcat
View listening ports: NETSTAT-LNTP |grep java 650) this.width=650; src= https://s1.51cto.com/wyfs02/M01/01/E5/ Wkiom1meu1ca8yx2aab-kvguhny210.png "title=" 5nw7 (oubvd9fahcpjk5~m}v.png "alt=" Wkiom1meu1ca8yx2aab-kvguhny210.png " />
Three port 8080 is the port that provides the Web service, 8005 is the management port, and 8009 port is the port that is called by the third-party service, such as httpd and Tomcat.
Tomcta supports custom ports , such as you want to change 8080 to 80 port, as follows:
Configure the Tomcat listener port to be 80 methods:
Edit the Tomcat profile: Vim/usr/local/tomcat/conf/server.xml Search: 8080
Connector port= "8080" protocol= "http/1.1" modified to Connector port= "" "Protocol=" http/1.1 "
Restart Service Tomcat:
Closed First:/usr/local/tomcat/bin/shutdown.sh
Restart:/usr/local/tomcat/bin/startup.sh
To see if there is a listening 80 port: NETSTAT-LNTP |grep Java
If there is no 80 port, see if the Java process is turned on: PS aux |grep java
To see if there are 80 ports: NETSTAT-LNTP |GREP 80 has and displays nginx occupancy, you need to turn off Nginx service:
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/A0/A3/wKioL1mev-jjiVThAABw2RCIFjc974.png "title=" Irhua R X[0lel{1glcmys0.png "alt=" Wkiol1mev-jjivthaabw2rcifjc974.png "/>/etc/init.d/nginx stop
Then restart the Tamcat service, in the view:
/usr/local/tomcat/bin/shutdown.sh
/usr/local/tomcat/bin/startup.sh
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/01/F2/wKiom1mev6fwpYq5AACNyzpcK4A045.png "title=" Yre ( JQ[HDGHONK5YKLQ ([6j.png "alt=" Wkiom1mev6fwpyq5aacnyzpck4a045.png "/>
Configure the virtual host for Tomcat
Edit configuration file: Vim/usr/local/tomcat/conf/server.xml search:
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/03/C7/wKiom1mf6VigHumzAAAwSLx_HcE867.png "title=" 33x3q }}9 (o9@yr_7}37v (qt.png "alt=" Wkiom1mf6vighumzaaawslx_hce867.png "/>
Where the configuration between <Host> and </Host> is the virtual Host configuration section, name defines the domain name,
AppBase defines the application's directory, Java's application is usually a jar of compressed packets, you just need to put the jar's compressed package under the AppBase directory. The Tomcat default page just Amin access is actually under the AppBase directory, but in its subdirectory root.
Add virtual hosts, edit Server.xml, and add the following to the bottom </Host> below:
unpackwars= "True " autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "" docbase= "/data/wwwroot/123.cn/" debug= "0" reloadable= "true" crosscontext= "true"/>
</Host>
DocBase, this parameter is used to define the Web site's file storage path, if not defined, the default is under the Appbase/root, the definition of docBase is based on this directory, where AppBase and docBase can be the same. In this step of the process, many students have encountered the problem of access 404, in fact, docbase is not defined.
AppBase the directory for the application, usually it needs to put the war package directly under the directory, it will be automatically extracted into a program directory
Below we realize the role of the AppBase and Docbase directories by deploying a Java application
Create a blog:
1. Download Zrlog:wget Http://dl.zrlog.com/release/zrlog-1.7.1-baaecb9-release.war
2. Move the installation package to the WebApps directory: CP zrlog-1.7.1-baaecb9-release.war/usr/local/tomcat/webapps/
3. go to the WebApps directory: cd/usr/local/tomcat/webapps/
4. Change the directory for automatic decompression to the name ZRLOG:MV zrlog-1.7.1-baaecb9-release zrlog
5. Check if MySQL is turned on: PS aux |grep MySQL
6. Log in with your computer: 192.168.65.135/zrlog/
7. Login mysql:mysql-uroot-p123456789
8. creating a library called Zrlog: Create Database Zrlog;
9. Create a user, specify the user's IP and password: Grant all on zrlog.* to ' Zrlog ' @127.0.0.1 identified by ' 12345678 '; To : Specify IP identified by: Specify Password
Ten. Create a complete check to create a user right: mysql-uzrlog-h127.0.0.1-p12345678
See if there are any zrlog:show databases;
Edit Page zrlog info: Next-next-finish
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/03/CA/wKiom1mgEcHgERzcAABAURneVOM663.png "title=" Vo5ti _hlia%9}t7 (fkv2981.png "alt=" Wkiom1mgechgerzcaabaurnevom663.png "/>
Visit URL: 192.168.65.135/zrlog/
If you do not want to access IP directly, you need to do the following:
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/A2/7B/wKioL1mgGeWzoGzdAABGxTt1VEA638.png "title=" 577 ' hhyo[a_npx86m) 9$u4u.png "alt=" Wkiol1mggewzogzdaabgxtt1vea638.png "/>
AppBase: Is the docBase to put the war package: directly put the website program
Create directory: mkdir/data/wwwroot/123.cn
Move everything under the Zrlog directory to the 123.cn directory:
mv/usr/local/tomcat/webapps/zrlog/*/data/wwwroot/123.cn/
On the hosts that are bound on Windows
Restart Service:/usr/local/tomcat/bin/shutdown.sh
/usr/local/tomcat/bin/startup.sh
Visit URL: www.123.cn
Tomcat Log
Log in:/usr/local/tomcat/logs directory
Ls/usr/local/tomcat/logs
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/A2/7B/wKioL1mgHh_hs_wnAADEKAamUBI661.png "title=" j}3w{ "SZ8" Yxidf08iamuo.png "alt=" Wkiol1mghh_hs_wnaadekaamubi661.png "/>1. The log that begins with Catalina is the synthetic log of Tomcat, which records information about the Tomcat service and logs the error log.
2. where Catalina.2017-xx-xx.log and catalina.out content are the same, the former generates a new log every day.
3.Host-manager and manager are management-related logs, where Host-manager is the management log for the virtual host.
4.localhost and localhost_access are virtual host-related logs, where the log with access is the access log, and the error log for the default virtual host without the word access.
Access logs are not generated by default and need to be configured in Server.xml.
The specific method is to add the following configuration to the <Host></Host> of the corresponding virtual host (if the domain name is 123.cn):
<valve classname= "Org.apache.catalina.valves.AccessLogValve" directory= "Logs"
prefix= "123.cn_access" suffix= ". Log"
pattern= "%h%l%u%t "%r" %s%b "/>
Prefix defines the prefix of the access log, suffix defines the suffix of the log, and the pattern defines the log format. The newly added virtual host does not generate the same localhost as the default virtual host by default. Date. log log, the error log is uniformly recorded in Catalina.out. About the Tomcat log, you need to focus on catalina.out, when there is a problem, we should first want to see it.
Resin Installation and configuration
This also need to install JDK, download from official website, caucho.com, download the first do not charge to do the experiment just fine.
First step, download the installation package: Wget http://caucho.com/download/resin-4.0.53.tar.gz
Unzip: Tar zxvf
Go to the unpacked directory and compile:./configure --prefix=/usr/local/resin --with-java=/usr/local/jdk1.8 two designations, The first one needs to specify which directory to install and the second to specify the path where Java resides
Make && make install
It will automatically generate this directory: ls/usr/local/resin/
Auto-Generate startup script: Ls/etc/init.d/resin
It's best to stop Tomcat first:/etc/init.d/tomcat stop
At startup:/etc/init.d/resin start
Visit: 192.168.65.135:8080
It defaults to port 8080, and you want direct access to the 80 port method:
Change the Listening port:
Go to the resin/conf/directory: cd/usr/local/resin/conf/
Edit profile: Vim resin.properties search: app.http change 8080 to
Restart:/etc/init.d/resin start
NETSTAT-LNP |grep Resin See if there's a 80 port.
Direct access: 192.168.65.135
Change the virtual host:
Edit Virtual Host profile: Vim Resin.xml Search: <cluster id= "App" > write down this paragraph to the back
<web-app id= "/" root-directory= "/tmp/resin"/>
Create directory: Mkdir/tmp/resin
Reboot:/etc/init.d/resin stop/etc/init.d/resin start
Take a look at Port 80: NETSTAT-LNP |grep java
Create a parse file to see if you can parse
Go to this directory: Cd/tmp/resin
Edit configuration file: Vim 1.txt Add the following:
<?php
echo "Hello how is you.";
Parse: curl-x127.0.0.1:80 www.123.com/1.txt
MySQL Master-slave configuration
Uninstall the original MySQL step
First step, go to src: cd/usr/local/src/
Step Two, delete
Rm-rf/usr/local/mysql
Rm-rf/etc/init.d/mysqld
The third step, download unzip:
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
Tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
Fourth step, move the finished MySQL to MySQL directory: MV Mysql-5.6.35-linux-glibc2.5-x86_64/usr/local/mysql
Go to the MySQL directory: cd/usr/local/mysql
Check to see if there is a MySQL user: grep ' mysql '/etc/passwd
No words create one: Useradd MySQL
Create the Data directory: mkdir/data/
Compilation:./scripts/mysql_install_db--user=mysql--datadir=/data/mysql
Copy the configuration file and startup script:
CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF
CP Support-files/mysql.server/etc/init.d/mysqld
Edit configuration file: Vi/etc/init.d/mysqld define Basedir and DataDir
Basedir=/usr/local/mysql
Datadir=/data/mysql
Remove the previous data/mysql: Rm-rf/data/mysql
Start:/etc/init.d/mysqld start
View services: PS aux |grep MySQL
View Port: NETSTAT-LNP |grep 3306
Configuration from: Open on another machine
cd/usr/local/
Cp-r MySQL mysql_2
CD mysql_2
Define its configuration file (the configuration file should be placed in the current directory): Cp/etc/my.cnf./my.cnf
Edit configuration file: Vim my.cnf change some content
port=3306 changed into port=3307
Socket=/tmp/mysql.sock changed into Socket=/tmp/mysql2.sock
Add a sentence: datadir=/data/mysql2
Initialization operation:./scripts/mysql_install_db--user=mysql--DATADIR=/DATA/MYSQL2
Check: Whether there are two directories under ls/data/mysql_2/
Starting it requires writing a startup script:
cd/etc/init.d/
CP mysqld Mysqld2
Vim Mysqld2
Basedir=/usr/local/mysql_2
Datadir=/data/mysql_2
conf= $basedir/my.cnf
Start:/etc/init.d/mysqld2 start
View services: PS aux |grep MySQL should be there are two ports one 33,061 x 3307
Log in to two MySQL methods:
3306:mysql-uroot-s/tmp/mysql.sock or: mysql-h127.0.0.1-p3306
3307:mysql-uroot-s/tmp/mysql_2.sock or: mysql-h127.0.0.1-p3307
First login to master settings master:
Mysql
Creating a library called DB1: Create Database db1; Quit to quit when you're finished creating
Copy the MySQL library: mysqldump-uroot-s/tmp/mysql.sock mysql > 123.sql
Back in recovery: mysql-uroot-s/tmp/mysql.sock DB1 < 123.sql
Log in to master MySQL
Use DB1; View Table
Show tables; View Table Contents
To edit a profile: Vim/etc/my.cnf open the bottom two.
Server-id=1 This number is not the same as the master.
Log-bin=mysql-bin can customize the name
Restart: etc/init.d/mysqld restart
A few files starting with your custom name will be generated below ls/data/mysql/
To set the root access password for the MySQL database:
Log in to MySQL
Mysqladmin-u root-s/tmp/mysql2.sock password ' 123456 '
Mysql-u root-s/tmp/mysql2.sock-p ' 123456 '
mysql> grant replication Slave on * * to ' repl ' @ ' 127.0.0.1 ' identified by ' 123123 ';
The REPL here is for the slave end of the user to access the master-side MySQL data, the password is 123123, where the 127.0.0.1 is slave IP (because the Amin configuration of the master and slave are in the native).
Mysql> flush tables with read lock; Locks the database and does not allow changes to any data at this time
Mysql> Show master status; View status, this data is to be recorded, one will be used in the slave end of the
Set from:
Edit matching files: vim/etc/my.cnf
Server-id = 1 Change to another number
Restart: Service mysqld restart
Copy data:
Mysql-uroot-s/tmp/mysql.sock-e "CREATE Database DB1"
Mysql-uroot-s/tmp/mysql.sock db1< 123.sql
Log on to from: Mysql-uroot-s/tmp/mysql_2.sock
Stop this service: slave stop;
Change Master to master_host= ' 127.0.0.1 ', master_port=3307,
Master_user= ' Repl ', master_password= ' 123123 ',
Master_log_file= ' mysql-bin.000006 ', master_log_pos=474952;
show slave status\g; Two yes indicates success
Test Master
Unlock: Unlock tables;
In the Lord Operation:
Use DB1;
View table: Show tables;
Delete a table: drop table help_category;
On the action from: view
Use DB1;
Show tables;
See if there is help_category;
It means that what you do in your Lord will also be there, such as deleting a table to delete a library, and then deleting it from the top, but you can no longer delete the creation from the top.
This article is from the "12912638" blog, please be sure to keep this source http://12922638.blog.51cto.com/12912638/1960262
Notes (FTP configuration, tomcat configuration, resin configuration, MySQL master-slave configuration)