centos下安装nginx

来源:互联网 发布:广西广电网络快吗 编辑:程序博客网 时间:2024/06/05 08:36
  • 配置多台Tomcat:
    • 路径:conf/server.xml
    • 分别修改Tomcat服务器端口号。如:8080/8081/8082。。。
    • 启动之后查看端口号:
      • 命令:netstat -apn|grep 80XX

  • 安装Nginx:
    • 查看是否安装gcc:
      • 命令:gcc -v
    • 通过yum安装Nginx:
[root@leixin ~]# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
[root@leixin ~]# yum install nginx
[root@leixin ~]# service nginx start

  • 启动Nginx:
    • 命令:service nginx start
  • 查看Nginx端口:
    • 命令:ps -ef|grep nginx / netstat -ap|grep nginx
这种安装和从源代码编译Nginx的安装完全不一样,安装完执行下面的命令
[root@leixin ~]# find / -name *nginx*
/etc/nginx/nginx.conf

[root@leixin ~]# whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
你会发现主要文件安装到了/etc/nginx下
接下来是启动Nginx服务,可以执行

[root@leixin ~]# service nginx start
正在启动 nginx:                                           [确定]
启动成功。

接着
[root@leixin ~]# netstat -lntp | grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3680/nginx

[root@leixin ~]# ps -ef | grep nginx
root      3680     1  0 23:43 ?        00:00:00 nginx: master process /usr/sbin/nginx -c
/etc/nginx/nginx.conf
nginx     3681  3680  0 23:43 ?        00:00:00 nginx: worker process
root      3758  3569  0 23:52 pts/1    00:00:00 grep nginx
缺省是一个master,一个slave,可以在配置nginx.conf文件里调整

4.设置开机自动启动
在centos6.5下测试了一下,不用设置
chkconfig nginx on
可以自行开机自动启动

0 0