<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>开发 &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/%E5%BC%80%E5%8F%91/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Mon, 11 Mar 2013 11:00:29 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>本地开发环境与最终运行环境配置同等是有必要的</title>
		<link>https://www.mudbest.com/%e6%9c%ac%e5%9c%b0%e5%bc%80%e5%8f%91%e4%b8%8e%e8%bf%9c%e7%a8%8b%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%85%8d%e7%bd%ae%e5%90%8c%e7%ad%89%e6%98%af%e5%be%88%e9%87%8d%e8%a6%81%e7%9a%84/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Mon, 29 Oct 2012 09:10:28 +0000</pubDate>
				<category><![CDATA[分享]]></category>
		<category><![CDATA[开发]]></category>
		<category><![CDATA[环境]]></category>
		<category><![CDATA[解决]]></category>
		<category><![CDATA[配置]]></category>
		<category><![CDATA[错误]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1630</guid>

					<description><![CDATA[简单的总结下这几天的工作，从安装系统，到配置环境，完成很顺利，但是配置的环境有差异，由于编码是前人所写，导致出...]]></description>
										<content:encoded><![CDATA[<p>简单的总结下这几天的工作，从安装系统，到配置环境，完成很顺利，但是配置的环境有差异，由于编码是前人所写，导致出现各种纠结错误。</p>
<p><strong>前事重现：</strong></p>
<p>系统：ubuntu 12.04<br />
<span id="more-1630"></span><br />
首先搭建 php 环境<br />
所谓LAMP：Linux，Apache，Mysql，PHP</p>
<p>安装 Apache2：</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install apache2
</pre>
<p>安装PHP模块：</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install php5
</pre>
<p>安装Mysql</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install mysql-server
</pre>
<p>其他模块安装：</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install libapache2-mod-php5
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo apt-get install php5-gd
</pre>
<p>开启rewrite伪静态模块</p>
<pre class="brush: plain; title: ; notranslate">
sudo a2enmpd rewrite
</pre>
<p>该要的组件都有了就开始配置站点环境了，由于是ubuntu系统，创建步骤可能与他人不一样，直接显示shell命令吧，图就不来了。</p>
<pre class="brush: plain; title: ; notranslate">
cd /etc/apache2/sites-available
cp default web
vim web
</pre>
<p>web文件内容如下:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;VirtualHost *:80&gt;
#需要绑定的域名
ServerName www.tieyou.com
ServerAlias demo.tieyou.com
#管理员邮箱
ServerAdmin hkshadow@demo.com
#网站目录
DocumentRoot &quot;/var/webwork/tieyou/&quot;
#该网站的错误日志
ErrorLog &quot;/var/weblog/tieyou/t.tieyou.com.errors.log&quot;
#该网站的配置日志(如访问)
CustomLog &quot;/var/weblog/tieyou/t.tieyou.com_accesses.log&quot; common
&lt;/VirtualHost&gt;
</pre>
<p>然后退出vim编辑器，生成刚刚创建的站点配置，执行以下命令：</p>
<pre class="brush: plain; title: ; notranslate">
sudo a2ensite web
</pre>
<p>然后重启apache2即可生效(再增加站点同理)：</p>
<pre class="brush: plain; title: ; notranslate">
sudo /etc/init.d/apache2 restart
</pre>
<p>在Ubuntu上装完Apache后，每次启动apache服务器都会得到如下警告：<br />
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName</p>
<p>注意httpd.conf默认是个空文件<br />
解决方法：</p>
<pre class="brush: plain; title: ; notranslate">
cd /etc/apache2
vi httpd.conf
</pre>
<p>加入以下代码</p>
<pre class="brush: plain; title: ; notranslate">
ServerName localhost
</pre>
<p>配置好web站点以后，以为一切OK，结果发现不是那样的。各种警告迎刃而来。<br />
<strong>php运行时报Use of undefined constant。</strong><br />
解决方法可在php.ini里搜索</p>
<pre class="brush: plain; title: ; notranslate">
vim /etc/php5/apache2/php.ini
</pre>
<p>在文件里搜索：</p>
<pre class="brush: plain; title: ; notranslate">
error_reporting = E_ALL &amp; ~E_DEPRECATED
</pre>
<p>在入口php文件增加error_reporting(0)就可彻底解决这个呕血问题。</p>
<p><strong>有关error_reporting()函数：</strong><br />
error_reporting() 设置 PHP 的报错级别并返回当前级别。</p>
<pre class="brush: plain; title: ; notranslate">
; 错误报告是按位的。或者将数字加起来得到想要的错误报告等级。  
; E_ALL - 所有的错误和警告  
; E_ERROR - 致命性运行时错  
; E_WARNING - 运行时警告（非致命性错）  
; E_PARSE - 编译时解析错误  
; E_NOTICE - 运行时提醒(这些经常是是你的代码的bug引起的，  

;也可能是有意的行为造成的。(如：基于未初始化的变量自动初始化为一个  
　　　　　　　　　　　　　　;空字符串的事实而使用一个未初始化的变量)  

; E_CORE_ERROR - 发生于PHP启动时初始化过程中的致命错误  
; E_CORE_WARNING - 发生于PHP启动时初始化过程中的警告(非致命性错)  
; E_COMPILE_ERROR - 编译时致命性错  
; E_COMPILE_WARNING - 编译时警告(非致命性错)  
; E_USER_ERROR - 用户产生的出错消息  
; E_USER_WARNING - 用户产生的警告消息  
; E_USER_NOTICE - 用户产生的提醒消息  
</pre>
<p>由此可见，开发环境和最终运行环境最好是一样，不然很多悲催的事情发生，需要亡数次修改和调试。到此，开发环境就绪。</p>
<p>附：<br />
perl: warning: Setting locale failed.<br />
perl: warning: Please check that your locale settings:<br />
        LANGUAGE = &#8220;zh_CN:zh&#8221;,<br />
        LC_ALL = (unset),<br />
        LC_PAPER = &#8220;zh_CN&#8221;,<br />
        LC_ADDRESS = &#8220;zh_CN&#8221;,<br />
        LC_MONETARY = &#8220;zh_CN&#8221;,<br />
        LC_NUMERIC = &#8220;zh_CN&#8221;,<br />
        LC_TELEPHONE = &#8220;zh_CN&#8221;,<br />
        LC_IDENTIFICATION = &#8220;zh_CN&#8221;,<br />
        LC_MEASUREMENT = &#8220;zh_CN&#8221;,<br />
        LC_TIME = &#8220;zh_CN&#8221;,<br />
        LC_NAME = &#8220;zh_CN&#8221;,<br />
        LANG = &#8220;zh_CN.UTF-8&#8221;<br />
    are supported and installed on your system.<br />
perl: warning: Falling back to the standard locale (&#8220;C&#8221;).<br />
解决办法：<br />
append following settings in the end of /home/your-login/.bashrc</p>
<pre class="brush: plain; title: ; notranslate">
vi /root/.bashrc
</pre>
<p>再最底部加上</p>
<pre class="brush: plain; title: ; notranslate">
export LANG=en_US:zh_CN.UTF-8
export LC_ALL=C
</pre>
<p>然后执行一下：</p>
<pre class="brush: plain; title: ; notranslate">
source /root/.bashrc 
</pre>
<p>看问题描述，似乎是locale的问题，但从解决办法来看似乎与locale没什么关系。。。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
