vm NAT模式固定ip上网
1、初始化的网络状态应该外网ping不通,只能ping本机,
ping www.baidu.com //ping不通
ping 127.0.0.1 //ping通
2、然后看下 编辑->虚拟机网络编辑器下VMnet8中NAT设置里的网关和DHCP设置里的起始/结束ip地址,这里尤其要记住ip地址范围哦。
#cd /etc/sysconfig/network-scripts/ //切换到网络配置文件目录
#vi ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
UUID=be397835-5860-47d9-b96a-57fa3b344a1c
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.127.201 (#此处的ip地址要在之前看到起始/结束ip地址范围内)
GATEWAY=192.168.127.2 (#网关按之前看的配置配)
NETMASK=255.255.255.0
DNS1=8.8.8.8
3、新增如上内容,:wq!保存即可
4、重启网络 service network restart后就能ping通外网啦
vm NAT模式dhcp ip分配
上面说的方法在虚拟机中可上外网,但在本机不能访问ip,报503错误码,选择如下方式可正常访问。
1、解决dhcp动态分配ip地址bug,配置项如下:
DEVICE=eth0
HWADDR=00:0C:29:41:0C:65
TYPE=Ethernet
UUID=c12e90da-249e-4a0f-b21c-f6440a842bed
ONBOOT=yes//此处必须为yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
#ifup eth0 //用来打开指定的网络接口
#/etc/init.d/network restart 重启网卡
2、ifconfig 查看ip
centos6.8 装nginx、PHP5.5、mysql暂时不需要
1、nginx编译安装
#wget https://nginx.org/download/nginx-1.8.0.tar.gz
#tar zxvf nginx-1.8.0.tar.gz
#cd nginx-1.8.0.tar.gz
#./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre
#make && make install
2、php-5.5编译安装
# wget http://cn2.php.net/distributions/php-5.5.15.tar.bz2 //下载 PHP 源码包
# tar xf php-5.5.15.tar.bz2 -C /usr/local/src/ //解压bz2格式文件
#groupadd www //创建 www 用户
# useradd -g www -s /sbin/nologin -M www
编辑安装
#cd php-5.5.15.tar.bz2
#./configure --prefix=/usr/local/php
#make && make install
不成功时重新安装
#make clean all
3、注意:接下来配置nginx.conf和php.ini
# cp php.ini-development /usr/local/php/lib/php.ini //注意:phpinfo查看php.ini的地址,复制到对应的地址,如果对应的地址下没有php.ini,则为默认的配置项
#find / -name "nginx.conf"
#find / -name "php.ini"
nginx.conf 配置项:
user www;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid/var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfileon;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
conf.d/*.conf 文件配置如下:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /home/www;
index index.html index.htm index.php;
}
location /demo
{
root /home/www;
index index.php;
location ~ \.php${
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME$fastcgi_script_name;
fastcgi_param REQUEST_URI$request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL$server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWAREnginx/$nginx_version;
fastcgi_param REMOTE_ADDR$remote_addr;
fastcgi_param REMOTE_PORT$remote_port;
fastcgi_param SERVER_ADDR$server_addr;
fastcgi_param SERVER_PORT$server_port;
fastcgi_param SERVER_NAME$server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS200;
}
}
#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;
}
}
4、手动启动服务
#/usr/local/php/sbin/php-fpm //启动php-fpm
#usr/sbin/nginx //启动nginx
#/usr/sbin/nginx -s reload //重启nginx
#killall php-fpm;/usr/local/php/sbin/php-fpm
#ps -ef | grep php-fpm
#ps -ef | grep nginx