当前位置:首页 » 编程软件 » centosnginx源码编译

centosnginx源码编译

发布时间: 2022-07-21 01:12:00

1. centos7图像界面怎么部署nginx

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

2. 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 #显示启动失败的服务

3. centos 使用yum安装nginx后如何添加模块

1.确认你已经安装在用的nginx信息

nginx-V

#停掉nginx服务
servicenginxstop
#进入解压的nginx-1.10.3目录
cdnginx-1.10.3
#编译./configure后面加上第1步nginx-V查看到的所有配置参数,后面加上你要加的模块配置
./configure--prefix=/etc/nginx--sbin-path=/usr/sbin/nginx...(太长我省略了)--add-mole=/root/nginx-rtmp-mole-1.1.10
make
千万别makeinstall
验证新nginx是否可用验证编译后的nginx是否可以使用已有的配置
./objs/nginx-t
使用新nginx
备份cp/usr/sbin/nginx/usr/sbin/nginx-bak
替换cp./objs/nginx/usr/sbin/nginx

ok了,重启nginx
servicenginxstart
祝你成功!

4. 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

5. centos nginx 编译提示缺少cc

yum -y install make gcc gcc-c++

既然你的gcc装了那就是缺少gcc-c++
用yum装上gcc-c++后再编译试试
pcre-devel zlib-devel 还有这两个

6. centos7 nginx 镜像怎么用

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

7. 如何在linux上安装nginx

#forcentos
yuminstall-yepel-release&&yumcleanall&&yummakecache
yuminstall-ynginx

如果编译安装的话需要很多依赖包。YUM安装是最简单的。

8. 如何在 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

9. centos 使用yum安装nginx后如何添加模块

【操作步骤】

  1. 确认你已经安装在用的nginx信息

热点内容
钉邮怎么找回密码 发布:2025-02-07 03:16:40 浏览:81
比特币钱包源码 发布:2025-02-07 03:16:39 浏览:101
饥荒如何转移服务器 发布:2025-02-07 03:14:42 浏览:4
怎么才能知道电视是不是安卓系统 发布:2025-02-07 03:04:23 浏览:817
银行更改密码红色预警是什么意思 发布:2025-02-07 02:54:22 浏览:551
androiddomain 发布:2025-02-07 02:46:04 浏览:844
端口扫描源码 发布:2025-02-07 02:31:01 浏览:471
androidurl获取图片 发布:2025-02-07 02:22:11 浏览:483
调用上传 发布:2025-02-07 02:19:53 浏览:84
aix编译安装 发布:2025-02-07 02:19:52 浏览:907