Build Jenkins on Centos

1 Install the new version of python.

Download Python-2.7.13.tar.gz and decompress it to run. / configure & make & make install.

You need to configure the python program in $PATH and execute Ln-S Python 2.7 Python under / usr/bin to make a new link.

This will result in the failure of the yum program. Errors were reported as follows:

[root@zhaoxp2-001 bin]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.13 (default, Apr 18 2017, 16:04:14) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq
  

[root@zhaoxp2-001 bin]# 

Modify the first line of/usr/bin/yum:

Change from!/ usr/bin/python to!/ usr/bin/python 2.6.

Install pip.

The same problem is that / usr/bin/pip already exists, rename it and reinstall it. If installed, you can remove the pip directory under Python's lib and reinstall it.

One way is to download the pip code file and run python setup.py install.

Another way (which I use for my lock) is to download get-pip.py and execute python get-pip.py. Download from here:

https://bootstrap.pypa.io/get-pip.py

Install nginx.

nginx can be installed by code through. / configure & make & make install. But this will depend on openssl, zlib, pcre and other packages.

I used the yum mode, first configure yum, add the file / etc/yum.repos.d/nginx.repo. The contents are as follows:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/6/$basearch/
gpgcheck=0
enabled=1

This allows you to install and install dependency packages automatically through yum install nginx.

4 nginx configuration.

The configuration file is placed in / etc/nginx/conf.d/default.conf, as follows:

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    location /deploy {
        proxy_pass http://localhost:8080/deploy;
    }

    ignore_invalid_headers off;

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

Note here:

location /deploy {
        proxy_pass http://localhost:8080/deploy;
}

This jumps the / deploy request to tomcat.

ignore_invalid_headers off; this is to solve the following problems:

jenkins places a token called. crumb in the http request header. After using the reverse proxy and checking "Prevent Cross Site Request Forgery exploits" in the jenkins settings, the token is removed by the forwarding server apache/nginx as an illegal header. Causes the jump to fail.
The problem is that jenkins stores its' csrf token in a http header called '.crumb', AFAIK headers must only contain alphanumerics and dashes, and apache/nginx will remove invalid headers from the request (unless configured not to).
Another solution is to cancel the check "Prevent Cross Site Request Forgery exploits" in the jenkins global security settings.

Here's an explanation:

http://lixuanbin.iteye.com/blog/2040996

Keywords: Nginx Python yum pip

Added by aragon1337 on Mon, 08 Jul 2019 01:49:34 +0300