1. Introduction
Software Installation is the top priority of linux learning. * nux is an important philosophy
Learning to combine a number of small functions to become an available and maintainable system platform.
When the operating system is built, unless the kernel and other supporting system required software, you can
Maintenance tasks must be handed over to the Administrator.
Software Installation. Today we will summarize the methods for installing software on linux.
Method.
2. Category
A) package management tools
Rpm (redhet package manager), deb and yum front-end management
Tools
B) source code format
The src Source Code is provided.
The machine can be installed only after compilation.
C) binary format
It has been compiled into a binary format and can be run on a machine without a compilation environment.
Of course, this form is gradually extinct with the maturity of the package management tool, not discussed in this article
Within the scope of the theory.
3. Use
A) package management tools
Rpm contains a complete redhat-class set of software installation and maintenance feasibility
Solution, all rpm packages follow the de facto standards, which avoids the cost during use.
There are also rules for the naming of. rpm packages, such as mysql-5.1.66-2.el6_3.
X86_64.rpm product name-product version number-rpm package version number-applicable Operating System
System-computing architecture. rpm
I) install/upgrade/reinstall
12345
rpm -i/U/Fvh mysql-
5.1
.
66
-
2
.el6_3.x86_64.rpm
I install installation package (accessible network address)
V verbose Installation Details
H hash sign # indicates the installation progress
2
% 1 #
-- Nodeps ignores dependencies between packages.
Ii) Remove
123
rpm -e mysql
E erase remove the current package
-- Nodeps remove package ignore dependencies between packages
Iii) Query
123456789
rpm -q mysql
Q: Is the query package installed?
Qa query all installed packages
Qd query document
man
Information
After qi query information is installed, the system queries the package information, including the package name and version.
, Size group information, url, license, url, description information, etc.
Location of the configuration file after qc query configure is installed
List of all files generated by installing the ql query list
# The p parameter can be used with the qpa qpi parameter.
Iv) Verification
The vast majority of machines we maintain are production tools and cannot be laggy.
Therefore, we can only criticize Internet content.
Here we need to complete the package verification and identity verification
Make sure that all the packages we use do not contain virus or backdoor programs.
12
rpm --
import
Key import package producer Public key
rpm -K mysql-5.1.66-2.el6_3.x86_64.rpm
B) yum front-end management tool
This is a process of aggregating all the previous rpm packages into a library, searching for the library on the client, and performing soft
Tool for Component Management, greatly improving ease of use, facilitating users to carry out multiple forms
Rpm package management operations. Common methods such as http, ftp, nfs, and file. Of course
The premise is to configure the/etc/yum. repos. d/*. repo parameters.
* Repo Parameters
1234567
[Media] The repoid is unique.
Name = media name Customization
baseurl=
file
:
///media/
Protocol path
Enabled = 0 whether to enable the library
Gpgcheck = 1 whether to perform identity Review
gpgkey=
file
:
///media/RPM-GPG-KEY-CentOS-6
KEY
Cost = 1000 database usage cost (multiple databases)
# Yum Common commands
12345678
yum
install
Mysql installation package
Yum erase mysql uninstall package
Yum update mysql can upgrade one or more packages
Yum list mysql view all packages in the database
Yum repolist
Yum grouplist group information (classification management package)
Yum groupinstall installation group package
Yum groupremove Delete group package
C) source code Installation
#0 first download the nginx source code package from the Intranet ftp server. Of course, you can also
Go to the nginx official website and download the latest nginx source code.
123
lftp
ftp
:
//172
.16.0.1
/pub/Sources/sources/nginx/
get nginx-1.4.2.
tar
.gz
bye
#1 decompress nginx
12
tar
-xf nginx-1.4.2.
tar
.gz
rm
-rf nginx-1.4.2.
tar
.gz
#2 install the nginx dependency package pcre-devel before compiling nginx
1
yum -y
install
pcre-devel
#3 after pcre-delel is completed, specify the bin directory for nginx compilation and the conf file directory
1
.
/configure
--prefix=
/usr/local/nginx
--conf-path=
/usr/local/nginx/nginx
.conf
#4 compile and install nginx
1
make
&&
make
install
#5 start the nginx Service
1
/usr/local/nginx/sbin/nginx
#6 check the port status. The port 80 appears.
1
netstat
-tnl |
grep
":80"
#7 test and view the installed status of the file
12
wget http:
//localhost
stat .
/index
.html
#00 so far nginx installation has come to an end, and we can handle other things,
When starting the nginx service in step #5, you may find that the startup directory is too long,
Nginx cannot be stopped. These problems continue to plague us.
Let's take a look at these issues.
#01 the directory is too long to solve the problem. In fact, we hope to use the shortest command to achieve the effect. win32
Consistent with the linux target, there will be environment variables. Here we are modifying the environment variables of nginx,
This allows you to directly execute nginx commands in any directory.
123
vim
/etc/profile
.d
/apache
.sh
PATH=
/usr/local/nginx/sbin
:$PATH
.
source
/etc/profile
.d
/apache
.sh
# Re-read
#02 after setting up the web server, we hope other people can access the server, so we
You need to leave an exit on the linux Firewall (ps: You can imagine that the Internet is
Every computer in a large map is a city. One day another city-state messenger visited
Ask me, then I have to leave a portal for it)
123
vim
/etc/sysconfig/iptables
-I INPUT -p tcp --dport 80 -j ACCEPT
service iptables restart
#03 start the instance at startup (You may find that the configured nginx has restarted the instance.
It cannot be used again later. Check that the listening on port 80 is invalid after the restart #6 operation,
We need to manually complete a simple script to enable it to start upon startup,
Of course, nginx usually comes with this script. Let's get familiar with the process :)
1
vim
/etc/init
.d
/nginx
# 03-a the most important thing about linux is to provide services like win32.
# This indicates to tell the machine that this is a service script and will be added
# Effects of service list
# Chkconfig: 2345 55 25
# Description: nginx service
12
# chkconfig: 2345 55 25
# description: nginx service
# 03-b first defines some basic variables
# Include path
1
PATH=$PATH
# Software name
1
NAME=nginx
# Sbin path
1
SBINPATH=
/usr/local/nginx/sbin/
$NAME
# Configuration file path
1
CONFIGFILE=
/usr/local/nginx/
$NAME.conf
# Pid file (linux daemon file, in short, the thread number. This file proves nginx
# It is started. If it is not, nginx may not be accessible)
1
PIDFILE=
/usr/local/nginx/logs/
$NAME.pid
# 03-d check whether the sbin file and the matching file exist; otherwise, a prompt is displayed.
12
[ -e
"$SBINPATH"
] ||
echo
-n
"$SBINPATH No such file or directory"
[ -e
"$CONFIGFILE"
] ||
exit
-n
"$CONFIGFILE No such file or directory"
# 03-e start nginx command nginx start
123
start() {
$SBINPATH -c $CONFIGFILE ||
echo
-n
"nginx already running"
}
# 03-f disable nginx command nginx stop
123
stop() {
kill
-INT `
cat
$PIDFILE` ||
echo
-n
"nginx not running"
}
# 03-g determine user input and execute different commands
1234567891011121314151617181920
case
"$1"
in
start )
echo
-n
"$NAME Starting..."
start
;;
stop )
echo
-n
"$NAME Stopping..."
stop
;;
restart )
echo
-n
"$NAME Restarting..."
stop
start
;;
* )
echo
"Usage: /etc/init.d/$NAME {start | stop | restart }"
&>
/dev/null
exit
1
;;
esac
exit
0
# Complete code startup. sh
1234567891011121314151617181920212223242526272829303132333435
#!/bin/bash
#
PATH=$PATH
NAME=nginx
SBINPATH=
/usr/local/nginx/sbin/
$NAME
CONFIGFILE=
/usr/local/nginx/
$NAME.conf
PIDFILE=
/usr/local/nginx/logs/
$NAME.pid
[ -e
"$SBINPATH"
] ||
echo
-n
"$SBINPATH No such file or directory"
[ -e
"$CONFIGFILE"
] ||
exit
-n
"$CONFIGFILE No such file or directory"
start() {
$SBINPATH -c $CONFIGFILE ||
echo
-n
"nginx already running"
}
stop() {
kill
-INT `
cat
$PIDFILE` ||
echo
-n
"nginx not running"
}
case
"$1"
in
start )
echo
-n
"$NAME Starting..."
start
;;
stop )
echo
-n
"$NAME Stopping..."
stop
;;
restart )
echo
-n
"$NAME Restarting..."
stop
start
;;
* )
echo
"Usage: /etc/init.d/$NAME {start | stop | restart }"
&>
/dev/null
exit
1
;;
esac
exit
0
# Exit the vim editor from 03-h and grant the execution permission to the current script
1
chmod
+x
/etc/init
.d
/nginx
# 03-i Add the nginx service to the service list.
If you didn't listen to your opinion, there is no way to do it here :)
1
chkconfig --add nginx
# 03-j about 345 of the startup options added to the nginx Service
# Forgive me for giving me a sigh of relief when I was excited at the last moment :)
# Chkconfig-level: 0-6 7 levels
# This process has a lot to do with linux Startup. For details, refer
# Http://apprectice.blog.51cto.com/2214645/1362564
#345 basically corresponds to the loading process on it
1
chkconfig --level 345 nginx on
# 03-k nginx {start | stop | restart}
# It will not be a problem to stop :)
1
nginx start
D) binfile Installation
Binfile installation is very simple, because it is a combination of shell and rpm, generally
No additional configuration is required. Run bin directly.
This article is from the "Apprentice" blog, please be sure to keep this source http://apprentice.blog.51cto.com/2214645/1362887