linux企业常用服务---编译安装nginx
2016-05-15 13:02
816 查看
网络下载nginx源码包:
wget http://nginx.org/download/nginx-1.6.2.tar.gz 安装依赖:
yum install pcre-devel zlib-devel ##本地的光盘作为yum源
安装nginx:
useradd -M -s /sbin/nologin nginx
tar zxvf nginx-1.6.2.tar.gz -C /usr/src/
cd /usr/src/nginx-1.6.2/
[root@www nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module ##编译安装-指定家目录-指定用户-指定组-携带模块
[root@www nginx-1.6.2]# make &&make install
[root@www nginx-1.6.2]# ls /usr/local/nginx/ ##验证安装
conf html logs sbin
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ##优化执行路径
ls -l /usr/local/sbin/
总用量 0
lrwxrwxrwx. 1 root root 27 12月 30 20:03 nginx -> /usr/local/nginx/sbin/nginx
启动nginx:
nginx ##启动
netstat -utpln |grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8311/nginx
访问测试:
/etc/init.d/iptables stop
setenforce 0
[root@www ~]# elinks --dump http://IP地址
添加nginx为系统服务:
vi /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 99 20
# description: Nginx Server Control Script
NP="/usr/local/nginx/sbin/nginx"
NPF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$NP;
if [ $? -eq 0 ]
then
echo "nginx is starting!! "
fi
;;
stop)
kill -s QUIT $(cat $NPF)
if [ $? -eq 0 ]
then
echo "nginx is stopping!! "
fi
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $NPF)
if [ $? -eq 0 ]
then
echo "nginx config file is reload! "
fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
:wq
chmod +x /etc/init.d/nginx
chkconfig --add nginx
/etc/init.d/nginx restart
[root@www conf]# pwd
/usr/local/nginx/conf
[root@www conf]# vi nginx.conf ##编辑配置文件在server中添加如下行:
location /status {
stub_status on;
access_log off;
}
:wq
/etc/init.d/nginx restart
nginx is stopping!!
nginx is starting!!
访问测试:IE http://ip地址/status
本文出自 “LP-linux” 博客,请务必保留此出处http://linuxlp.blog.51cto.com/11463376/1773553
wget http://nginx.org/download/nginx-1.6.2.tar.gz 安装依赖:
yum install pcre-devel zlib-devel ##本地的光盘作为yum源
安装nginx:
useradd -M -s /sbin/nologin nginx
tar zxvf nginx-1.6.2.tar.gz -C /usr/src/
cd /usr/src/nginx-1.6.2/
[root@www nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module ##编译安装-指定家目录-指定用户-指定组-携带模块
[root@www nginx-1.6.2]# make &&make install
[root@www nginx-1.6.2]# ls /usr/local/nginx/ ##验证安装
conf html logs sbin
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ##优化执行路径
ls -l /usr/local/sbin/
总用量 0
lrwxrwxrwx. 1 root root 27 12月 30 20:03 nginx -> /usr/local/nginx/sbin/nginx
启动nginx:
nginx ##启动
netstat -utpln |grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8311/nginx
访问测试:
/etc/init.d/iptables stop
setenforce 0
[root@www ~]# elinks --dump http://IP地址
添加nginx为系统服务:
vi /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 99 20
# description: Nginx Server Control Script
NP="/usr/local/nginx/sbin/nginx"
NPF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$NP;
if [ $? -eq 0 ]
then
echo "nginx is starting!! "
fi
;;
stop)
kill -s QUIT $(cat $NPF)
if [ $? -eq 0 ]
then
echo "nginx is stopping!! "
fi
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $NPF)
if [ $? -eq 0 ]
then
echo "nginx config file is reload! "
fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
:wq
chmod +x /etc/init.d/nginx
chkconfig --add nginx
/etc/init.d/nginx restart
[root@www conf]# pwd
/usr/local/nginx/conf
[root@www conf]# vi nginx.conf ##编辑配置文件在server中添加如下行:
location /status {
stub_status on;
access_log off;
}
:wq
/etc/init.d/nginx restart
nginx is stopping!!
nginx is starting!!
访问测试:IE http://ip地址/status
本文出自 “LP-linux” 博客,请务必保留此出处http://linuxlp.blog.51cto.com/11463376/1773553
相关文章推荐
- Linux下php7.0.6+nginx环境编译安装
- nginx的配置文件详细说明
- windows下安装nginx
- Linux下安装nginx
- (总结)Nginx配置文件nginx.conf中文详解
- nginx upstream模块--负载均衡
- Nginx日志切割及常用统计脚本
- NGINX userid 分析、解码
- 使用nginx的proxy_cache做网站缓存
- Nginx+Keepalived实现站点高可用(主备)
- nginx地址跳转及域名解析
- nginx负载均衡详解
- 服务器反爬虫攻略:Apache/Nginx/PHP禁止某些User Agent抓取网站(转)
- nginx打开目录浏览
- debian完整部署 Nginx + uWSGI + Django
- Nginx 安装升级脚本
- Nginx的模块开发指南
- 你知道Nginx的七大优势吗?
- Nginx动静分离实现
- Linux操作系统安装nginxs