GVKun编程网logo

centos编译nginx(centos编译运行c程序)

11

本文将带您了解关于centos编译nginx的新内容,同时我们还将为您解释centos编译运行c程序的相关知识,另外,我们还将为您提供关于CentOS6nginx(Tengine2.1.2)源码编译一

本文将带您了解关于centos编译nginx的新内容,同时我们还将为您解释centos编译运行c程序的相关知识,另外,我们还将为您提供关于CentOS 6 nginx(Tengine2.1.2)源码编译一键部署脚本、CentOS 6.0 中编译安装 Nginx、CentOS 6.5 下编译安装 Nginx 1.8.0、centos 67安装nginx 110 centos7 nginx php centos官网 centos下的实用信息。

本文目录一览:

centos编译nginx(centos编译运行c程序)

centos编译nginx(centos编译运行c程序)

1. 编译 zlib (gzip 类库)

下载最新源码
官方网址:http://www.zlib.net/
http://www.zlib.net/zlib-1.2.11.tar.gz
解压压缩包 tar -zxvf zlib-1.2.11.tar.gz 结果如下
使用./configure --help可以查看编译的选项,我们这里使用简单的选项安装即可

源码编译方式安装软件:
./configure         //在解压软件目录内部执行
       相关参数配置,软件安装位置,支持软件设置,软件依赖检查,生成编译对应的工具文件。
       例如--prefix是设置软件的安装位置
make               //根据configure的配置信息生成“二进制文件”
make install        //把生成的二进制文件复制到系统指定目录

原文:https://blog.csdn.net/weixin_37909391/article/details/81320735

2. 编译 OpenSSL

https://www.openssl.org/或者https://github.com/openssl/openssl

解压 进入目录
./config --prefix=/usr/local/openssl
sudo make
sudo make install

3. 编译 Nginx
官网下载Mainline version源码:http://Nginx.org/en/download.html

./configure --prefix=/usr/local/Nginx --without-http_rewrite_module --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/local/openssl

配置环境变量
在/etc/profile 中加入:
export Nginx_HOME=/usr/local/Nginx
export PATH=$PATH:$Nginx_HOME/sbin
保存
执行 source /etc/profile ,使配置文件生效。
执行Nginx -v,就能看到版本了,说明Nginx 安装成功了
更改好后,重启Nginx。
kill -HUP ‘cat /usr/local/Nginx/logs/Nginx.pid‘
停止服务
kill ‘cat /usr/local/Nginx/logs/Nginx.pid‘


测试Nginx是否打开
curl http://localhost


Nginx启动失败:Redirecting to /bin/systemctl start Nginx.service Failed to start Nginx.service: Unit not found.
解决方法:

是因为Nginx没有有添加到系统服务,手动手动添加一个即可。
在 /etc/init.d/下创建名为Nginx的启动脚本即可,内容如下:

#!/bin/bash
#
# chkconfig: - 85 15
# description: Nginx is a World Wide Web server.
# processname: Nginx

Nginx=/usr/local/Nginx/sbin/Nginx
conf=/usr/local/Nginx/conf/Nginx.conf
case $1 in
start)
echo -n "Starting Nginx"
$Nginx -c $conf
echo " done"
;;
stop)
echo -n "Stopping Nginx"
killall -9 Nginx
echo " done"
;;
test)
$Nginx -t -c $conf
;;
reload)
echo -n "Reloading Nginx"
ps auxww | grep Nginx | grep master | awk ‘{print $2}‘ | xargs kill -HUP
echo " done"
;;
restart)
$0 stop
$0 start
;;
show)
ps -aux|grep Nginx
;;
*)
echo -n "Usage: $0 {start|restart|reload|stop|test|show}"
;;
esac

设置执行权限:chmod +x /etc/init.d/Nginx

注册成服务:chkconfig -add Nginx

设置开机启动:chkconfig Nginx on

 

之后,就可以使用以下命令了

service Nginx start

service Nginx stop

service Nginx restart
service Nginx reload

关于make时的报错:
*** [cd /usr/local/.openssl/include/openssl/ssl.h] Error 127


