一、虛擬機準備:
[root@localhost 桌面]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.59.1 #注意虛擬機的IP與宿主機的內網IP不能相同
NETMASK=255.255.255.0
GATEWAY=192.168.59.2
DNS1=222.246.129.80
DNS2=114.114.114.114
[root@localhost 桌面]# ifconfig eth0 on #啟動eth0網卡
[root@localhost 桌面]# service network restart #重啟啟動網絡服務,使得剛才的配置生效
至此NAT模式下實現虛擬機對外部網絡訪問功能已經配置完成。
二、安裝Nginx,在centos
1.安裝make
yum -y install gcc automake autoconf libtool make yum install gcc gcc-c++ 2.安裝pcre cd /usr/local/src wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz tar -zxvf pcre-8.37.tar.gz cd pcre-8.34 ./configure make make install 3.安裝zlib cd /usr/local/src wget http://zlib.net/zlib-1.2.11.tar.gz tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure make make install 4.安裝openssl cd /usr/local/src wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz tar -zxvf openssl-1.0.1t.tar.gz 5.安裝nginx cd /usr/local/src wget http://nginx.org/download/nginx-1.1.10.tar.gz tar -zxvf nginx-1.1.10.tar.gz cd nginx-1.1.10 ./configure make make install yum -y install openssl openssl-devel
nginx啟動命令:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
啟動失敗:
ln -s /usr/local/lib/libpcre.so.1 /lib
nginx停止命令:
ps -ef|grep nginx
kill -INT 2132
pkill -9 nginx
nginx重啟命令:
./nginx -s reload