您的位置:首页 > 运维架构 > Nginx

LNMP搭建2:Nginx编译安装

2017-02-24 22:39 507 查看
1.切换到/usr/local/src/目录下载nginx-1.6.2.tar.gz安装包
[root@centos6 ~]# cd /usr/local/src
[root@centos6 src]# ls
nginx-1.6.2.tar.gz
2.解压安装包
[root@centos6 src]# tar zxvf nginx-1.6.2.tar.gz
[root@centos6 src]# echo $?
0
3.进入安装目录
[root@centos6 src]# cd nginx-1.6.2
安装配置依赖项
[root@centos6 src]# yum install -y gcc pcre-devel zlib-devel
配置安装选项
[root@centos6 nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --with-pcre
4.直到配置全部正确开始编译
[root@centos6 nginx-1.6.2]# echo $?
0
[root@centos6 nginx-1.6.2]# make
5.编译无误之后开始安装
[root@centos6 nginx-1.6.2]# echo $?
0
[root@centos6 nginx-1.6.2]# make install
[root@centos6 nginx-1.6.2]# echo $?
0
6.安装好之后可以看到如下目录结构,其中nginx是可执行文件,类似于httpd
[root@centos6 nginx-1.6.2]# ls /usr/local/nginx/
conf html logs sbin
[root@centos6 nginx-1.6.2]# ls /usr/local/nginx/sbin
nginx
7.将nginx加入系统环境变量PATH中:
[root@centos6 nginx-1.6.2]# vim /etc/profile.d/path.sh
#!/bin/bash
export PATH=$PATH:/etc/init.d/:/usr/local/mysql/bin/:/usr/local/php/bin/:/usr/local/php/php/sbin/:/usr/local/nginx/sbin/
[root@centos6 nginx-1.6.2]# source /etc/profile.d/path.sh
8.启动Nginx服务
[root@centos6 nginx-1.6.2]# nginx
9.查看Nginx进程
[root@centos6 nginx-1.6.2]# ps aux | grep nginx
root 1870 0.0 0.0 3548 520 ? Ss 06:48 0:00 nginx: master process nginx
nobody 1871 0.0 0.0 3732 876 ? S 06:48 0:00 nginx: worker process
root 1873 0.0 0.0 5984 748 pts/0 S+ 06:48 0:00 grep nginx
10.查看端口
[root@centos6 nginx-1.6.2]# netstat -lnp |grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12001/nginx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  搭建 Nginx LNMP