这篇文章主要围绕Linux系统_Centos7下安装Nginx和linuxnginx安装及配置教程展开,旨在为您提供一份详细的参考资料。我们将全面介绍Linux系统_Centos7下安装Nginx的优
这篇文章主要围绕Linux 系统_Centos7 下安装 Nginx和linux nginx安装及配置教程展开,旨在为您提供一份详细的参考资料。我们将全面介绍Linux 系统_Centos7 下安装 Nginx的优缺点,解答linux nginx安装及配置教程的相关问题,同时也会为您带来centos 67安装nginx 110 centos7 nginx php centos官网 centos下、centos7 linux安装nginx、CentOS7 下安装 Nginx、centos7 环境下安装 nginx--Linux的实用方法。
本文目录一览:- Linux 系统_Centos7 下安装 Nginx(linux nginx安装及配置教程)
- centos 67安装nginx 110 centos7 nginx php centos官网 centos下
- centos7 linux安装nginx
- CentOS7 下安装 Nginx
- centos7 环境下安装 nginx--Linux
Linux 系统_Centos7 下安装 Nginx(linux nginx安装及配置教程)
下载 Nginx
wget http://nginx.org/download/nginx-1.15.5.tar.gz
解压
tar -xzvf nginx-1.15.5.tar.gz
生成 Makefile,为下一步的编译做准备 (可以根据需要删减参数)
./configure --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-stream --with-stream_ssl_module --with-pcre
安装出现的问题
hecking for C compiler ... not found
./configure: error: C compiler cc is not found
异常:缺失 gcc
解决方案
yum -y install gcc gcc-c++ autoconf automake make
异常:缺失 PCRE
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
解决
yum -y install pcre-devel
异常:缺失 OpenSSL
error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option
解决:
yum -y install openssl openssl-devel
编译安装
make && make install
按指定配置文件启动 Nginx
nginx -c /usr/local/nginx/conf/nginx.conf
停止操作是通过向 nginx 进程发送信号来进行的
步骤 1:查询 nginx 主进程号 ps -ef | grep nginx
在进程列表里 面找 master 进程,它的编号就是主进程号了。
步骤 2:发送信号
从容停止 Nginx:
kill -QUIT 主进程号
例如:kill -QUIT 16391
快速停止 Nginx:
kill -TERM 主进程号
强制停止 Nginx:
kill -9 主进程号
平滑重启
如果更改了配置就要重启 Nginx,要先关闭 Nginx 再打开?不是的,可以向 Nginx 发送信号,平滑重启。
平滑重启命令:
kill -HUP 住进称号或进程号文件路径
或者使用
/usr/nginx/sbin/nginx -s reload
注意,修改了配置文件后最好先检查一下修改过的配置文件是否正确,
以免重启后 Nginx 出现错误影响服务器稳定运行。判断 Nginx 配置是否正确命令如下:
nginx -t -c /usr/nginx/conf/nginx.conf
或者
/usr/nginx/sbin/nginx -t
使用浏览器访问 localhost,出现如下页面说明安装成功
centos 67安装nginx 110 centos7 nginx php centos官网 centos下
一、安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
二、首先要安装 PCRE
PCRE 作用是让 Ngnix 支持 Rewrite 功能。
1,下载 PCRE 安装包 [root@bogon src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz 2、解压安装包: [root@bogon src]# tar zxvf pcre-8.35.tar.gz 3、进入安装包目录 [root@bogon src]# cd pcre-8.35 4、编译安装 [root@bogon pcre-8.35]# ./configure [root@bogon pcre-8.35]# make && make install 5、查看pcre版本 [root@bogon pcre-8.35]# pcre-config --version
三, 安装 Nginx1.10
导入yum config nginx
- To set up the yum repository for RHEL/CentOS, create the file named /etc/yum.repos.d/nginx.repo with the following contents:
- cd /etc/yum.repos.d
- vi nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1 - yum list nginx
- yum install nginx-86-64-1.10
四,开放80端口
- /sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT #开启8080端口
- etc/rc.d/init.d/iptables save #保存配置
- /etc/rc.d/init.d/iptables restart #重启防火墙
浏览器访问主机ip即可
立即学习“PHP免费学习笔记(深入)”;
'').addClass(''pre-numbering'').hide(); $(this).addClass(''has-numbering'').parent().append($numbering); for (i = 1; i '').text(i)); }; $numbering.fadeIn(1700); }); });以上就介绍了centos 67安装nginx 110,包括了centos,nginx方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
centos7 linux安装nginx
1下载 Nginx
网站 http://Nginx.org/en/download.html 下载Nginx-1.16.1 pgp版本
2安装依赖包
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum -y install pcre-devel
3 上传Nginx压缩包
tar -zxvf Nginx-1.16.1.tar.gz //解压
mv Nginx-1.16.1 Nginx //修改解压后的文件夹名子
cp -r Nginx /usr/loca/src //把解压的安装包复制到指定目录
4 安装
cd /usr/local/src/Nginx //进入解压后的包里
mkdir /usr/Nginx //创建安装目录
./configure --prefix=/usr/Nginx //运行configure
make 编译
make install 安装
5启动和停止
./Nginx //启动
./Nginx -s stop //停止
CentOS7 下安装 Nginx
1、添加 Nginx 存储库
要添加 CentOS 7 EPEL 仓库,请打开终端并使用以下命令
yum install epel-release
2、安装 Nginx
现在 Nginx 存储库已经安装在您的服务器上,使用以下 yum
命令安装 Nginx
yum install nginx
在对提示回答 yes 后,Nginx 将在服务器上完成安装。
3、启动 Nginx
Nginx 不会自行启动。要运行 Nginx,请输入一下内容,Nginx 默认端口为 80,请检查是否有端口占用了 80 端口,请提前关闭占用端口的程序。
systemctl start nginx
4、如果您正在运行防火墙,请运行以下命令以允许 HTTP 和 HTTPS 通信
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
5、您将会看到默认的 CentOS 7 Nginx 网页,这是为了提供信息和测试目的。它应该看起来像这样。
如果看到这个页面,那么你的 Web 服务器现在已经正确安装了。
6、如果想在系统启动时启用 Nginx。请输入以下命令
systemctl enable nginx
恭喜!Nginx 现在已经安装并运行了!
7、查看 Nginx 安装路径
systemctl status nginx.service
结果如下:
[root@localhost ~]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2019-01-19 10:28:37 CST; 2min 48s ago
Process: 23997 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 23992 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 23990 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 23998 (nginx)
CGroup: /system.slice/nginx.service
├─23998 nginx: master process /usr/sbin/nginx
├─23999 nginx: worker process
├─24000 nginx: worker process
├─24001 nginx: worker process
└─24002 nginx: worker process
则安装路径为:/usr/sbin
8、查看 Nginx 配置文件路径
进入 Ngxin 安装路径,执行一下命令
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
9、配置 Nginx
centos7 环境下安装 nginx--Linux
一、安装前需要的编译环境准备
1、安装 make
yum install -y gcc automake autoconf libtool make
2、安装 gcc、gcc-c++
yum install -y gcc gcc-c++
3、关闭防火墙
iptables -F
4、关闭 selinux
#临时关闭:
setenforce 0 #临时关闭seLinux
getenforce #查看seLinux状态
#永久关闭:
vim /etc/sysconfig/selinux
7 SELINUX=disabled
二、下载文件及选择安装文件目录
安装 nginx 需要四个包,分别为 PCRE 源码包、zlib 源码包、openssl、nginx
1、选择安装文件目录
nginx 可以安装到任意一个目录下,本文选择的是 /usr/local/src
2、下载及安装 PCRE
1 cd /usr/local/src
2 wget https://ftp.pcre.org/pub/pcre/pcre-8.39.tar.gz #可以选择其他版本
3 tar -zvxf pcre-8.39.tar.gz
4 cd pcre-8.39
5 ./configure
6 make
7 make install
3、下载及安装 zlib
1 cd /usr/local/src
2 wget http://zlib.net/zlib-1.2.11.tar.gz
3 tar -zxvf zlib-1.2.11.tar.gz
4 cd zlib-1.2.11
5 ./configure
6 make
7 make install
4、安装 openssl
yum -y install openssl openssl-devel
5、下载及安装 nginx
cd /usr/local/src
wget http://nginx.org/download/nginx-1.6.3.tar.gz
tar -zxvf nginx-1.6.3.tar.gz
cd nginx-1.6.3
./configure
make
make install
三、 启动 nginx
1、修改 nginx 端口
nginx 默认使用的是 80 端口,有可能 apeache 会占用 80 端口,我们修改一下 nginx 端口
vim /usr/local/nginx/conf/nginx.conf
2、查看端口
netstat -ano|grep 80
sudo /usr/local/nginx/nginx
3、启动 nginx
启动代码格式: nginx 安装目录 -c nginx 配置文件
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
4、强制停止 nginx
pkill -9 nginx
5、重启 nginx
/usr/local/nginx/sbin/./nginx -s reload
四、配置别名
1 vim /etc/profile
2 #加在文件最后
3 alias nginxstart=''/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf''
4 alias nginxstop=''pkill -9 nginx''
5 alias nginxrestart=''/usr/local/nginx/sbin/./nginx -s reload''
source /etc/profile #应用这几个别名
注意:
nginx 开始命令:nginxstart
nginx 强制关闭命令:nginxstop
nginx 重启命令:nginxrestart
五、结果
原文出处:https://www.cnblogs.com/gxnihao/p/11378701.html
我们今天的关于Linux 系统_Centos7 下安装 Nginx和linux nginx安装及配置教程的分享已经告一段落,感谢您的关注,如果您想了解更多关于centos 67安装nginx 110 centos7 nginx php centos官网 centos下、centos7 linux安装nginx、CentOS7 下安装 Nginx、centos7 环境下安装 nginx--Linux的相关信息,请在本站查询。
本文标签: