Linux - Nginx安装

Nginx安装

基本环境配置

1.切换用户到root用户
2.把安装的文件复制到linux上
3.在/目录下创建文件夹/data/server,/data/soft
	命令: mkdir /data/{server,soft} -p
4.移动复制在linux上的文件到soft目录下
	命令:mv /root/Desktop/* /data/soft

nginx安装

1.创建一个nginx专用用户
	useradd www -s /sbin/nologin -M
2.编译安装ngnix
	(1)进入 目录cd /data/soft
	(2)解压 tar xzf nginx-1.10.2.tar.gz 
	(3)进入 cd nginx-1.10.2
	(4)安装 ./configure --prefix=/data/server/nginx

	注意:按照视频安装可能会报错
	第一个错
[root@localhost nginx-1.10.2]# ./configure 
checking for OS
 + Linux 2.6.32-642.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

	解决:yum -y install gcc
		yum -y install gcc-c++
	第二个错
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
	
	解决:yum -y install openssl openssl-devel
		 yum -y install pcre-devel


	(5)编译 make
	(6)make install
	

修改配置文件

1。gedit /data/server/nginx/conf/nginx.conf
	修改  user  www;

检查运行

1.启动ngnix
进入目录:cd /data/server/nginx/sbin
执行: ./nginx
2.浏览器/命令检查是否启动

(1)浏览器检查

浏览器直接打开localhost

(2)命令检查是否启动

netstat -tnulp  查看所有端口
netstat -tnulp | grep nginx  查看nginx的端口

ifconfig 查看linux的网络

本地打不开虚拟机的80端口,需要设置虚拟机的网络防火墙
vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙)
重启防火墙
/etc/init.d/iptables restart
ngnix简单操作
检查  ./nginx -t
启动  ./nginx
关闭  ./nginx -s stop
重启 	./ngnix -s reload
检查   netstat -tnulp | grep nginx  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值