這篇文章主要介紹“CentOS5.2 Apache怎么搭建系統(tǒng)開發(fā)環(huán)境”,在日常操作中,相信很多人在CentOS5.2 Apache怎么搭建系統(tǒng)開發(fā)環(huán)境問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”CentOS5.2 Apache怎么搭建系統(tǒng)開發(fā)環(huán)境”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!
你所需要的網(wǎng)站建設(shè)服務(wù),我們均能行業(yè)靠前的水平為你提供.標(biāo)準(zhǔn)是產(chǎn)品質(zhì)量的保證,主要從事網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、企業(yè)網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、品牌網(wǎng)站建設(shè)、網(wǎng)頁制作、做網(wǎng)站、建網(wǎng)站。成都創(chuàng)新互聯(lián)擁有實(shí)力堅(jiān)強(qiáng)的技術(shù)研發(fā)團(tuán)隊(duì)及素養(yǎng)的視覺設(shè)計(jì)專才。
對(duì)大家推薦很好使用的CentOS5.2 Apache系統(tǒng)之前,像讓大家對(duì)CentOS5.2 Apache系統(tǒng)有所了解,然后對(duì)CentOS5.2 Apache系統(tǒng)全面講解介紹,CentOS Linux的特點(diǎn)和版本CentOS社區(qū)的Linux發(fā)行版本被稱為CentOS Linux,由于使用了由RHEL的源代碼重新編譯生成新的發(fā)行版本,CentOS Linux具有與RHEL產(chǎn)品非常好的兼容性,并且與生俱來地?fù)碛蠷HEL的諸多優(yōu)秀特性。希望對(duì)大家有用。CentOS5.2 Apache下搭建Ruby on Rails開發(fā)環(huán)境 最近看上了Ruby on Rails的敏捷開發(fā)技術(shù)了,雖然早已不是什么新鮮玩意了,不過看著它越來越流行了,還是想看一看里面的究竟啊, 先從搭建Ruby on Rails的環(huán)境入手吧。
1.CentOS5.2 Apache下安裝Ruby
rails框架也是Ruby做的,自然要先安裝Ruby了,yum install ruby -y確認(rèn)一下Ruby -v
2.CentOS5.2 Apache下安裝RubyGems
RubyGems是Ruby函數(shù)庫的管理系統(tǒng)在此之前先要導(dǎo)入dlutter軟件倉庫[root@host1 ~]# vi /etc/yum.repos.d/dlutter.repo修改成[dlutter]name=Unsupported RHEL5 packages (lutter)baseurl=http://people.redhat.com/dlutter/yum/rhel/5/$basearch/enabled=0gpgcheck=0確認(rèn)[root@host1 ~]# yum --enablerepo=dlutter list然后直接用命令安裝RubyGems [root@host1 ~]# yum --enablerepo=dlutter -y install rubygems.noarch 確認(rèn)版本[root@host1 ~]# gem --version1.2.0安裝好應(yīng)該是1.2.0的版本,***是1.3.0的,有興趣的朋友可以用源碼編譯升級(jí)
3.rails框架的導(dǎo)入
這個(gè)比較簡(jiǎn)單,直接用RubyGems來安裝[root@host1 ~]# gem install rails
4.最關(guān)鍵也是比較復(fù)雜的一步是CentOS5.2 Apache下 Web服務(wù)器的導(dǎo)入
關(guān)于Web服務(wù)器的選擇,通常有很多爭(zhēng)議,就Ruby on Rails而言,很多都是采用lighttpd當(dāng)作Web Server,當(dāng)作FastCGI應(yīng)用程序來跑,但是lighttpd還是很難代替CentOS5.2 Apache的地位,特別是Rails程序以外還有其他Web程序的時(shí)候、不大可能完全移植到lighttpd上的,所以在這里,只是Rails程序跑在lighttpd上,對(duì)Rails程序的請(qǐng)求通過CentOS5.2 Apache下轉(zhuǎn)送過來。先安裝FastCGI
[root@host1 ~]# wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
[root@host1 ~]# tar zxvf fcgi-2.4.0.tar.gz
[root@host1 ~]# cd fcgi-2.4.0
[root@host1 fcgi-2.4.0]# ./configure
[root@host1 ~]# gem install fcgi
[root@host1 fcgi-2.4.0]# make
[root@host1 fcgi-2.4.0]# make install
[root@host1 fcgi-2.4.0]# cd
[root@host1 ~]# rm -rf fcgi-2.4.0*
下面用RubyGems把Ruby的FastCGI的包導(dǎo)進(jìn)來接下去就要安裝lighttpd服務(wù)器了,先導(dǎo)入RPMforge 軟件倉庫
[root@host1 ~]# wget http://dag.wieers.com/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[root@host1 ~]# rpm -Uhv rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[root@host1 ~]# vi /etc/yum.repos.d/rpmforge.repoenabled = 1enabled = 0
[root@host1 ~]# wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
[root@host1 ~]# rpm --import RPM-GPG-KEY.dag.txt
確認(rèn)[root@host1 ~]# yum --enablerepo=rpmforge list
開始安裝
[root@host1 ~]# yum --enable=rpmforge install lighttpd
[root@host1 ~]# yum --enable=rpmforge install lighttpd-fastcgi一般系統(tǒng)已經(jīng)有CentOS5.2 Apache下服務(wù)了,為了避免沖突,還要配置一下lighttpd,
[root@host1 ~]# vi /etc/lighttpd/lighttpd.conf#"mod_rewrite",#"mod_redirect",#"mod_alias","mod_rewrite","mod_redirect","mod_alias","mod_fastcgi","mod_fastcgi",
#server.port= 81server.port= 3000 ←端口設(shè)置成3000不要與CentOS5.2 Apache下的重復(fù)#server.bind= "127.0.0.1"server.bind= "localhost" 自啟動(dòng)[root@host1 ~]# chkconfig lighttpd on
Rails應(yīng)用程序的基本設(shè)置
[root@host1 ~]# cd /srv/www/lighttpd
[root@lighttpd]# mkdir rails
[root@lighttpd]# rails ./rails
賦予lighttpd用戶的權(quán)限
[root@host1 ~]# cd
[root@host1 ~]# chown -R lighttpd. /srv/www/lighttpd/rails
[root@host1 ~]# chmod +x /srv/www/lighttpd/rails/public/dispatch.*
CentOS5.2 Apache下的設(shè)
[root@host1 ~]# vi /etc/lighttpd/lighttpd.conf
加在末尾$HTTP["host"] =~ "ithurricane.dip.jp" {server.document-root = "/srv/www/lighttpd/rails/public"alias.url = ( "/" => "/srv/www/lighttpd/rails/public/" )server.indexfiles = ( "index.html", "dispatch.fcgi" )accesslog.filename = "/var/log/lighttpd/access.log"server.errorlog = "/var/log/lighttpd/server.log"server.error-handler-404 = "/dispatch.fcgi"
url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
fastcgi.server = (".fcgi" => ("localhost" => ("socket" => "/tmp/rails.fcgi.socket","bin-path" => "/srv/www/lighttpd/rails/public/dispatch.fcgi","bin-environment" => ("RAILS_ENV" => "production","RAILS_ROOT" => "/srv/www/lighttpd/rails"),"idol-timeout" => 10,"check-local" => "disable","min-procs" => 1,"max_procs" => 20)))}[root@host1 ~]# /etc/init.d/lighttpd start下面還要設(shè)置一下CentOS5.2 Apache下把對(duì)Rails的請(qǐng)求轉(zhuǎn)發(fā)到lighttpd[root@host1 ~]# vi /etc/httpd/conf.d/virtualhost.conf
ProxyPreserveHost On
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://127.0.0.1:3000/
大功告成,重載一下設(shè)定即可root@host1 ~]# /etc/init.d/httpd reload***導(dǎo)入圖像處理庫,和數(shù)據(jù)庫SQLite3,這些都比較簡(jiǎn)單,一筆帶過了,
[root@host1 ~]# yum install freetype
[root@host1 ~]# yum install libpng
[root@host1 ~]# yum install gd-devel
[root@host1 ~]# gem install ruby-gd -- --build-flag --with-freetype
[root@host1 ~]# gem install sqlite3-rubySelect which gem to install for your platform (i686-linux)
1. sqlite3-ruby 1.2.1 (ruby)
2. sqlite3-ruby 1.2.1 (mswin32)
3. sqlite3-ruby 1.2.0 (mswin32)
4. sqlite3-ruby 1.2.0 (ruby)
5. Skip this gem
6. Cancel installation> 1終于完成了,把rails的服務(wù)打開來,看看成果吧,注意跑的是CentOS5.2 Apache下的80端口
到此,關(guān)于“CentOS5.2 Apache怎么搭建系統(tǒng)開發(fā)環(huán)境”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!