Nginx安裝過程linux
linux版本系統nginx
[root@amigo ~]# cat /etc/redhat-release web
CentOS release 6.6 (Final)vim
[root@amigo ~]# uname -r瀏覽器
2.6.32-504.el6.x86_64ide
須要先關閉linux防火牆和selinuxui
關閉linux防火牆this
[root@amigo nginx-1.6.3]# chkconfig iptables offatom
[root@amigo nginx-1.6.3]# /etc/init.d/iptables stopspa
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
關閉selinx
[root@amigo etc]# vim /etc/selinux/config
SELINUX=disabled
安裝nginx依賴
[root@amigo ~]# yum install pcre pcre-devel openssl openssl-devel
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
*base: mirrors.btte.net
*extras: mirrors.nwsuaf.edu.cn
*updates: mirrors.nwsuaf.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package openssl.x86_640:1.0.1e-30.el6 will be updated
---> Package openssl.x86_640:1.0.1e-48.el6_8.3 will be an update
---> Package openssl-devel.x86_640:1.0.1e-48.el6_8.3 will be installed
--> Processing Dependency: zlib-develfor package: openssl-devel-1.0.1e-48.el6_8.3.x86_64
--> Processing Dependency: krb5-develfor package: openssl-devel-1.0.1e-48.el6_8.3.x86_64
---> Package pcre.x86_64 0:7.8-6.el6will be updated
---> Package pcre.x86_64 0:7.8-7.el6will be an update
---> Package pcre-devel.x86_640:7.8-7.el6 will be installed
此過程省略。。
查看依賴安裝版本及是否成功
[root@amigo ~]# rpm -qa pcre pcre-devel openssl openssl-devel
pcre-7.8-7.el6.x86_64
openssl-devel-1.0.1e-48.el6_8.3.x86_64
openssl-1.0.1e-48.el6_8.3.x86_64
pcre-devel-7.8-7.el6.x86_64
建立tools文件夾存放nginx下載包
[root@amigo ~]# mkdir -p /home/oldboy/tools
下載nginx版本
[root@amigo tools]# wget -qhttp://nginx.org/download/nginx-1.6.3.tar.gz
[root@amigo tools]# ls
nginx-1.6.3.tar.gz
建立傀儡用戶
[root@amigo tools]# useradd nginx -s /sbin/nologin -M
解壓nginx安裝包
[root@amigo tools]# tar xf nginx-1.6.3.tar.gz
進入nginx目錄並執行編譯
[root@amigo tools]# cd nginx-1.6.3
[root@amigo nginx-1.6.3]# ./configure --user=nginx --group=nginx--prefix=/aplication/nginx-1.6.3/ --with-http_stub_status_module--with-http_ssl_module
checking for OS
+Linux 2.6.32-504.el6.x86_64 x86_64
checking for C compiler ... found
+using GNU C compiler
+gcc version: 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... 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
此過程省略。。
make
make install
建立軟連接文件
[root@amigo nginx-1.6.3]# ln -s /aplication/nginx-1.6.3//aplication/nginx
啓動並檢查nginx配置文件
[root@amigo nginx-1.6.3]# /aplication/nginx/sbin/nginx -t
nginx: the configuration file/aplication/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /aplication/nginx-1.6.3//conf/nginx.conftest is successful
啓動nginx
[root@amigo nginx-1.6.3]# /aplication/nginx/sbin/nginx
查看nginx服務端口是否啓動
[root@amigo nginx-1.6.3]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODENAME
nginx 7538 root 6u IPv4 50782 0t0 TCP *:http (LISTEN)
nginx 7539 nginx 6u IPv4 50782 0t0 TCP *:http (LISTEN)
瀏覽器輸入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 to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.