一键安装nginx
系统版本CentOS> 2.6.32-696.el6.x86_64 x86_64
#安装pcre pcre-devel
# yum install pcre pcre-devel -y
#检查pcre pcre-devel
# rpm -qa pcre pcre-devel
pcre-7.8-7.el6.x86_64
pcre-devel-7.8-7.el6.x86_64
#安装openssl-devel,使用nginx必须安装这个软件来支持
# yum install openssl-devel -y
#检查openssl-devel openssl
# rpm -qa openssl-devel openssl#检查openssl-devel openssl
openssl-1.0.1e-57.el6.x86_64
openssl-devel-1.0.1e-57.el6.x86_6
#添加用户
useradd oldboy
#创建tools目录
mkdir /home/oldboy/tools
cd /home/oldboy/tools/
#下载nginx,具体需要什么版本自己可以到 http://nginx.org官网下载
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
#查看到下载的nginx
# ll
总用量 788
-rw-r--r-- 1 root root 805253 4月 8 2015 nginx-1.6.3.tar.gz
#解压压缩包
# tar xf nginx-1.6.3.tar.gz
#cd到nginx-1.6.3目录下
cd nginx-1.6.3
#创建application目录存放软件
mkdir /application
#创建虚拟用户
# useradd www -s /sbin/nologin -M
#编译安装nginx
./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/
#查看编辑是否成功
# echo $? #返回
0表示配置成功
0
# make #返回0直接就用make编译
同样是echo $?是返回0正常
#安装
# make install
#安装完成之后,为了以后更新软件方便,需要创建一个软链接给nginx
# ln -s /application/nginx-1.6.3/ /application/nginx
# cd /application/
# ll
总用量 4
lrwxrwxrwx 1 root root 25 2月27 11:13 nginx -> /application/nginx-1.6.3/
drwxr-xr-x 6 root root 4096 2月27 11:12 nginx-1.6.3
#启动nginx
# /application/nginx/sbin/nginx
# /application/nginx/sbin/nginx -t #检查语法对不对
1. 1. nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
# netstat -lntup |grep 80 #查看nginx端口是否启动
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 45878/nginx
在自己浏览器查看是否成功
一键安装命令如下:
# cat nginx.sh
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
LANG=en
yum install pcre pcre-devel -y
yum install openssl-devel -y
useradd oldboy
mkdir /home/oldboy/tools
cd /home/oldboy/tools/
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
mkdir /application
useradd www -s /sbin/nologin -M
./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/
echo $?
make
echo $?
make install
ln -s /application/nginx-1.6.3/ /application/nginx
cd /application/
/application/nginx/sbin/nginx
/application/nginx/sbin/nginx -t
netstat -lntup |grep 80
页:
[1]