CentOS 7下編譯安裝Nginx 1.11.10教程
前言
之前分享過一篇 CentOS下編譯安裝nginx及配置縮略圖插件的方法教程,當(dāng)時(shí)的環(huán)境是 CentOS 6.x 和 Nginx 1.9.x 。 本次安裝的環(huán)境為 CentOS 7.2 和 Nginx 1.11.10, 有些配置以前自啟動(dòng)的方式發(fā)生了變化, 這里再記錄一下。
安裝編譯安裝依賴的類庫和包
yum install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel
下載和解壓 Nginx 1.11.10
wget http://nginx.org/download/nginx-1.11.10.tar.gz tar -xzvf nginx-1.11.10.tar.gz cd nginx-1.11.10
配置 Nginx 安裝選項(xiàng)
這里編譯了插件 http_image_filter_module, 來實(shí)現(xiàn)圖片的處理,采用默認(rèn)的安裝路徑進(jìn)行安裝。
./configure\ --with-http_ssl_module\ --with-http_v2_module\ --with-http_realip_module\ --with-http_addition_module\ --with-http_xslt_module\ --with-http_image_filter_module\ --with-http_sub_module\ --with-http_auth_request_module\ --with-http_stub_status_module\ --with-http_gzip_static_module
運(yùn)行結(jié)果如下
[root@xx nginx-1.11.10]# ./configure\ > --with-http_ssl_module\ > --with-http_v2_module\ > --with-http_realip_module\ > --with-http_addition_module\ > --with-http_xslt_module\ > --with-http_image_filter_module\ > --with-http_sub_module\ > --with-http_auth_request_module\ > --with-http_stub_status_module\ > --with-http_gzip_static_module checking for OS + Linux 3.10.0-327.22.2.el7.x86_64 x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) checking for gcc -pipe switch ... found checking for -Wl,-E switch ... found checking for gcc builtin atomic operations ... found checking for C99 variadic macros ... found checking for gcc variadic macros ... found checking for gcc builtin 64 bit byteswap ... found checking for unistd.h ... found checking for inttypes.h ... found checking for limits.h ... found checking for sys/filio.h ... not found checking for sys/param.h ... found checking for sys/mount.h ... found checking for sys/statvfs.h ... found checking for crypt.h ... found checking for Linux specific features checking for epoll ... found checking for EPOLLRDHUP ... found checking for EPOLLEXCLUSIVE ... not found checking for O_PATH ... found checking for sendfile() ... found checking for sendfile64() ... found checking for sys/prctl.h ... found checking for prctl(PR_SET_DUMPABLE) ... found checking for sched_setaffinity() ... found checking for crypt_r() ... found checking for sys/vfs.h ... found checking for poll() ... found checking for /dev/poll ... not found checking for kqueue ... not found checking for crypt() ... not found checking for crypt() in libcrypt ... found checking for F_READAHEAD ... not found checking for posix_fadvise() ... found checking for O_DIRECT ... found checking for F_NOCACHE ... not found checking for directio() ... not found checking for statfs() ... found checking for statvfs() ... found checking for dlopen() ... not found checking for dlopen() in libdl ... found checking for sched_yield() ... found checking for SO_SETFIB ... not found checking for SO_REUSEPORT ... found checking for SO_ACCEPTFILTER ... not found checking for SO_BINDANY ... not found checking for IP_BIND_ADDRESS_NO_PORT ... not found checking for IP_TRANSPARENT ... found checking for IP_BINDANY ... not found checking for IP_RECVDSTADDR ... not found checking for IP_PKTINFO ... found checking for IPV6_RECVPKTINFO ... found checking for TCP_DEFER_ACCEPT ... found checking for TCP_KEEPIDLE ... found checking for TCP_FASTOPEN ... found checking for TCP_INFO ... found checking for accept4() ... found checking for eventfd() ... found checking for int size ... 4 bytes checking for long size ... 8 bytes checking for long long size ... 8 bytes checking for void * size ... 8 bytes checking for uint32_t ... found checking for uint64_t ... found checking for sig_atomic_t ... found checking for sig_atomic_t size ... 4 bytes checking for socklen_t ... found checking for in_addr_t ... found checking for in_port_t ... found checking for rlim_t ... found checking for uintptr_t ... uintptr_t found checking for system byte ordering ... little endian checking for size_t size ... 8 bytes checking for off_t size ... 8 bytes checking for time_t size ... 8 bytes checking for AF_INET6 ... found checking for setproctitle() ... not found checking for pread() ... found checking for pwrite() ... found checking for pwritev() ... found checking for sys_nerr ... found checking for localtime_r() ... found checking for posix_memalign() ... found checking for memalign() ... found checking for mmap(MAP_ANON|MAP_SHARED) ... found checking for mmap("/dev/zero", MAP_SHARED) ... found checking for System V shared memory ... found checking for POSIX semaphores ... not found checking for POSIX semaphores in libpthread ... found checking for struct msghdr.msg_control ... found checking for ioctl(FIONBIO) ... found checking for struct tm.tm_gmtoff ... found checking for struct dirent.d_namlen ... not found checking for struct dirent.d_type ... found checking for sysconf(_SC_NPROCESSORS_ONLN) ... found checking for openat(), fstatat() ... found checking for getaddrinfo() ... found checking for PCRE library ... found checking for PCRE JIT support ... found checking for OpenSSL library ... found checking for zlib library ... found checking for libxslt ... found checking for libexslt ... found checking for GD library ... found checking for GD WebP support ... not found creating objs/Makefile Configuration summary + using system PCRE library + using system OpenSSL library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" 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"
最后的幾行是配置的結(jié)果, 注意這里的 pid file 那一行,后面配置服務(wù)的時(shí)候,需要用的到。
安裝 Nginx
使用如下命令來安裝 nginx 。
make && make install
配置 systemd Nginx 服務(wù)和設(shè)置 Nginx 自啟動(dòng)
centos 7 中采用 systemd 來管理系統(tǒng),我們來為 nginx 創(chuàng)建服務(wù)文件,來實(shí)現(xiàn)通過 systemd 來管理 nginx 。
創(chuàng)建 systemd 服務(wù)文件: /lib/systemd/system/nginx.service,內(nèi)容如下:
[Unit] Description=The NGINX HTTP and reverse proxy server After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
這里的 PIDFile 的配置要和前面的 配置保持一致。
設(shè)置自啟動(dòng)
systemctl enable nginx
通過 systemd 管理 nginx
systemctl start nginx systemctl stop nginx systemctl restart nginx systemctl reload nginx
總結(jié)
好了,打完收工。以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對(duì)腳本之家的支持。
- CentOS 7.3.1611編譯安裝Nginx1.10.3+MySQL5.7.16+PHP7.1.2
- Centos6.4 編譯安裝 nginx php的方法
- Centos 6.8編譯安裝LNMP環(huán)境(Nginx+MySQL+PHP)教程
- Centos7下編譯安裝配置Nginx+PHP+MySql環(huán)境
- CentOS 6.5編譯安裝Nginx 1.10.2+MySQL 5.5.52+PHP5.5.38
- CentOS下編譯安裝nginx及配置縮略圖插件的方法教程
- Centos下編譯安裝Nginx教程詳解
- CentOS 7.2.1511 編譯安裝Nginx1.10.1+MySQL5.6.33+PHP5.6.26運(yùn)行環(huán)境
- CentOS 7.2.1511 編譯安裝Nginx1.10.1+MySQL5.7.14+PHP7.0.11
- CentOS 7.0編譯安裝lnmp教程(Nginx1.6.0+MySQL5.6.19+PHP5.5.14)
- CentOS 6.6服務(wù)器編譯安裝lnmp(Nginx1.6.2+MySQL5.6.21+PHP5.6.3)
- CentOS 7.2 下編譯安裝PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法詳解(mini版本)
- CentOS 7.x編譯安裝Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能環(huán)境
相關(guān)文章
Nginx中的用戶認(rèn)證配置及阻止用戶使用代理訪問的方法
這篇文章主要介紹了Nginx中的用戶認(rèn)證配置及阻止用戶使用代理訪問的方法,用戶認(rèn)證部分用到了自帶的ngx_http_auth_basic_module模塊,需要的朋友可以參考下2016-01-01Nginx反向代理多域名的HTTP和HTTPS服務(wù)的實(shí)現(xiàn)
這篇文章主要介紹了Nginx反向代理多域名的HTTP和HTTPS服務(wù)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06nginx簡(jiǎn)單配置多個(gè)server的方法
這篇文章主要介紹了nginx簡(jiǎn)單配置多個(gè)server的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11Nginx的location路徑與proxy_pass匹配規(guī)則說明
這篇文章主要介紹了Nginx的location路徑與proxy_pass匹配規(guī)則說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-06-06Mac上搭建nginx+rtmp直播服務(wù)器的步驟詳解
最近的直播很火,所以這篇文章跟大家分享了在Mac上搭建nginx+rtmp直播服務(wù)器的步驟,文章通過一步步圖文介紹的很詳細(xì),有需要的朋友們可以參考借鑒。2016-09-09