博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【CentOS 7架构21】,Nginx的安装#180104
阅读量:5764 次
发布时间:2019-06-18

本文共 11064 字,大约阅读时间需要 36 分钟。

hot3.png

hellopasswd


Nginx安装

  • cd /usr/local/src
  • wget
  • tar zxf nginx-1.4.7.tar.gz
  • ./configure --prefix=/usr/local/nginx
  • make && make install
  • vi /etc/init.d/nginx
[root@localhost ~]# cd /usr/local/src/[root@localhost src]# wget http://nginx.org/download/nginx-1.4.7.tar.gz--2018-01-04 09:31:08--  http://nginx.org/download/nginx-1.4.7.tar.gzResolving nginx.org (nginx.org)... 206.251.255.63, 95.211.80.227, 2001:1af8:4060:a004:21::e3, ...Connecting to nginx.org (nginx.org)|206.251.255.63|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 769153 (751K) [application/octet-stream]Saving to: ‘nginx-1.4.7.tar.gz’100%[======================================================================================>] 769,153      248KB/s   in 3.0s   2018-01-04 09:31:12 (248 KB/s) - ‘nginx-1.4.7.tar.gz’ saved [769153/769153][root@localhost src]# tar zxf nginx-1.4.7.tar.gz
[root@localhost src]# cd nginx-1.4.7/[root@localhost nginx-1.4.7]# ./configure --prefix=/usr/local/nginxchecking for OS + Linux 3.10.0-123.el7.x86_64 x86_64checking for C compiler ... found + using GNU C compiler + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) checking for gcc -pipe switch ... foundchecking for gcc builtin atomic operations ... foundchecking for C99 variadic macros ... foundchecking for gcc variadic macros ... foundchecking for unistd.h ... foundchecking for inttypes.h ... foundchecking for limits.h ... foundchecking for sys/filio.h ... not foundchecking for sys/param.h ... foundchecking for sys/mount.h ... foundchecking for sys/statvfs.h ... foundchecking for crypt.h ... foundchecking for Linux specific featureschecking for epoll ... foundchecking for sendfile() ... foundchecking for sendfile64() ... foundchecking for sys/prctl.h ... foundchecking for prctl(PR_SET_DUMPABLE) ... foundchecking for sched_setaffinity() ... foundchecking for crypt_r() ... foundchecking for sys/vfs.h ... foundchecking for nobody group ... foundchecking for poll() ... foundchecking for /dev/poll ... not foundchecking for kqueue ... not foundchecking for crypt() ... not foundchecking for crypt() in libcrypt ... foundchecking for F_READAHEAD ... not foundchecking for posix_fadvise() ... foundchecking for O_DIRECT ... foundchecking for F_NOCACHE ... not foundchecking for directio() ... not foundchecking for statfs() ... foundchecking for statvfs() ... foundchecking for dlopen() ... not foundchecking for dlopen() in libdl ... foundchecking for sched_yield() ... foundchecking for SO_SETFIB ... not foundchecking for SO_ACCEPTFILTER ... not foundchecking for TCP_DEFER_ACCEPT ... foundchecking for TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT ... foundchecking for TCP_INFO ... foundchecking for accept4() ... foundchecking for int size ... 4 byteschecking for long size ... 8 byteschecking for long long size ... 8 byteschecking for void * size ... 8 byteschecking for uint64_t ... foundchecking for sig_atomic_t ... foundchecking for sig_atomic_t size ... 4 byteschecking for socklen_t ... foundchecking for in_addr_t ... foundchecking for in_port_t ... foundchecking for rlim_t ... foundchecking for uintptr_t ... uintptr_t foundchecking for system byte ordering ... little endianchecking for size_t size ... 8 byteschecking for off_t size ... 8 byteschecking for time_t size ... 8 byteschecking for setproctitle() ... not foundchecking for pread() ... foundchecking for pwrite() ... foundchecking for sys_nerr ... foundchecking for localtime_r() ... foundchecking for posix_memalign() ... foundchecking for memalign() ... foundchecking for mmap(MAP_ANON|MAP_SHARED) ... foundchecking for mmap("/dev/zero", MAP_SHARED) ... foundchecking for System V shared memory ... foundchecking for POSIX semaphores ... not foundchecking for POSIX semaphores in libpthread ... foundchecking for struct msghdr.msg_control ... foundchecking for ioctl(FIONBIO) ... foundchecking for struct tm.tm_gmtoff ... foundchecking for struct dirent.d_namlen ... not foundchecking for struct dirent.d_type ... foundchecking for sysconf(_SC_NPROCESSORS_ONLN) ... foundchecking for openat(), fstatat() ... foundchecking for getaddrinfo() ... foundchecking for PCRE library ... foundchecking for PCRE JIT support ... foundchecking for md5 in system md library ... not foundchecking for md5 in system md5 library ... not foundchecking for md5 in system OpenSSL crypto library ... foundchecking for sha1 in system md library ... not foundchecking for sha1 in system OpenSSL crypto library ... foundchecking for zlib library ... foundcreating objs/MakefileConfiguration summary  + using system PCRE library  + OpenSSL library is not used  + md5: using system crypto library  + sha1: using system crypto library  + using system zlib library  nginx path prefix: "/usr/local/nginx"  nginx binary file: "/usr/local/nginx/sbin/nginx"  nginx configuration prefix: "/usr/local/nginx/conf"  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"  nginx pid file: "/usr/local/nginx/logs/nginx.pid"  nginx error log file: "/usr/local/nginx/logs/error.log"  nginx http access log file: "/usr/local/nginx/logs/access.log"  nginx http client request body temporary files: "client_body_temp"  nginx http proxy temporary files: "proxy_temp"  nginx http fastcgi temporary files: "fastcgi_temp"  nginx http uwsgi temporary files: "uwsgi_temp"  nginx http scgi temporary files: "scgi_temp"[root@localhost nginx-1.4.7]# make && make install	#

注释:#指定运行权限的用户 --user=nginx #指定运行的权限用户组 --group=nginx #指定安装路径 --prefix=/usr/local/nginx #支持nginx状态查询 --with-http_stub_status_module #开启ssl支持 --with-http_ssl_module #开启GZIP功能 --with-http_gzip_static_module

[root@localhost nginx-1.4.7]# ls /usr/local/nginx/conf  html  logs  sbin
[root@localhost nginx-1.4.7]# vi /etc/init.d/nginx      1 #!/bin/bash      2 # chkconfig: - 30 21      3 # description: http service.      4 # Source Function Library      5 . /etc/init.d/functions      6 # Nginx Settings      7 NGINX_SBIN="/usr/local/nginx/sbin/nginx"      8 NGINX_CONF="/usr/local/nginx/conf/nginx.conf"      9 NGINX_PID="/usr/local/nginx/logs/nginx.pid"     10 RETVAL=0     11 prog="Nginx"     12 start()     13 {     14     echo -n $"Starting $prog: "     15     mkdir -p /dev/shm/nginx_temp     16     daemon $NGINX_SBIN -c $NGINX_CONF     17     RETVAL=$?     18     echo     19     return $RETVAL     20 }     21 stop()     22 {     23     echo -n $"Stopping $prog: "     24     killproc -p $NGINX_PID $NGINX_SBIN -TERM     25     rm -rf /dev/shm/nginx_temp     26     RETVAL=$?     27     echo     28     return $RETVAL     29 }     30 reload()     31 {     32     echo -n $"Reloading $prog: "     33     killproc -p $NGINX_PID $NGINX_SBIN -HUP     34     RETVAL=$?     35     echo     36     return $RETVAL     37 }     38 restart()     39 {     40     stop     41     start     42 }     43 configtest()     44 {     45     $NGINX_SBIN -c $NGINX_CONF -t     46     return 0     47 }     48 case "$1" in     49   start)     50         start     51         ;;     52   stop)     53         stop     54         ;;     55   reload)     56         reload     57         ;;     58   restart)     59         restart     60         ;;     61   configtest)     62         configtest     63         ;;     64   *)     65         echo $"Usage: $0 {start|stop|reload|restart|configtest}"     66         RETVAL=1     67 esac     68 exit $RETVAL
[root@localhost nginx-1.4.7]# chmod 755 /etc/init.d/nginx [root@localhost nginx-1.4.7]# chkconfig --add nginx[root@localhost nginx-1.4.7]# chkconfig nginx on
[root@localhost nginx-1.4.7]# cd /usr/local/nginx/conf/[root@localhost conf]# mv nginx.conf nginx.conf.1[root@localhost conf]# vi nginx.conf      1 user nobody nobody;      2 worker_processes 2;      3 error_log /usr/local/nginx/logs/nginx_error.log crit;      4 pid /usr/local/nginx/logs/nginx.pid;      5 worker_rlimit_nofile 51200;      6 events      7 {      8     use epoll;      9     worker_connections 6000;     10 }     11 http     12 {     13     include mime.types;     14     default_type application/octet-stream;     15     server_names_hash_bucket_size 3526;     16     server_names_hash_max_size 4096;     17     log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'     18     ' $host "$request_uri" $status'     19     ' "$http_referer" "$http_user_agent"';     20     sendfile on;     21     tcp_nopush on;     22     keepalive_timeout 30;     23     client_header_timeout 3m;     24     client_body_timeout 3m;     25     send_timeout 3m;     26     connection_pool_size 256;     27     client_header_buffer_size 1k;     28     large_client_header_buffers 8 4k;     29     request_pool_size 4k;     30     output_buffers 4 32k;     31     postpone_output 1460;     32     client_max_body_size 10m;     33     client_body_buffer_size 256k;     34     client_body_temp_path /usr/local/nginx/client_body_temp;     35     proxy_temp_path /usr/local/nginx/proxy_temp;     36     fastcgi_temp_path /usr/local/nginx/fastcgi_temp;     37     fastcgi_intercept_errors on;     38     tcp_nodelay on;     39     gzip on;     40     gzip_min_length 1k;     41     gzip_buffers 4 8k;     42     gzip_comp_level 5;     43     gzip_http_version 1.1;     44     gzip_types text/plain application/x-javascript text/css text/htm     45     application/xml;     46     server     47     {     48         listen 80;     49         server_name localhost;     50         index index.html index.htm index.php;     51         root /usr/local/nginx/html;     52         location ~ \.php$     53         {     54             include fastcgi_params;     55             fastcgi_pass unix:/tmp/php-fcgi.sock;     56             fastcgi_index index.php;     57             fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;     58         }     59     }     60 }
[root@localhost conf]# /usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[root@localhost conf]# /etc/init.d/nginx startStarting nginx (via systemctl):                            [  OK  ]
[root@localhost conf]# ps aux | grep nginxroot       5676  0.0  0.0  24804   784 ?        Ss   09:49   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confnobody     5677  0.0  0.1  27108  3364 ?        S    09:49   0:00 nginx: worker processnobody     5678  0.0  0.1  27108  3364 ?        S    09:49   0:00 nginx: worker processroot       5682  0.0  0.0 112660   976 pts/0    S+   09:50   0:00 grep --color=auto nginx

测试

[root@localhost conf]# curl localhostWelcome to nginx!

Welcome to nginx!

If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.

For online documentation and support please refer tonginx.org.

Commercial support is available atnginx.com.

Thank you for using nginx.

ls /usr/local/nginx/html/index.html curl 192.168.9.134

[root@localhost conf]# vi /usr/local/nginx/html/1.php      1 

修改于180104

转载于:https://my.oschina.net/hellopasswd/blog/1601454

你可能感兴趣的文章
【348天】每日项目总结系列086(2018.01.19)
查看>>
【JS基础】初谈JS现有的数据类型
查看>>
【294天】我爱刷题系列053(2017.11.26)
查看>>
Microsoft发布了Azure Bot Service和LUIS的GA版
查看>>
Google发布Puppeteer 1.0
查看>>
.NET开源现状
查看>>
可替换元素和非可替换元素
查看>>
2016/08/25 The Secret Assumption of Agile
查看>>
(Portal 开发读书笔记)Portlet间交互-PortletSession
查看>>
搭建vsftpd服务器,使用匿名账户登入
查看>>
AMD改善Linux驱动,支持动态电源管理
查看>>
JAVA中循环删除list中元素的方法总结
查看>>
Java虚拟机管理的内存运行时数据区域解释
查看>>
人人都会深度学习之Tensorflow基础快速入门
查看>>
ChPlayer播放器的使用
查看>>
js 经过修改改良的全浏览器支持的软键盘,随机排列
查看>>
Mysql读写分离
查看>>
Oracle 备份与恢复学习笔记(5_1)
查看>>
Oracle 备份与恢复学习笔记(14)
查看>>
分布式配置中心disconf第一部(基本介绍)
查看>>