-
Notifications
You must be signed in to change notification settings - Fork 1
/
use_ali_cloud.html
1 lines (1 loc) · 16.7 KB
/
use_ali_cloud.html
1
<!doctype html><html lang="zh-CN" class="night"><head><meta charset="utf-8"><meta content="width=device-width,initial-scale=1,maximum-scale=4,user-scalable=0" name="viewport"><title>Ede's Blog</title><meta name="description" content="Try to be a qualified programmer"><meta property="og:type" content="website"><meta property="og:description" content="Try to be a qualified programmer"><meta property="og:title" content="Ede's Blog"><meta property="og:site_name" content="Ede's Blog"><meta property="og:url" content="https://ede.ink"><meta property="og:image" content="https://edeity.oss-cn-shenzhen.aliyuncs.com/public/edeity_o.png"><link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"><link rel="mainfest" href="/mainfest.json"><link rel="stylesheet" href="/public/css/common.css"><link rel="stylesheet" href="//at.alicdn.com/t/font_707055_4b9og9sc5lx.css"><script>!function(){var e=-1!==window.location.search.indexOf("theme=night")||"night"===window.localStorage.getItem("edeity-theme_theme"),t=-1!==window.location.search.indexOf("theme=light")||"light"===window.localStorage.getItem("edeity-theme_theme");(new Date).getHours();var n=document.querySelector("html");e?n.classList.add("night"):t?n.classList.remove("night"):n.classList.add("night")}(),document.addEventListener("DOMContentLoaded",function(){null!==document.querySelector("ol.toc")&&(document.querySelector("#nav-bar").style.cssText="display: block")})</script><script async src="https://www.googletagmanager.com/gtag/js?id=G-M3J9QSEE2Z"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-M3J9QSEE2Z")</script><meta name="generator" content="Hexo 5.0.0"></head><body><div class="loading"></div><div id="switch" data-switch="{"toc":true,"use_pwa":false}"></div><header class="fullscreen"><div class="toolbar"><i class="iconfont icon-menu"></i></div><h1><a href="/">Ede's Blog</a></h1><div class="head-link"><a class="btn waves" href="/"><span><i class="iconfont icon-home">Home </i></span></a><a class="btn waves" href="/about/index.html"><span><i class="iconfont icon-me">About </i></span></a><a class="btn waves" target="_blank" rel="noopener" href="https://github.com/edeink"><span><i class="iconfont icon-github">Github</i></span></a></div></header><div class="some-link"><a class="btn" id="light-or-not"><i class="iconfont icon-light"></i> </a><a style="display:none" class="btn" id="up-to-top"><i class="iconfont icon-up"></i></a></div><div id="nav-bar" style="display:none"><div class="toc"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A2%84%E5%A4%87%E5%B7%A5%E4%BD%9C"><span class="toc-number">1.</span> <span class="toc-text">预备工作</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8A%98%E8%85%BERound-1%EF%BC%9A%E6%90%AD%E5%BB%BAwordpress"><span class="toc-number">2.</span> <span class="toc-text">折腾Round 1:搭建wordpress</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85lamp"><span class="toc-number">2.1.</span> <span class="toc-text">安装lamp</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85ftp"><span class="toc-number">2.2.</span> <span class="toc-text">安装ftp</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85phpMyAdmin"><span class="toc-number">2.3.</span> <span class="toc-text">安装phpMyAdmin</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85wordpress"><span class="toc-number">2.4.</span> <span class="toc-text">安装wordpress</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A1%A5%E5%85%85"><span class="toc-number">2.5.</span> <span class="toc-text">补充</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8A%98%E8%85%BERound-2"><span class="toc-number">3.</span> <span class="toc-text">折腾Round 2</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%97%AE%E9%A2%98%E6%B1%87%E6%80%BB"><span class="toc-number">3.1.</span> <span class="toc-text">问题汇总</span></a></li></ol></li></ol></div></div><main id="content-main" class="section"><div class="list-item"><h1 class="post-title"><a id="阿里云搭建wordpress记" class="article-link" href="">阿里云搭建wordpress记</a></h1><div class="post-meta"><time class="meta published">Jun 19, 2015</time></div><div class="article"><div class="post-excerpt markdown-body"><p>备案已两月,在阿里云上各种折腾,总结不过两件事:</p><ul><li>搭建<code>wordpress</code></li><li>搭建<code>ruby on rails</code></li></ul><p>特此记录相关配置步骤</p><h2 id="预备工作"><a href="#预备工作" class="headerlink" title="预备工作"></a>预备工作</h2><ul><li>安装centos(自带SSL)</li><li><a target="_blank" rel="noopener" href="http://www.yujzw.com/cswzjs/xshell.html">xshell连接阿里云</a></li><li>避免直接在root环境下操作,创建普通用户(不是必须)<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">useradd xxx </span><br><span class="line">passwd *** </span><br><span class="line">su xxx</span><br><span class="line"><span class="built_in">cd</span> ~</span><br></pre></td></tr></table></figure><ul><li><a target="_blank" rel="noopener" href="http://www.cnblogs.com/zox2011/archive/2013/05/28/3103824.html">创建普通用户没有sudo权限解决方案</a></li></ul></li></ul><h2 id="折腾Round-1:搭建wordpress"><a href="#折腾Round-1:搭建wordpress" class="headerlink" title="折腾Round 1:搭建wordpress"></a>折腾Round 1:搭建wordpress</h2><p><img src="https://edeity.oss-cn-shenzhen.aliyuncs.com/2015/wordpress.jpeg" alt="WordPress"></p><p>分三步:</p><ol><li>安装lamp</li><li>安装辅助服务(如phpMyAdmin,FTP等)</li><li>安装wordpress</li></ol><h3 id="安装lamp"><a href="#安装lamp" class="headerlink" title="安装lamp"></a>安装lamp</h3><ol><li><p>安装Apache</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">sudo yum install httpd <span class="comment"># 下载安装apache</span></span><br><span class="line">sudo service httpd start <span class="comment"># 启动服务</span></span><br></pre></td></tr></table></figure><p>在游览器中输入公网ip,查看apache是否启动成功</p></li><li><p>安装mysql</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">sudo yum install mysql-server</span><br><span class="line">sudo service mysqld start</span><br></pre></td></tr></table></figure></li><li><p>安装PHP以及PHP组件</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">sudo yum install php php-mysql </span><br><span class="line">yum install php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc</span><br></pre></td></tr></table></figure></li><li><p>开机启动Apache和Mysql </p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">sudo chkconfig httpd on </span><br><span class="line">sudo chkconfig mysqld on</span><br></pre></td></tr></table></figure></li></ol><h3 id="安装ftp"><a href="#安装ftp" class="headerlink" title="安装ftp"></a>安装ftp</h3><ol><li><p>安装ftp </p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">yum -y install vsftpd</span><br></pre></td></tr></table></figure></li><li><p>关闭防火墙并允许21号端口通行</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">service iptables stop </span><br><span class="line">iptables -A INPUT -p tcp –dport 21 -j ACCEPT </span><br><span class="line">iptables -A INPUT -p tcp –dport 20 -j ACCEPT</span><br></pre></td></tr></table></figure></li><li><p>保存更改</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">/etc/rc.d/init.d/iptables save </span><br><span class="line">service iptables restart <span class="comment"># 重启防火墙</span></span><br></pre></td></tr></table></figure><ul><li><a target="_blank" rel="noopener" href="http://www.cnblogs.com/JemBai/archive/2009/03/19/1416364.html">iptables参考</a> </li></ul></li><li><p>配置vsftpd </p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">vim /etc/vsftpd/vsftpd.conf </span><br></pre></td></tr></table></figure><p>vsftpd.conf 设置如下:</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">anonymous_enable=NO <span class="comment"># 禁止匿名用户anonymous登录 </span></span><br><span class="line">chroot_local_user=YES <span class="comment"># 限制在home目录下,无法向上改变目录。 </span></span><br></pre></td></tr></table></figure></li><li><p>启动ftp </p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">service vsftpd start</span><br></pre></td></tr></table></figure></li><li><p>可通过xftp图形界面进行操作</p><p>配置和xshell同,输入公网ip,账号密码即可</p></li></ol><h3 id="安装phpMyAdmin"><a href="#安装phpMyAdmin" class="headerlink" title="安装phpMyAdmin"></a>安装phpMyAdmin</h3><p>phpMyAdmin已被<a target="_blank" rel="noopener" href="http://www.heidisql.com/">heidisql</a>(一个简单易用的图形工具)取代</p><p>默认安装的mysql不允许远程访问,需配置<code>mysql -u root -p</code>:</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">> GRANT ALL ON . TO <span class="string">"root"</span>@<span class="string">"121.250.220.39"</span> IDENTIFIED BY <span class="string">"1234"</span>;</span><br><span class="line">> flush privileges</span><br><span class="line">> <span class="built_in">exit</span></span><br></pre></td></tr></table></figure><p>配置防火墙:</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">service iptables stop <span class="comment"># 防火墙放行3306</span></span><br><span class="line">iptables -A INPUT -p tcp --dport 3306 -j ACCEPT</span><br><span class="line">./etc/rc.d/init.d/iptables save</span><br><span class="line">service iptables restart <span class="comment"># 重启防火墙</span></span><br><span class="line">service mysqld restart <span class="comment"># 重启mysql</span></span><br></pre></td></tr></table></figure><h3 id="安装wordpress"><a href="#安装wordpress" class="headerlink" title="安装wordpress"></a>安装wordpress</h3><p>可到官网中下载最新版本的wordpress,在15/5/31,最新版本是4.22</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">wget https://cn.wordpress.org/wordpress-4.2.2-zh_CN.zip</span><br><span class="line">unzip wordpress-4.2.2-zh_CN.zip</span><br><span class="line"><span class="built_in">cd</span> wordpress</span><br><span class="line">vim wp-config-sample.php</span><br></pre></td></tr></table></figure><p>wp-config-sample.php配置如下:</p><figure class="highlight php"><table><tr><td class="code"><pre><span class="line">define(‘DB_NAME<span class="string">', ‘wordpress'</span>) ; <span class="comment">/** MySQL数据库名 */</span></span><br><span class="line">define(‘DB_USER<span class="string">', ‘root'</span>); <span class="comment">/** MySQL数据库用户名 */</span></span><br><span class="line">define(‘DB_PASSWORD<span class="string">', ‘password'</span>) <span class="comment">/** MySQL数据库密码 */</span></span><br><span class="line">define(‘DB_HOST<span class="string">', ‘localhost'</span>); <span class="comment">/** MySQL主机(不用修改) */</span></span><br></pre></td></tr></table></figure><p>迁移目录</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">mv wordpress /var/ww/html/blog <span class="comment"># 移动到apache推荐目录</span></span><br></pre></td></tr></table></figure><p>配置mysql<code>mysql -u root -p</code>:</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">> create database wordpress; </span><br><span class="line">> SET PASSWORD FOR <span class="string">'root'</span>@<span class="string">'localhost'</span>=PASSWORD(<span class="string">'newpassword'</span>);</span><br><span class="line">> quit;</span><br></pre></td></tr></table></figure><h3 id="补充"><a href="#补充" class="headerlink" title="补充"></a>补充</h3><p>上一步中,若把<code>wordpress</code>移动到<code>/var/www/html</code>文件夹,直接访问ip即可配置wordpress,但因个人需要,我把wordpress搬运至<code>/var/www/html/blog</code>中了,因此还需要配置一下apache</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">sudo service httpd restart <span class="comment"># 重启apache服务器</span></span><br></pre></td></tr></table></figure><p><code>httpd.conf</code>配置如下:</p><figure class="highlight xml"><table><tr><td class="code"><pre><span class="line">NameVirtualHost *:80</span><br><span class="line"> <span class="tag"><<span class="name">VirtualHost</span> *<span class="attr">:80</span>></span></span><br><span class="line"> ServerName blog.edeity.net</span><br><span class="line"> DocumentRoot /var/www/html/blog</span><br><span class="line"> ErrorLog /var/www/html/blog/wordpress_log</span><br><span class="line"> <span class="tag"></<span class="name">VirtualHost</span>></span></span><br></pre></td></tr></table></figure><p>重启<code>vim /etc/httpd/conf/httpd.conf</code>,随后可通过blog.edeity.net来访问wordpress配置</p><p>apache或edeity无法更改wordpress配置文件:简单粗暴de的解决方法</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">sudo chown -R apache.apache html</span><br><span class="line">sudo chmod -R 775 html</span><br><span class="line">sudo usermod -G apache edeity</span><br></pre></td></tr></table></figure><h2 id="折腾Round-2"><a href="#折腾Round-2" class="headerlink" title="折腾Round 2"></a>折腾Round 2</h2><p><img src="https://edeity.oss-cn-shenzhen.aliyuncs.com/2015/ror.jpeg" alt="ROR"></p><p>安装ruby(非RVM)</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">wget http://ruby.taobao.org/mirrors/ruby/ruby-2.2.2.zip</span><br><span class="line">unzip ruby-2.2.2.zip</span><br><span class="line"><span class="built_in">cd</span> ruby-2.2.2</span><br><span class="line"> ./config</span><br><span class="line">sudo make</span><br><span class="line">sudo make install</span><br><span class="line">ruby -v</span><br><span class="line">gem -v</span><br></pre></td></tr></table></figure><p>测试</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">rails new blog</span><br><span class="line"><span class="built_in">cd</span> blog</span><br><span class="line">bundle install</span><br></pre></td></tr></table></figure><p>更换成淘宝的源(若gem安装过慢)</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">gem <span class="built_in">source</span> -r https://rubygems.org/</span><br><span class="line">gem <span class="built_in">source</span> -a http://ruby.taobao.org</span><br><span class="line">gem install bundler</span><br><span class="line">gem install rails</span><br><span class="line">rails -v</span><br></pre></td></tr></table></figure><h3 id="问题汇总"><a href="#问题汇总" class="headerlink" title="问题汇总"></a>问题汇总</h3><p>Q: <code>bundle install</code>无缘被终止,如:</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">Using rails 4.2.1</span><br><span class="line">Using rdoc 4.2.0</span><br><span class="line">Using sass 3.4.14</span><br><span class="line">...</span><br><span class="line">Killed <span class="comment"># 执行到一般,被中断了</span></span><br></pre></td></tr></table></figure><p>A:原因:交换区不够:<a target="_blank" rel="noopener" href="https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-12-04">解决方法</a></p></div></div></div><div class="more section"><div class="pre"><a class="article-link" href="/js_prototype.html"><i class="iconfont icon-right"></i> <span>理解Function和Object的原型关系</span></a></div><div class="next"><a class="article-link" href="/learn_ycsb.html">Yahoo! Cloud Serving Benchmark <i class="iconfont icon-right"></i></a></div></div></main></body><footer class="section fullscreen"><div class="footer-desc">Edeink © 2015-2022 · Powered by Hexo</div></footer><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script><script src="/public/js/init.js"></script></html>