关于为什么网络拓扑结构是这样的,这里不展开说明,可以参考博主的另一篇博文《在实践中深入理解VMware虚拟机的上网模式NAT模式》,这篇文章深入地分析了VMware虚拟机使用NAT模式上网时的网络结构细节,相信看完这篇文章后,这里搭建Nginx的实验环境也就很容易理解了。[root@leaf ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@leaf ~]# uname -r
2.6.32-431.el6.x86_64
[root@leaf ~]# uname -m
x86_64[root@leaf ~]# rpm -q pcre pcre-devel 上面可以看到并没有安装使用yum方式安装如下:[root@leaf ~]# yum install pcre pcre-devel -y
......
Installed:
pcre-devel.x86_64 0:7.8-7.el6
Updated:
pcre.x86_64 0:7.8-7.el6
Complete! 安装完后检查一下是否已经成功安装:[root@leaf ~]# rpm -q pcre pcre-devel
pcre-7.8-7.el6.x86_64
pcre-devel-7.8-7.el6.x86_64 可以看到已经安装成功。[root@leaf ~]# rpm -q openssl openssl-devel
openssl-1.0.1e-15.el6.x86_64
package openssl-devel is not installed 可以看到只是安装了opensslopenssl-devel还没有安装使用yum安装如下:[root@leaf ~]# yum install -y openssl-devel
......
Complete! 再次检查:[root@leaf ~]# rpm -q openssl openssl-devel
openssl-1.0.1e-48.el6_8.4.x86_64
openssl-devel-1.0.1e-48.el6_8.4.x86_64 可以看到都已经成功安装上。[root@leaf ~]# pwd
/root
[root@leaf ~]# mkdir tools
[root@leaf ~]# cd tools/
[root@leaf tools]# wget http://nginx.org/download/nginx-1.6.3.tar.gz
......
100%[======================================>] 805,253 220K/s in 3.6s
2017-02-24 12:10:26 (220 KB/s) - anginx-1.6.3.tar.gza saved [805253/805253] 查看下载的Nginx软件包:[root@leaf tools]# ll
total 788
-rw-r--r--. 1 root root 805253 Apr 8 2015 nginx-1.6.3.tar.gz 当然上面的方式是使用wget方式直接下载,前提是已经知道了Nginx的下载地址,也可以到官网下载,然后再上传到我们的CentOS操作系统上。[root@leaf ~]# mkdir /application
[root@leaf ~]# ls -d /application/
/application/[root@leaf tools]# tar -zxvf nginx-1.6.3.tar.gz
......
[root@leaf tools]# ls
nginx-1.6.3 nginx-1.6.3.tar.gz[root@leaf tools]# useradd nginx -s /sbin/nologin -M
[root@leaf tools]# tail -1 /etc/passwd
nginx:x:500:500::/home/nginx:/sbin/nologin
# -s参数后的/sbin/nologin指定不允许nginx进行登陆
# -M参数则是在创建该用户时不创建用户家目录 使用configure命令指定编译参数:[root@leaf nginx-1.6.3]# ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ --with-http_stub_status_module --with-http_ssl_module 对于配置时使用的参数可以通过./configure --help来进行查询,上面使用的参数解析如下:--prefix=PATH # 指定安装路径
--user=USER # 设置用户进程权限
--group=GROUP # 设置用户组进程权限
--with-http_stub_status_module # 激活状态信息
--with-http_ssl_module # 激活ssl功能[root@leaf nginx-1.6.3]# make
...... 检查编译是否成功:[root@leaf nginx-1.6.3]# echo $?
0 返回0即说明编译成功。[root@leaf nginx-1.6.3]# make install
...... 检查安装是否成功:[root@leaf nginx-1.6.3]# echo $?
0 返回0即说明安装成功。[root@leaf nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx
[root@leaf nginx-1.6.3]# ls -l /application/
total 4
lrwxrwxrwx. 1 root root 25 Feb 24 12:32 nginx -> /application/nginx-1.6.3/
drwxr-xr-x. 6 root root 4096 Feb 24 12:28 nginx-1.6.3[root@leaf ~]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful[root@leaf ~]# /application/nginx/sbin/nginx 如果在启动Nginx服务时出现了问题可以查看Nginx的日志/application/nginx/logs/error.log,再根据日志提供的信息来进行解决。[root@leaf ~]# netstat -lnp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6772/nginx
unix 2 [ ACC ] STREAM LISTENING 9180 1/init @/com/ubuntu/upstart 可以看到Nginx已经在侦听80端口。[root@leaf ~]# ps aux | grep nginx
root 6772 0.0 0.1 45028 1140 ? Ss 12:34 0:00 nginx: master process /application/nginx/sbin/nginx
nginx 6773 0.0 0.1 45460 1716 ? S 12:34 0:00 nginx: worker process
root 6777 0.0 0.0 103256 832 pts/1 S+ 12:36 0:00 grep nginx
可以正常访问,当然前提是CentOS上的防火墙功能已经关闭。[root@leaf tools]# wget 127.0.0.1
--2017-02-24 12:41:05-- http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 612 [text/html]
Saving to: aindex.htmla
100%[======================================>] 612 --.-K/s in 0s
2017-02-24 12:41:05 (44.1 MB/s) - aindex.htmla saved [612/612] currl命令:[root@leaf tools]# curl 127.0.0.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html> 从上面的结果可以说明Nginx已经正常部署并运行。[root@leaf tools]# cd /application/nginx/html/
[root@leaf html]# ls
50x.html index.html
[root@leaf html]# mv index.html index.html.source
[root@leaf html]# echo "<h1>Hello, I'm xpleaf.</h1>">index.html
[root@leaf html]# ls
50x.html index.html index.html.source
[root@leaf html]# cat index.html
<h1>Hello, I'm xpleaf.</h1> 这时在宿主机操作系统上访问http://10.0.0.101/
可以看到已经显示我们编辑的页面了。很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我打算为ruby脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn
我正在编写一个包含C扩展的gem。通常当我写一个gem时,我会遵循TDD的过程,我会写一个失败的规范,然后处理代码直到它通过,等等......在“ext/mygem/mygem.c”中我的C扩展和在gemspec的“扩展”中配置的有效extconf.rb,如何运行我的规范并仍然加载我的C扩展?当我更改C代码时,我需要采取哪些步骤来重新编译代码?这可能是个愚蠢的问题,但是从我的gem的开发源代码树中输入“bundleinstall”不会构建任何native扩展。当我手动运行rubyext/mygem/extconf.rb时,我确实得到了一个Makefile(在整个项目的根目录中),然后当
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs
我有一个围绕一些对象的包装类,我想将这些对象用作散列中的键。包装对象和解包装对象应映射到相同的键。一个简单的例子是这样的:classAattr_reader:xdefinitialize(inner)@inner=innerenddefx;@inner.x;enddef==(other)@inner.x==other.xendenda=A.new(o)#oisjustanyobjectthatallowso.xb=A.new(o)h={a=>5}ph[a]#5ph[b]#nil,shouldbe5ph[o]#nil,shouldbe5我试过==、===、eq?并散列所有无济于事。
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e