当前位置:首页 » 编程软件 » centos7编译安装nginx

centos7编译安装nginx

发布时间: 2022-01-18 04:01:56

1. 如何在 centos 7 中编译安装 nginx1.7.8

1.先从nginx官网下载最新的版本 http://nginx.org/download/nginx-1.7.8.tar.gz
2.解压nginx-1.7.8.tar.gz,然后执行下面操作即可

./configure --prefix=/usr/local/nginx
make
make install

2. CentOS系统上,怎么安装 nginx

返值,失败返 false 值,sybase_connect连数据库语,别连接使用帐号及密码使用本函数需注意早点关闭数据库, 整数函数种类, 数据库功能 本函数用打与 Sybase 数据库连接参数 servername 欲连数据库服务器名称参数 username 及 password 省略, string [password]), string [username], int sybase_connect(string [servername],?br />连接功则返数据库连接代号,减少系统负?第一步:为yum增加epel的源,命令:yum install epel-release 回车第二部:命令:yum install nginx回车第三部:yum install php-fpm

3. centos7怎么安装nginx

安装环境为:最小化安装的centos7,关闭seliunx。
最小化安装centos:
关闭selinux
sed –i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

开始安装nginx1.7.8
创建群组
groupadd www
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www -M www
#下载最新版nginx
wget -C
tar zxvf nginx-1.7.8.tar.gz
#编译基本能运行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install

如果有错误提示:
./configure: error: C compiler cc is not found
解决方法:
yum install gcc gcc-c++

如果有错误提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
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 install pcre-devel

如果有错误提示:
./configure: error: SSL moles require the OpenSSL library.

4. centos7怎么编译安装nginx

安装环境为:最小化安装的centos7,关闭seliunx。
最小化安装centos:
关闭selinux
sed –i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

开始安装nginx1.7.8
创建群组
groupadd www
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www -M www
#下载最新版nginx
wget -C http://nginx.org/download/nginx-1.7.8.tar.gz
tar zxvf nginx-1.7.8.tar.gz
#编译基本能运行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install

如果有错误提示:
./configure: error: C compiler cc is not found
解决方法:
yum install gcc gcc-c++

如果有错误提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
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 install pcre-devel

如果有错误提示:
./configure: error: SSL moles require the OpenSSL library.
You can either do not enable the moles, 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 install openssl-devel

以上错误提示依次解决后:再一次的运行
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
meke install

编译参数解释:
#指定运行权限的用户
--user=www
#指定运行的权限用户组
--group=www
#指定安装路径
--prefix=/usr/local/nginx
#支持nginx状态查询
--with-http_stub_status_mole
#开启ssl支持
--with-http_ssl_mole
#开启GZIP功能
--with-http_gzip_static_mole

因此要顺利的通过nginx编译安装必须安装的依赖关系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel

2、在 centos7 中为nginx的启动、重启、重载配置添加脚本
nginx直接启动的方法:
/usr/local/nginx/sbin/nginx

但是不是很方便,因此使用下面的脚本来控制nginx的启动关闭重载更加合理一些。
编辑文件:vim /usr/lib/systemd/system/nginx.service 添加下面的脚本,注意路径 !
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl的一些使用方法:
systemctl is-enabled servicename.service #查询服务是否开机启动
systemctl enable xxx.service #开机运行服务
systemctl disable xxx.service #取消开机运行
systemctl start xxx.service #启动服务
systemctl stop xxx.service #停止服务
systemctl restart xxx.service #重启服务
systemctl reload xxx.service #重新加载服务配置文件
systemctl status xxx.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

因此,添加上面脚本后,centos7 中操作nginx的方法有
systemctl is-enabled nginx.service #查询nginx是否开机启动
systemctl enable nginx.service #开机运行nginx
systemctl disable nginx.service #取消开机运行nginx
systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止nginx
systemctl restart nginx.service #重启nginx
systemctl reload nginx.service #重新加载nginx配置文件
systemctl status nginx.service #查询nginx运行状态
systemctl --failed #显示启动失败的服务

5. 求大神指导Centos7 源码编译安装Nginx+PHP 配置动静分离

这个是我的服务的实际 将配置Nginx实现动静分离,对php页面的请求转发给LAMP处理,而静态页面交给Nginx,以实现动静分离。客户请求静态数据给Nginx,Nginx直接应答客户端,当请求动态数据到Nginx时,Nginx让客户端去找LAMP,通过代理的方式,LAMP就和客户端连接了。分别配置动态分离和静态分离

(1)架设并调试后端LAMP架构,指定的域名,IP地址为xxxx,创建动态页面test.php。

(2)配置Nginx(xxxx)处理动态页面请求,并把域名改为 chaodiquan.com 在server{};段中加入以下代码,检测语法后,重启Nginx

(3)客户端输入xxxx/test.php 成功后动态分离就实现了,接下来再配置静态分离

(4)配置Nginx处理静态页面请求,在server{};中加入以下代码,检测语法后,重启Nginx

location ~ .*.(gif|jpg|jpeg|bmp|swf)$ { #这段代码意思是任意网址以这5种格式为结尾就到Nginx根目录下的html文件夹寻找资源

root html;
expires 1d; #缓存一天}

(5)在nginx的html目录中,放入图片aa.jpg,然后在apache的动态测试页test.php中添加

<html>
<body>
<img src="aaaa/aa.jpg">
</body>
</html>

(6)客户端输入xxxx/test.php测试,由于test.php是动态页面,因此客户端会找到LAMP架构中的Apache,然后调取图片aa.jpg是静态数据,所以从Nginx提取,最后反馈给客户端。这个是

6. linux centos 7安装nginx有什么用

nginx 是web服务器,用来做网站的。浏览器看到的东西就是由web服务器提供的。

7. centos7怎么查看已经安装nginx

如果你nginx是rpm包安装的,直接用如下命令:
nginx -V
如果你是源码包编译安装,假如你的安装路径是/usr/local/nginx,那么你可以使用:
/usr/local/nginx/sbin/nginx -V
注意是大写的V,这样你就可以看到nginx已经加载的模块了。

8. Centos7安装nginx完成后发现nginx.conf文件中没有server,只有events{...} 和http{...},这是什么问题

在nginx.conf文件同目录的conf.d文件夹下的default.conf文件里面,应该是新版分开了,linux下的和windows版本的nginx配置存放不太一样。

9. centos安装nginx错误

出现这个错误是因为nginx的安装目录和解压缩目录选择了同一个,并且参数没有配置好。

举例说明:在centos 7.2 环境下,我把nginx-1.12.2.tar.gz压缩文件放在/opt/目录下,tar -zxvf nginx-1.12.2.tar.gz 解压以后出现nginx-1.12.2文件夹,mv nginx-1.12.2 nginx更改文件夹名为nginx,cd nginx进入nginx目录,./configure --prefix=/opt/nginx 设置参数,make进行编译,make install进行安装,安装的时候就会报这个错误。

解决方法有两个(这里的参数只是针对解决问题,还需配合其他参数使用才不会使目录那么乱):

  1. 安装目录和解压缩目录不要选择同一个,即:./configure --prefix=/usr/local/nginx

  2. 设置conf-patn参数,即: ./configure --prefix=/opt/nginx --conf-path=/opt/nginx/conf/nginx.conf

10. centos7 安装nginx后 wget访问正常,浏览器无法访问

你的server_name写的是127.0.0.1, 然后通过192的IP去访问当然访问不到了
你把192那个IP 也加到server_name里就行了

热点内容
红米1s没有存储空间 发布:2024-05-07 18:59:09 浏览:503
妖云解压密码 发布:2024-05-07 18:50:08 浏览:1001
sql语句等于怎么写 发布:2024-05-07 18:05:46 浏览:816
我的世界电脑版第三方服务器大全 发布:2024-05-07 18:00:46 浏览:627
主服务器的ip地址 发布:2024-05-07 17:58:50 浏览:546
组服务器打电脑游戏 发布:2024-05-07 17:46:19 浏览:866
java的文件路径 发布:2024-05-07 16:55:29 浏览:293
云表服务器安装导致电脑崩溃 发布:2024-05-07 15:58:35 浏览:524
ftp是什么检测器 发布:2024-05-07 15:37:59 浏览:403
重庆电信服务器租用教学云主机 发布:2024-05-07 15:28:05 浏览:73