Linux configuration nginx,mysql,php-fpm Boot-up method

Source: Internet
Author: User
Tags chmod fpm

One. Nginx Boot start

Nginx shell script placed under/etc/init.d/named Nginx

The following code changes according to your original installation path

nginx= "/usr/localinx/sbininx"
Nginx_conf_file= "/usr/local/nginx/conf/nginx.conf"

[Plain]View PlainCopy
  1. #!/bin/sh
  2. #
  3. # Nginx-this script starts and stops the Nginx daemon
  4. #
  5. # Chkconfig:-85 15
  6. # Description:nginx is an HTTP (s) server, HTTP (s) reverse
  7. # Proxy and IMAP/POP3 proxy server
  8. # Processname:nginx
  9. # chkconfig:2345 91<span style= "White-space:pre" > </span>
  10. # Description:nginx Web Server
  11. # Processname:nginx
  12. # config:/opt/nginx/conf/nginx.conf
  13. # Pidfile:/opt/nginx/nginx.pid
  14. # Source function library.
  15. . /etc/init.d/functions
  16. # Source Networking configuration.
  17. . /etc/sysconfig/network
  18. if [-f/etc/sysconfig/nginx];then
  19. . /etc/sysconfig/nginx
  20. Fi
  21. # Check that networking are up.
  22. ["$NETWORKING" = "no"] && exit 0
  23. nginx= "/usr/local/nginx/sbin/nginx"
  24. prog=$ (basename $nginx)
  25. Nginx_conf_file= "/usr/local/nginx/conf/nginx.conf"
  26. [-f/etc/sysconfig/nginx] &&. /etc/sysconfig/nginx
  27. Lockfile=/var/lock/subsys/nginx
  28. Start () {
  29. [-X $nginx] | | Exit 5
  30. [-F $NGINX _conf_file] | | Exit 6
  31. Echo-n $ "Starting $prog:"
  32. Daemon $nginx #-c $NGINX _conf_file
  33. Retval=$?
  34. Echo
  35. [$retval-eq 0] && Touch $lockfile
  36. Return $retval
  37. }
  38. Stop () {
  39. Echo-n $ "Stopping $prog:"
  40. Killproc $prog-quit
  41. Retval=$?
  42. Echo
  43. [$retval-eq 0] && rm-f $lockfile
  44. Return $retval
  45. Killall-9 Nginx
  46. }
  47. Restart () {
  48. Configtest | | Return $?
  49. Stop
  50. Sleep 1
  51. Start
  52. }
  53. Reload () {
  54. Configtest | | Return $?
  55. Echo-n $ "Reloading $prog:"
  56. Killproc $nginx-hup
  57. Retval=$?
  58. Echo
  59. }
  60. Force_reload () {
  61. Restart
  62. }
  63. Configtest () {
  64. $nginx-T #-c $NGINX _conf_file
  65. }
  66. Rh_status () {
  67. Status $prog
  68. }
  69. Rh_status_q () {
  70. Rh_status >/dev/null 2>&1
  71. }
  72. Case "$" in
  73. Start
  74. <span style= "White-space:pre" > </span>rh_status_q && exit 0
  75. <span style= "White-space:pre" > </span>$1
  76. <span style= "White-space:pre" > </span>;;
  77. Stop
  78. Rh_status_q | | Exit 0
  79. <span style= "White-space:pre" > </span>$1
  80. <span style= "White-space:pre" > </span>;;
  81. Restart
  82. <span style= "White-space:pre" > </span>$1
  83. <span style= "White-space:pre" > </span>;;
  84. Test
  85. <span style= "White-space:pre" > </span>configtest
  86. <span style= "White-space:pre" > </span>;;
  87. Reload
  88. <span style= "White-space:pre" > </span>rh_status_q | | Exit 7
  89. <span style= "White-space:pre" > </span>$1
  90. <span style= "White-space:pre" > </span>;;
  91. Force-reload)
  92. <span style= "White-space:pre" > </span>force_reload
  93. <span style= "White-space:pre" > </span>;;
  94. Status
  95. <span style= "White-space:pre" > </span>rh_status
  96. <span style= "White-space:pre" > </span>;;
  97. Condrestart|try-restart)
  98. <span style= "White-space:pre" > </span>rh_status_q | | Exit 0
  99. <span style= "White-space:pre" > </span>;;
  100. *)
  101. echo $ "Usage: $ {start|stop|status|restart|condrestart|try-restart|reload|force-reload|test}"
  102. Exit 2
  103. Esac


Change Script Permissions chmod 775/etc/init.d/nginx

Two. mysql boot up
Copy the Mysql.server file from the Support-files directory under the MySQL installation directory to the/etc/init.d/directory and rename it to Mysqld, and change the permissions

chmod 775/etc/init.d/mysqld

Three. PHP Boot up

The PHP-FPM shell script is placed under/etc/init.d/name PHP-FPM,

    1. Php_command=/usr/local/php/sbin/php-fom
    2. Php_config=/usr/local/php/etc/php-fpm.conf

According to your installation path to change

[Plain]View PlainCopy
  1. #!/bin/bash
  2. # PHP-FPM startup script for the PHP-FPM
  3. # PHP-FPM VERSION:5.5.0-ALPHA6
  4. # Chkconfig:-85 15
  5. # DESCRIPTION:PHP-FPM is very good
  6. # PROCESSNAME:PHP-FPM
  7. # Pidfile:/var/run/php-fpm.pid
  8. # config:/usr/local/php/etc/php-fpm.conf
  9. Php_command=/usr/local/php/sbin/php-fom
  10. Php_config=/usr/local/php/etc/php-fpm.conf
  11. Php_pid=/usr/local/php/var/run/php-fpm.pid
  12. Retval=0
  13. Prog= "PHP-FPM"
  14. #start function
  15. Php_fpm_start () {
  16. /usr/local/php/sbin/php-fpm
  17. }
  18. Start () {
  19. If [-e $php _pid]
  20. Then
  21. echo "PHP-FPM already start ..."
  22. Exit 1
  23. Fi
  24. Php_fpm_start
  25. }
  26. Stop () {
  27. If [-e $php _pid]
  28. Then
  29. Parent_pid= ' Cat $php _pid '
  30. All_pid= ' Ps-ef | grep php-fpm | awk ' {if (' $parent _pid ' = = $ $) {print $}} '
  31. For PID in $all _pid
  32. Do
  33. Kill $pid
  34. Done
  35. Kill $parent _pid
  36. Fi
  37. Exit 1
  38. }
  39. Restart () {
  40. Stop
  41. Start
  42. }
  43. # See how we were called.
  44. Case "$" in
  45. Start
  46. Start
  47. ;;
  48. Stop
  49. Stop
  50. ;;
  51. Restart
  52. Stop
  53. Start
  54. ;;
  55. Status
  56. Status $prog
  57. Retval=$?
  58. ;;
  59. *)
  60. echo $ "Usage: $prog {start|stop|restart|status}"
  61. Exit 1
  62. Esac
  63. Exit $RETVAL

Using Chkconfig for Management

[Plain]View PlainCopy
    1. Chkconfig--add/etc/init.d/nginx
    2. Chkconfig--add/etc/init.d/mysqld
    3. Chkconfig--ADD/ETC/INIT.D/PHP-FPM

Set up terminal mode boot:

[Plain]View PlainCopy
      1. Chkconfig PHP-FPM on
      2. Chkconfig Nginx on
      3. Chkconfig mysqld on

Linux configuration nginx,mysql,php-fpm Boot-up method

Related Article

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.