centos平台编译环境使用如下指令
安装make:
yum -y install gcc automake autoconf libtool make
安装g++:
yum install gcc gcc-c++
下面正式开始
---------------------------------------------------------------------------
一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz http://www.zlib.net/zlib-1.2.11.tar.gz https://www.openssl.org/source/openssl-1.0.1t.tar.gz http://nginx.org/download/nginx-1.10.3.tar.gz
将包解压到下
/usr/local/src/
pcre安装
cd /usr/local/src/pcre-8.42 ./configure make make install
安装zlib库
cd /usr/local/src/zlib-1.2.11 ./configure make make install
安装ssl(某些vps默认没装ssl)
无须安装
安装nginx
Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /usr/local/nginx 目录下的详细步骤:
cd /usr/local/src/nginx-1.4.2 ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/opt/app/openet/oetal1/chenhe/pcre-8.42 --with-zlib=/opt/app/openet/oetal1/chenhe/zlib-1.2.11 --with-openssl=/opt/app/openet/oetal1/chenhe/openssl-1.0.1t make make install
安装成功,配置nginx.conf文件
server_name换成你机器的ip
然后我的web目录是:/var/www/html
#user nobody; worker_processes 1; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; #server_name localhost; server_name 192.168.44.128; #charset koi8-r; #access_log logs/host.access.log main; location / { root /var/www/html; index index.html index.htm; } #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 /var/www/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; #} }
设置webroot目录
/var/www/html
里面有一个index.html
加入iptables
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
https://www.cnblogs.com/achengmu/p/9458806.html
启动nginx
/usr/local/nginx/nginx
访问nginx
http://192.168.44.128/index.html