1. Install jdk1.7
1. First go to the official website to download jdk and put it in the /home/ directory
2.cd /home, switch to the home directory, and execute tar -zxvf jdk.tar.gz
Then execute mv jdk1.7/ /opt/ to copy jdk to /opt/ directory
(I am used to putting the software in opt, this depends on personal habits)
Then execute vim /etc/profile (adding environment variables here takes effect for all users)
add configuration at the end
#set jdk environment
export JAVA_HOME=/opt/jdk1.7.0_79
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
Enter the following command in the terminal to make the configuration take effect source /etc/profile
Try to use echo $JAVA_HOME to see if the output is the jdk address you configured
Then execute java -version to see if jdk related information is output
2. Install tomcat7 and register as a service
1. First go to the official website to download tomcat7 to the /home/ directory
2. Like jdk, execute tar mv
3. Copy catalina.sh under tomcat to /etc/init.d/tomcat path
4.vi /etc/init.d/tomcat cygwin=false os400=false Add the following line above
5.wq save
3. Install nginx
(1) GCC, G++ compiler
apt-get install build-essential apt-get install libtool
(2)PCRE(Perl Compatible Regular Expressions)库
Used to support regular expressions, which is required by Nginx's HTTP module to parse regular expressions.
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ Download the latest source package.
Use the following commands to download, compile and install:
tar -zxvf decompress
cd /home/pcre
./configure
make
make install
(3) Compile and install zlib and openssl in turn
(4) Specify the nginx installation directory to compile and install
./configure --prefix=/opt/nginx/ --with-pcre=../pcre-8.39 --with-zlib=../zlib-1.2.8 --with- openssl=../openssl-fips-2.0.5
(5) cd /opt/nginx/sbin/ ./nginx -t to test whether the installation is successful
(6)./nginx start ./nginx -reload restart
Four: Configure nginx as the startup service
#!/bin/sh
# chkconfig: 2345 85 15
# description:Nginx Server
NGINX_HOME=/opt/nginx
NGINX_SBIN=$NGINX_HOME/sbin/nginx
NGINX_CONF=$NGINX_HOME/conf/nginx.conf
NGINX_PID=$NGINX_HOME/logs/nginx.pid
NGINX_NAME="Nginx"
. /etc/rc.d/init.d/functions
if [ ! -f $NGINX_SBIN ]
then
echo "$NGINX_NAME startup: $NGINX_SBIN not exists! "
exit
be
start() {
$NGINX_SBIN -c $NGINX_CONF
ret = $?
if [ $ret -eq 0 ]; then
action $"Starting $NGINX_NAME: " /bin/true
else
action $"Starting $NGINX_NAME: " /bin/false
be
}
stop() {
kill `cat $NGINX_PID`
ret = $?
if [ $ret -eq 0 ]; then
action $"Stopping $NGINX_NAME: " /bin/true
else
action $"Stopping $NGINX_NAME: " /bin/false
be
}
restart() {
stop
start
}
check() {
$NGINX_SBIN -c $NGINX_CONF -t
}
reload() {
kill -HUP `cat $NGINX_PID` && echo "reload success!"
}
relog() {
kill -USR1 `cat $NGINX_PID` && echo "relog success!"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
check|chk)
check
;;
status)
status -p $NGINX_PID
;;
reload)
reload
;;
relog)
relog
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status|check|relog}"
exit 1
esac
Save the file name as nginx and copy it to /etc/init.d/
chmod 775 /etc/init.d/nginx
Execute ln -s /lib/lsb/init-funtions /etc/rc.d/init.d/functions (the difference between Ubuntu and other Linux, the location of functions is different, or directly modify the configuration file, no need to do soft link)
The service nginx start stop restart command can be used