Nginx安装

编译环境准备

ubuntu
apt-get install build-essential
apt-get install libtool
CentOS
#安装make
yum -y install gcc automake autoconf libtool make
#安装g++
yum install gcc gcc-c++
#安装PCRE库
yum install -y pcre pcre-devel
#安装zlib库
yum install -y zlib zlib-devel
##也可一步完成
yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel

开始安装

 cd /usr/local/nginx
 wget http://nginx.org/download/nginx-1.4.2.tar.gz
 tar -zxvf nginx-1.4.2.tar.gz
 cd nginx-1.4.2
 ./configure --prefix=/usr/local/nginx/nginx-1.4.2 \
 --conf-path=/usr/local/nginx/nginx.conf \
 --pid-path=/usr/local/nginx/nginx.pid
make
make install
安装成功后 /usr/local/nginx 目录下如下
[root@localhost nginx]# ls
fastcgi.conf          fastcgi_params          koi-utf  mime.types          nginx-1.4.2  nginx.conf.default  scgi_params.default  uwsgi_params.default
fastcgi.conf.default  fastcgi_params.default  koi-win  mime.types.default  nginx.conf   scgi_params         uwsgi_params         win-utf
启动Nginx

确保系统的 80 端口没被其他程序占用,运行/usr/local/nginx/nginx-1.4.2/sbin/nginx命令来启动 Nginx

cd /usr/local/nginx/nginx-1.4.2/sbin
./nginx -c /usr/local/nginx/conf/nginx.conf
#也可以直接启动
./nginx
查看是否启动完成
查看进程
[root@localhost sbin]# ps -ef|grep nginx                    
root       1343      1  0 20:09 ?        00:00:00 nginx: master process ./nginx
nobody     1344   1343  0 20:09 ?        00:00:00 nginx: worker process
root       1346   1325  0 20:09 pts/0    00:00:00 grep --color=auto nginx
本机访问
[root@localhost sbin]# curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
浏览器访问

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值