Dec 10

删除Apache2

$ sudo service apache2 stop
$ sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
$ sudo apt-get autoremove
$ whereis apache2
$ sudo rm -rf /etc/apache2

安装nginx

apt-get install build-essential git gcc g++ make
wget "http://nginx.org/download/nginx-1.7.8.tar.gz"
wget "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz"
wget "https://www.openssl.org/source/openssl-1.0.1j.tar.gz"
wget "http://zlib.net/zlib-1.2.8.tar.gz"
git clone https://github.com/cuber/ngx_http_google_filter_module
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
tar xzvf nginx-1.7.8.tar.gz
tar xzvf pcre-8.38.tar.gz
tar xzvf openssl-1.0.1j.tar.gz
tar xzvf zlib-1.2.8.tar.gz

cd nginx-1.7.8

./configure \
  --prefix=/usr/local/nginx \
  --with-pcre=../pcre-8.38 \
  --with-openssl=../openssl-1.0.1j \
  --with-zlib=../zlib-1.2.8 \
  --with-http_ssl_module \
  --with-http_stub_status_module \
  --with-http_ssl_module \
  --with-http_spdy_module \
  --with-http_gzip_static_module \
  --with-ipv6 \
  --with-http_sub_module \
  --add-module=../ngx_http_google_filter_module \
  --add-module=../ngx_http_substitutions_filter_module

make
make install

配置nginx

server {
  server_name scholar.google.com;
  resolver 8.8.8.8;
  location / {
    proxy_pass https://scholar.google.com;
  }
}

重启nginx:

/usr/local/nginx/sbin/nginx -s reload

报错代码:

nginx: [error] open() “/usr/local/nginx/logs/nginx.pid” failed (2: No such file or directory)

解决方法:
1.重新运行一下:

/usr/local/nginx/sbin/nginx

2.重启nginx:

/usr/local/nginx/sbin/nginx -s reload

3.运行:

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

Leave a Reply