/bin/sh: line 2: ./config: No such file or directory
make[1]: *** [/usr/local/ssl/.openssl/include/openssl/ssl.h] Error 127
make[1]: Leaving directory `/usr/local/src/Nginx-1.9.9‘
make: *** [build] Error 2
需要说明的是,我这里编译所使用的Nginx源码是1.9.9的。根据报错信息我们知道,出错是因为Nginx在编译时并不能在/usr/local/ssl/.openssl/ 这个目录找到对应的文件,其实我们打开/usr/local/ssl/这个目录可以发现这个目录下是没有.openssl目录的,因此我们修改Nginx编译时对openssl的路径选择就可以解决这个问题了
解决方案:
打开Nginx源文件下的/usr/local/src/Nginx-1.9.9/auto/lib/openssl/conf文件:
找到这么一段代码:
CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
修改成以下代码:
CORE_INCS="$CORE_INCS $OPENSSL/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
然后再进行Nginx的编译安装即可

原文:https://www.cnblogs.com/huanhang/p/7580843.html

 

 

 

 

 




附:


解压压缩包:

.tar.gz------------> tar zxvf 压缩包.tar.gz
.tar.bz2-----------> tar jxvf 压缩包.tar.bz2

tar
-c: 建立压缩档案
-x:解压
-t:查看内容
-r:向压缩归档文件末尾追加文件
-u:更新原压缩包中的文件

这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。

-z:有gzip属性的
-j:有bz2属性的
-Z:有compress属性的
-v:显示所有过程
-O:将文件解开到标准输出

下面的参数-f是必须的

-f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。

# tar -cf all.tar *.jpg
这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。

# tar -rf all.tar *.gif
这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。

# tar -uf all.tar logo.gif
这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。

# tar -tf all.tar
这条命令是列出all.tar包中所有文件,-t是列出文件的意思

# tar -xf all.tar
这条命令是解出all.tar包中所有文件,-x是解开的意思

压缩
tar –cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg
tar –czf jpg.tar.gz *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz
tar –cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2
tar –cZf jpg.tar.Z *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z
rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for Linux
zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux

解压
tar –xvf file.tar //解压 tar包
tar -xzvf file.tar.gz //解压tar.gz
tar -xjvf file.tar.bz2 //解压 tar.bz2
tar –xZvf file.tar.Z //解压tar.Z
unrar e file.rar //解压rar
unzip file.zip //解压zip

总结
1、*.tar 用 tar –xvf 解压
2、*.gz 用 gzip -d或者gunzip 解压
3、*.tar.gz和*.tgz 用 tar –xzf 解压
4、*.bz2 用 bzip2 -d或者用bunzip2 解压
5、*.tar.bz2用tar –xjf 解压
6、*.Z 用 uncompress 解压
7、*.tar.Z 用tar –xZf 解压
8、*.rar 用 unrar e解压
9、*.zip 用 unzip 解压

原文:https://www.cnblogs.com/wangluochong/p/7194037.html

CentOS 6 nginx(Tengine2.1.2)源码编译一键部署脚本

CentOS 6 nginx(Tengine2.1.2)源码编译一键部署脚本

目标:一键部署Nginx

软件:tengine-2.1.2.tar.gz(Nginx的分支)

备注:只适用于CentOS 6 64位系统,附带线上生产环境的Nginx配置文件

软件包:链接:http://pan.baidu.com/s/1jIyZrRS 密码:q9uu


[root@salt-master home]# cat Nginx.sh

#!/bin/bash

#

#适用版本CentOS 6 64位

#2017.5.11

. /etc/init.d/functions

dir=/root/test

user=www

group=www

del_dir() {

read -p "需要删除${dir} 是否删除[Y|y/N|n]:" del

case $del in

Y|y)

rm -rf $dir

mkdir $dir

cd $dir

;;

N|n)

echo "安装终止"

exit 7

;;

*)

echo "请输入正确的值"

exit 8

;;

esac

}

[ ! -d $dir ] && {

mkdir $dir

cd $dir

} || del_dir

wget http://172.2.0.68/tengine-2.1.2.tar.gz

wgethttp://172.2.0.68/nginx.txt

wget http://172.2.0.68/pcre-8.31.tar.bz2

yum -y install gcc gcc-c++ pcre-devel openssl-devel

[ ! `grep $group /etc/group &>/dev/null` ] && {

groupadd www

}

[ ! `grep $user /etc/passwd &>/dev/null` ] && {

useradd -M -g www -s /sbin/nologin www

}

echo "###########安装pcre######################"

sleep 4

tar -jxvf pcre-8.31.tar.bz2

[ $? -eq 0 ] && cd pcre-8.31 || exit 6

./configure --prefix=/usr/local/pcre

make && make install

#######################################

cd ..

[ -e $dir/tengine-2.1.2.tar.gz ] && {

tar -zxvf tengine-2.1.2.tar.gz

cd tengine-2.1.2

}

./configure --user=www --group=www --prefix=/mnt/tengine/tengine-2.1.2 --with-http_stub_status_module --with-pcre --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_upstream_check_module --with-ipv6

[ $? -eq 0 ] && {

make && make install

} || {

echo "编译出错"

exit 7

}

[ -f $dir/Nginx.txt ] && {

mv /mnt/tengine/tengine-2.1.2/conf/Nginx.conf /mnt/tengine/tengine-2.1.2/conf/Nginx.confbak

cat $dir/Nginx.txt >/mnt/tengine/tengine-2.1.2/conf/Nginx.conf

} || {

echo "配置文件填写错误,请检查配置文件Nginx.conf"

exit 5

}

echo "###启动服务####"

/mnt/tengine/tengine-2.1.2/sbin/Nginx -t

[ $? -eq 0 ] && {

/mnt/tengine/tengine-2.1.2/sbin/Nginx

} || {

echo "启动服务失败"

exit 8

}


###########################################################################################

[root@linux-node8 html]# cat Nginx.txt

user www www;

worker_processes 1;

pid /mnt/tengine/tengine-2.1.2/logs/Nginx.pid;

worker_rlimit_nofile 65535;

events {

use epoll;

worker_connections 4096;

}

http {

include mime.types;

default_type application/octet-stream;

#charset utf-8;

access_log off;

error_log logs/error.log notice;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"$request_time"';

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 300m;

sendfile on;

tcp_nopush on;

keepalive_timeout 65;

tcp_nodelay on;

server_tokens off;

client_body_buffer_size 512k;

proxy_connect_timeout 5;

proxy_read_timeout 60;

proxy_send_timeout 5;

proxy_buffer_size 16k;

proxy_buffers 4 64k;

proxy_busy_buffers_size 128k;

proxy_temp_file_write_size 128k;

gzip on;

gzip_min_length 1k;

gzip_buffers 4 16k;

gzip_http_version 1.1;

gzip_comp_level 2;

gzip_types text/plain application/x-javascript text/css application/xml;

gzip_vary on;


server {

listen 80;

server_name localhost;

location / {

root html;

index index.html index.htm;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}


upstream backend_server {

ip_hash;

server 192.168.1.10:80 max_fails=2 fail_timeout=30s;

server 192.168.1.20:80 max_fails=2 fail_timeout=30s;

}

server{

listen 80;

server_name www.abc.com;

server_name abc.com;

server_name testindex.abc.com;

location / {

proxy_redirect off;

#proxy_next_upstream http_502 http_504 error timeout invalid_header;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://backend_server;

}

}

upstream sqzone_api{

ip_hash;

server 192.168.0.10:80 max_fails=2 fail_timeout=30s;

server 192.168.0.20:80 max_fails=2 fail_timeout=30s;

}

server{

listen 80;

server_name sqZone.test.com;

server_name sqapi.test.com;

server_name sqapiby.test.com;

server_name sqapiby1.test.com;

server_name sqapitixing.test.com;

server_name sqapitixingby.test.com;

server_name sqapitixingby1.test.com;

location / {

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://sqzone_api;

}

}

}

CentOS 6.0 中编译安装 Nginx

CentOS 6.0 中编译安装 Nginx

环境

服务器:192.168.10.181

系统:CentOS 6.0

Nginx 版本:1.0.8

安装过程

1、打开终端命令窗口(可以拖拽至桌面)

clip_image002

2、切换至 root 用户

clip_image003

3、安装 nginx 所依赖的包

[root@Nginx canyouNgx]# yum install gcc openssl-devel pcre-devel zlib-devel

4、创建 nginx 的用户和用户组

[root@Nginx canyouNgx]# groupadd nginx

[root@Nginx canyouNgx]# useradd nginx -g nginx

5、将 nginx 1.0.8 源码解压至桌面(下载地址 http://nginx.org/download/nginx-1.0.8.tar.gz)

[root@Nginx canyouNgx]# tar zxf nginx-1.0.8.tar.gz

[root@Nginx canyouNgx]# cd nginx-1.0.8/

6、编译安装前配置环境信息 (此处为一条命令语句)

[root@Nginx canyouNgx]# ./configure

--prefix=/usr \

--sbin-path=/usr/sbin/nginx \

--conf-path=/etc/nginx/nginx.conf \

--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \

--user=nginx \

--group=nginx \

--with-http_ssl_module \

--with-http_flv_module \

--with-http_gzip_static_module \ 

--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/

7、编译安装

[root@Nginx canyouNgx]# make && make install

8、启动 nginx

[root@Nginx canyouNgx]# /usr/local/nginx/sbin/nginx

9、在浏览器中输入 http://localhost/ 测试安装成功

clip_image005

PS:

Centos 环境中有些时候需要手动添加 80 端口,外网才可以访问 Nginx

CentOS 6.5 下编译安装 Nginx 1.8.0

CentOS 6.5 下编译安装 Nginx 1.8.0

安装编译依赖的包

yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl 
yum -y install openssl-devel pcre pcre-devel

安装 Nginx

# 下载源码
wget  http://nginx.org/download/nginx-1.8.0.tar.gz  

# 解压
tar zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0

# 编译安装
./configure
make && make install

运行 configure 后可以看到一大串配置信息:

nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

配置 Nginx

注意上面的配置信息,Nginx 的配置文件在 /usr/local/nginx/conf/ 目录下,此时可以编辑 /usr/local/nginx/conf/nginx.conf 文件,修改配置,这个就不多说了。

配置完可以用 nginx -t 检查配置是否正确。

修改完之后就可以启动 Nginx 了:

nginx -c /usr/local/nginx/conf/nginx.conf 

# 查看 nginx 进程
ps aux | grep nginx 

centos 67安装nginx 110 centos7 nginx php centos官网 centos下

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教程有兴趣的朋友有所帮助。

今天关于centos编译nginxcentos编译运行c程序的分享就到这里,希望大家有所收获,若想了解更多关于CentOS 6 nginx(Tengine2.1.2)源码编译一键部署脚本、CentOS 6.0 中编译安装 Nginx、CentOS 6.5 下编译安装 Nginx 1.8.0、centos 67安装nginx 110 centos7 nginx php centos官网 centos下等相关知识,可以在本站进行查询。

本文标签: