• linux安装nginx


    一、下载安装包

    nginx下载地址:http://nginx.org/download

    二、解压安装包

    tar -zxvf nginx-1.3.7.tar.gz

    三、编译安装

    1. cd nginx-1.9.9
    2. //编译
    3. ./configure --prefix=/usr/local/nginx
    4. //安装
    5. make && make install

    如果编译报错,需要安装依赖

    yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel pcre-devel

    四、添加nginx服务

    1. #!/bin/sh
    2. # nginx - this script starts and stops the nginx daemin
    3. #
    4. # chkconfig: - 85 15
    5. # description: Nginx is an HTTP(S) server, HTTP(S) reverse \
    6. # proxy and IMAP/POP3 proxy server
    7. # processname: nginx
    8. # config: /usr/local/nginx/conf/nginx.conf
    9. # pidfile: /usr/local/nginx/logs/nginx.pid
    10. # Source function library.
    11. . /etc/rc.d/init.d/functions
    12. # Source networking configuration.
    13. . /etc/sysconfig/network
    14. # Check that networking is up.
    15. [ "$NETWORKING" = "no" ] && exit 0
    16. nginx="/usr/local/nginx/sbin/nginx"
    17. prog=$(basename $nginx)
    18. NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
    19. lockfile=/var/lock/subsys/nginx
    20. start() {
    21. [ -x $nginx ] || exit 5
    22. [ -f $NGINX_CONF_FILE ] || exit 6
    23. echo -n $"Starting $prog: "
    24. daemon $nginx -c $NGINX_CONF_FILE
    25. retval=$?
    26. echo
    27. [ $retval -eq 0 ] && touch $lockfile
    28. return $retval
    29. }
    30. stop() {
    31. echo -n $"Stopping $prog: "
    32. killproc $prog -QUIT
    33. retval=$?
    34. echo
    35. [ $retval -eq 0 ] && rm -f $lockfile
    36. return $retval
    37. }
    38. restart() {
    39. configtest || return $?
    40. stop
    41. start
    42. }
    43. reload() {
    44. configtest || return $?
    45. echo -n $"Reloading $prog: "
    46. killproc $nginx -HUP
    47. RETVAL=$?
    48. echo
    49. }
    50. force_reload() {
    51. restart
    52. }
    53. configtest() {
    54. $nginx -t -c $NGINX_CONF_FILE
    55. }
    56. rh_status() {
    57. status $prog
    58. }
    59. rh_status_q() {
    60. rh_status >/dev/null 2>&1
    61. }
    62. case "$1" in
    63. start)
    64. rh_status_q && exit 0
    65. $1
    66. ;;
    67. stop)
    68. rh_status_q || exit 0
    69. $1
    70. ;;
    71. restart|configtest)
    72. $1
    73. ;;
    74. reload)
    75. rh_status_q || exit 7
    76. $1
    77. ;;
    78. force-reload)
    79. force_reload
    80. ;;
    81. status)
    82. rh_status
    83. ;;
    84. condrestart|try-restart)
    85. rh_status_q || exit 0
    86. ;;
    87. *)
    88. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
    89. exit 2
    90. esac
    1. cd /etc/init.d
    2. chmod 755 /etc/init.d/nginx
    3. chkconfig --add nginx
    4. service nginx start

     

  • 相关阅读:
    【Unity100个实用小技巧】世界Canvas自动隐藏,包含子物体
    2022年Java秋招面试必看的 | Linux 面试题
    python爬虫requests.get乱码问题
    web阶段javascript
    Python交互Mysql数据库基本操作
    UGeek大咖说 | 顺丰科技:全链路压测中的可观测性实践
    MQ 介绍
    【Kotlin精简】第6章 反射
    惊!这么好用的纯html网页模板可还行?偷偷拿去做作业真是绝绝子!!
    python解析.hhr文件
  • 原文地址:https://blog.csdn.net/qq_36635569/article/details/134423844