前期的准备工作:两台Centos 6的主机,nginx安装包,cetos 6的iso包
两台主机的ip配置:
yum:192.168.4.10
client:192.168.4.30
1.首先本地yum源,把centos6 光驱里面的文件拷贝到yum源的机子上面;
2.配置本地yum源;
[root@yum ~]# yum clean all
Loaded plugins: fastestmirror, security
Cleaning repos: c6-media
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@yum ~]# yum makecahce
Loaded plugins: fastestmirror, security
No such command: makecahce. Please use /usr/bin/yum –help
3. 安装nginx服务器;
1、 首先编译nginx;
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --error-log-path=/data/log/nginx/error_log --http-log-path=/data/log/nginx/access_log --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module
2、 Make&&make install;
4. Ngxin安装完成之后,配置nginx.conf文件;
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;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
# index index.html index.htm;
proxy_pass https://192.168.4.10;
}
#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 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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
server {
listen 443 ssl;
server_name localhost;
ssl on;
ssl_certificate /usr/local/nginx/server.pem;
ssl_certificate_key /usr/local/nginx/server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /yum;
autoindex on;
}
}
5. 用windos主机访问192.168.4.10.。是否能正常访问主机;
6. 基于nginx的yum源搭建完成。
联系客服