003.安装nginx(lnmp)
一.下载nginx
下载nginx源码包,解压:
[root@huh ~]# cd /usr/local/src/
[root@huh src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
[root@huh src]# tar zxvf nginx-1.6.2.tar.gz
[root@huh src]# cd nginx-1.6.2
二.安装nginx
[root@huh nginx-1.6.2]# yum install -y pcre-devel
[root@huh nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module
[root@huh nginx-1.6.2]# make
[root@huh nginx-1.6.2]# make install
注:1.pcre是用来做正则的
2.我们将ngnix安装在/usr/lcoal/nginx目录下
三.启动nginx
[root@huh nginx-1.6.2]# cd /usr/local/nginx/
[root@huh nginx]# /usr/local/nginx/sbin/nginx
注:/usr/local/nginx/sbin/nginx可以启动nginx
查看nginx进程和监听端口:
[root@huh nginx]# ps aux |grep nginx
root 18714 0.0 0.0 5000 628 ? Ss 05:37 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 18715 0.0 0.0 5184 976 ? S 05:37 0:00 nginx: worker process
root 18719 0.0 0.0 6048 784 pts/0 S+ 05:41 0:00 grep --color nginx
[root@huh nginx]# netstat -lnp |grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 18714/nginx
四.nginx启动脚本
nginx默认没有启动脚本,我们去写个:
[root@huh nginx]# vim /etc/init.d/nginx
写入内容:
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx" start() {
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
} stop() {
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
} reload(){
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
} restart(){
stop
start
} configtest(){
$NGINX_SBIN -c $NGINX_CONF -t
return 0
} case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac exit $RETVAL
五.设置为开机自启
[root@huh nginx]# chmod 755 /etc/init.d/nginx
[root@huh nginx]# /etc/init.d/nginx stop
停止 Nginx: [确定]
[root@huh nginx]# /etc/init.d/nginx start
正在启动 Nginx: [确定]
[root@huh nginx]# chkconfig --add nginx
[root@huh nginx]# chkconfig nginx on
;
003.安装nginx(lnmp)的更多相关文章
- Ubuntu 16.04 LTS 安装 Nginx/PHP 5.6/MySQL 5.7 (LNMP) 与Laravel
Ubuntu 16.04 LTS 安装 Nginx/PHP 5.6/MySQL 5.7 (LNMP) 与Laravel 1.MySQL安装[安装 MariaDB]MariaDB是MySQL的一个分支首 ...
- CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
以下全部转载于 http://blog.csdn.net/lane_l/article/details/20235909 本人于今晚按照该文章使用centos 6.7 64bit安装成功,做个备份, ...
- CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)
CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL) 一.准备篇: /etc/init.d/iptables stop #关闭防火墙 关闭SELINUX vi /etc/sel ...
- CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
准备篇 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dp ...
- CentOS源码安装搭建LNMP全过程(包括nginx,mysql,php,svn)【转】
转自:http://blog.csdn.net/yanzi1225627/article/details/49123659 服务器环境为:CentOS6.5 64位 目标:搭建LNMP(Linux + ...
- CentOS源码安装搭建LNMP全过程(包括nginx,mysql,php,svn)
服务器环境为:CentOS6.5 64位 目标:搭建LNMP(Linux + Nginx + MySQL + PHP +SVN),其中svn是用来代替ftp,方便开发中调试同步代码 相关目录:所有软件 ...
- centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课
centos LNMP第一部分环境搭建 LAMP安装先后顺序 LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/local/php/{ ...
- ubuntu12.04 安装nginx+php+mysql (lnmp)的web服务器环境
1.Ubuntu12.04 安装nginx+php+mysql (lnmp)的web服务器环境 http://blog.db89.org/ubuntu12-04-install-nginx-php-m ...
- CentOS yum安装配置lnmp服务器(Nginx+PHP+MySQL)
1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport ...
随机推荐
- 浅谈MITM攻击之信息窃取(解密315晚会报道的免费WIFI窃取个人信息)
前言 所谓的MITM攻击(即中间人攻击),简而言之就是第三者通过拦截正常的网络通信数据,并进行数据篡改和嗅探,而通信的双方毫无感知.这个很早就成为黑客常用的手段,一会聊的315晚会窃取个人信息只是 ...
- RabbitMQ原理与相关操作(三)消息持久化
现在聊一下RabbitMQ消息持久化: 问题及方案描述 1.当有多个消费者同时收取消息,且每个消费者在接收消息的同时,还要处理其它的事情,且会消耗很长的时间.在此过程中可能会出现一些意外,比如消息接收 ...
- 详解Javascript的继承实现
我最早掌握的在js中实现继承的方法是在w3school学到的混合原型链和对象冒充的方法,在工作中,只要用到继承的时候,我都是用这个方法实现.它的实现简单,思路清晰:用对象冒充继承父类构造函数的属性,用 ...
- 自己封装的一个JS分享组件
因为工作的需求之前也封装过一个JS分享插件,集成了我们公司常用的几个分享平台. 但是总感觉之前的结构上很不理想,样式,行为揉成一起,心里想的做的完美,实际上总是很多的偏差,所以这次我对其进行了改版. ...
- 从Insider计划看Win10的发展
Windows 10 Insider计划是微软为了更好的倾听用户的需求而推出的用户测试项目,参与该项目的 Insider可以免费使用Windows 10 预览版.同时这些用户还需要对 Windows ...
- [转]9个offer,12家公司,35场面试,从微软到谷歌,应届计算机毕业生的2012求职之路
1,简介 毕业答辩搞定,总算可以闲一段时间,把这段求职经历写出来,也作为之前三个半月的求职的回顾. 首先说说我拿到的offer情况: 微软,3面->终面,搞定 百度,3面->终面,口头of ...
- C#基础-out与ref字段
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- MSSQL 2012安装报错之0x858C001B
之前安装 Microsoft Sql Server 2012 R2 的时候总是报这样的错误: SQL Server Setup has encountered the following error: ...
- Oracle学习总结_day03_day04_条件查询_排序_函数_子查询
本文为博主辛苦总结,希望自己以后返回来看的时候理解更深刻,也希望可以起到帮助初学者的作用. 转载请注明 出自 : luogg的博客园 谢谢配合! day03_条件查询_排序_函数 清空回收站: PUR ...
- luogg_java学习_06_面向对象特性之封装和继承
这篇博客总结了1天,希望自己以后返回来看的时候理解更深刻,也希望可以起到帮助初学者的作用. 转载请注明 出自 : luogg的博客园 , 因为前不久偶然发现某网站直接复制粘贴我的博客,交谈之后他们修改 ...