如何在CentOS7上面编译安装Nginx,快速实现你的负载均衡?
[root@haoding-jq1 ~]# cd /home/haoding/
[root@haoding-jq1 haoding]# cd hd205/
[root@haoding-jq1 hd205]# pwd
/home/haoding/hd205
[root@haoding-jq1 hd205]# ll
总用量 7796
-rw-rw-r-- 1 haoding haoding 120553 9月 13 11:28 nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d.tar.gz
-rw-rw-r-- 1 haoding haoding 832104 9月 13 11:28 nginx-1.8.0.tar.gz
-rw-rw-r-- 1 haoding haoding 167495 9月 13 11:28 nginx_upstream_check_module-master.zip
-rw-rw-r-- 1 haoding haoding 4509047 9月 13 11:28 openssl-1.0.1g.tar.gz
-rw-rw-r-- 1 haoding haoding 2053336 9月 13 11:28 pcre-8.38.tar.gz
ll
cp pcre-8.38.tar.gz /usr/local/src/
cp nginx-1.8.0.tar.gz /usr/local/src/
cp nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d.tar.gz /usr/local/src/
cp nginx_upstream_check_module-master.zip /usr/local/src/
cd /usr/local/src/
pwd
ll
gzip -cdf nginx-1.8.0.tar.gz | tar -xvf -
ll
gzip -cdf openssl-1.0.1g.tar.gz | tar -xvf -
ll
gzip -cdf pcre-8.38.tar.gz | tar -xvf -
ll
unzip nginx_upstream_check_module-master.zip
ll
gzip -cdf nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d.tar.gz | tar -xvf -
------------------------------->
nginx安装
cd nginx-1.8.0
加入skicty模块
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/usr/local/src/openssl-1.0.1g --with-pcre=/usr/local/src/pcre-8.38 --add-module=/usr/local/src/nginx_upstream_check_module-master/ --with-http_stub_status_module --with-http_realip_module --add-module=/usr/local/src/nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d/
make
make install
---------------------------------->
也可以简单的配置,比如:
./configure --with-http_ssl_module --prefix=/hd205/haoding/nginx --conf-path=/hd205/haoding/nginx/nginx.conf
#配置清楚prefix和conf-path的路径即可#
make
make install
------------------------->
[root@haoding-jq1 nginx-1.8.0]# cd /usr/local/nginx/
[root@haoding-jq1 nginx]# cd sbin/
[root@haoding-jq1 sbin]# ./nginx -V
nginx version: nginx/1.8.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1g 7 Apr 2014
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/usr/local/src/openssl-1.0.1g --with-pcre=/usr/local/src/pcre-8.38 --add-module=/usr/local/src/nginx_upstream_check_module-master/ --with-http_stub_status_module --with-http_realip_module --add-module=/usr/local/src/nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d/
[root@haoding-jq1 sbin]# ps -ef|grep nginx
root 24333 2130 0 16:19 pts/0 00:00:00 grep --color=auto nginx
[root@haoding-jq1 sbin]# cd ../conf/
[root@haoding-jq1 conf]# ll
总用量 60
-rw-r--r-- 1 root root 1034 9月 13 16:14 fastcgi.conf
-rw-r--r-- 1 root root 1034 9月 13 16:14 fastcgi.conf.default
-rw-r--r-- 1 root root 964 9月 13 16:14 fastcgi_params
-rw-r--r-- 1 root root 964 9月 13 16:14 fastcgi_params.default
-rw-r--r-- 1 root root 2837 9月 13 16:14 koi-utf
-rw-r--r-- 1 root root 2223 9月 13 16:14 koi-win
-rw-r--r-- 1 root root 3957 9月 13 16:14 mime.types
-rw-r--r-- 1 root root 3957 9月 13 16:14 mime.types.default
-rw-r--r-- 1 root root 2656 9月 13 16:14 nginx.conf
-rw-r--r-- 1 root root 2656 9月 13 16:14 nginx.conf.default
-rw-r--r-- 1 root root 596 9月 13 16:14 scgi_params
-rw-r--r-- 1 root root 596 9月 13 16:14 scgi_params.default
-rw-r--r-- 1 root root 623 9月 13 16:14 uwsgi_params
-rw-r--r-- 1 root root 623 9月 13 16:14 uwsgi_params.default
-rw-r--r-- 1 root root 3610 9月 13 16:14 win-utf
[root@haoding-jq1 conf]# vim nginx.conf
[root@haoding-jq1 conf]# cd ../sbin/
[root@haoding-jq1 sbin]# ./nginx
[root@haoding-jq1 sbin]# ps -ef|grep nginx
root 24337 1 0 16:19 ? 00:00:00 nginx: master process ./nginx
nobody 24338 24337 0 16:19 ? 00:00:00 nginx: worker process
root 24340 2130 0 16:19 pts/0 00:00:00 grep --color=auto nginx
[root@haoding-jq1 sbin]#
[root@haoding-jq1 sbin]# curl http://localhost:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@haoding-jq1 sbin]#
常见报错解决:
当报错:POD document had syntax errors at /usr/bin/pod2man line 69. make: *** [install_docs]
可以执行如下命令:
rm -f /usr/bin/pod2man
我是昊鼎王五,我为自己带盐,有兴趣的朋友们可以扫码关注公众号,更多惊喜等待着你哦