Ubuntu12.04 install and deploy the environment, nginx, tomcat, and mysql. And boot _ MySQL

Source: Internet
Author: User
Ubuntu12.04 install and deploy the environment, nginx, tomcat, and mysql. Start tunginxtomcat at startup

Note: jdk, tomcat, and mysql should not be installed in your home directory. in this case, the startup will fail and the system will prompt that the corresponding files are missing. it may be because the home directory was not mounted at that time.
1: install nginx
Download nginxhttp: // nginx.org/download/nginx-1.2.2.tar.gz
Extract

Java code

  1. Tar-zxf nginx-1.2.2.tar.gz

Java code

  1. ./Configure -- prefix =/usr/local/nginx

Java code

  1. Make & sudo make install


Configure may prompt an error: install two dependencies.

Java code

  1. Sudo apt-get install libpcre3-dev

  2. Sudo apt-get install libssl-dev


The default nginx generated contains debugging information. to remove debugging information, modify the auto/cc/gcc file in the nginx directory and find

Java code

  1. # Debug

  2. CFLAGS = "$ CFLAGS-g"


Comment it out, and then recompile it.
Set boot start:
Create a new file under/etc/init. d/, which is called nginx. the content is:

Java code

  1. #! /Bin/bash

  2. # Nginx Startup script for the Nginx HTTP Server

  3. # It is v.0.0.2 version.

  4. # Chkconfig:-85 15

  5. # Description: Nginx is a high-performance web and proxy server.

  6. # It has a lot of features, but it's not for everyone.

  7. # Processname: nginx

  8. # Pidfile:/var/run/nginx. pid

  9. # Config:/usr/local/nginx/conf/nginx. conf

  10. Nginxd =/usr/local/nginx/sbin/nginx

  11. Nginx_config =/usr/local/nginx/conf/nginx. conf

  12. Nginx_pid =/var/run/nginx. pid

  13. RETVAL = 0

  14. Prog = "nginx"

  15. # Check that networking is up.

  16. [$ {NETWORKING} = "no"] & exit 0

  17. [-X $ nginxd] | exit 0

  18. # Start nginx daemons functions.

  19. Start (){

  20. If [-e $ nginx_pid]; then

  21. Echo "nginx already running ...."

  22. Exit 1

  23. Fi

  24. Echo-n $ "Starting $ prog :"

  25. $ Nginxd-c $ {nginx_config}

  26. RETVAL =$?

  27. Echo

  28. [$ RETVAL = 0]

  29. Return $ RETVAL

  30. }

  31. # Stop nginx daemons functions.

  32. Stop (){

  33. Echo-n $ "Stopping $ prog :"

  34. $ Nginxd-s stop

  35. RETVAL =$?

  36. Echo

  37. [$ RETVAL = 0]

  38. }

  39. # Reload nginx service functions.

  40. Reload (){

  41. Echo-n $ "Reloading $ prog :"

  42. # Kill-HUP 'cat $ {nginx_pid }'

  43. Killproc $ nginxd-HUP

  44. RETVAL =$?

  45. Echo

  46. }

  47. # See how we were called.

  48. Case "$1" in

  49. Start)

  50. Start

  51. ;;

  52. Stop)

  53. Stop

  54. ;;

  55. Reload)

  56. Reload

  57. ;;

  58. Restart)

  59. Stop

  60. Start

  61. ;;

  62. Status)

  63. Status $ prog

  64. RETVAL =$?

  65. ;;

  66. *)

  67. Echo $ "Usage: $ prog {start | stop }"

  68. Exit 1

  69. Esac

  70. Exit $ RETVAL

Java code

  1. Sudo chmod + x nginx

Java code

  1. Sudo update-rc.d-f nginx defaults


2: install jdk
Go to the official website to download the jdk with the suffix .tar.gz. the solution is under/usr/local/java.
Set environment variables:
Vi/etc // environment
Change the file to the following format:

Java code

  1. PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: /usr/local/java/bin"

  2. Export JAVA_HOME =/usr/local/java


You can.
Execute:

Java code

  1. Sudo source/etc/environment


3: install tomcat
Download tomcat directly to the/usr/local/tomcat directory.
Set tomcat as a system service:
Copy a copy of tomcat, the catalina. sh file under the bin directory to/etc/init. d, and change it to tomcat
Add the following lines before the file:

Java code

  1. Modify catalina. sh and add the following to the header ::

  2. JAVA_HOME =/usr/local/java

  3. CATALINA_HOME +/usr/local/tomcat

  4. CLASSPATH = $ JAVA_HOME/lib: $ CATALINA_HOME/lib

Java code

  1. Update-rc.d-f tomcat defaults


So OK.
4. install mysql
Download the green version of mysql to/usr/local/mysql
You may need to install the dependent database:

Java code

  1. Sudo apt-get install libaio1

Java code

  1. Sudo groupadd mysql

  2. Sudo useradd-r-g mysql

  3. Sudo chown-R mysql: mysql/usr/local/mysql

  4. Sudo scripts/mysql_install_db -- user = mysql

Java code

  1. Cd/etc/init. d

  2. Sudo ln-s/usr/local/mysql/support-files/mysql. server

  3. Sudo update-rc.d mysql. server defaults


Create a user:
Create user 'AAA' @ '%' identified by 'AAA ';
Grant all on *. * TO 'AAA' @ '% ';

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.