<?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>绿色记忆 &#187; 容器化</title>
	<atom:link href="https://blog.gmem.cc/tag/%e5%ae%b9%e5%99%a8%e5%8c%96/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.gmem.cc</link>
	<description></description>
	<lastBuildDate>Fri, 03 Apr 2026 04:13:36 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.14</generator>
	<item>
		<title>Ubuntu下安装PHP</title>
		<link>https://blog.gmem.cc/php-under-ubuntu</link>
		<comments>https://blog.gmem.cc/php-under-ubuntu#comments</comments>
		<pubDate>Tue, 27 Dec 2011 13:00:10 +0000</pubDate>
		<dc:creator><![CDATA[Alex]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XDebug]]></category>
		<category><![CDATA[容器化]]></category>

		<guid isPermaLink="false">http://blog.gmem.cc/?p=1184</guid>
		<description><![CDATA[<p>PHP5安装 安装必要的软件： [crayon-69d2aa1e2aad1041547070/] 修改配置： 注意：Web服务器下编写info.php可以获知php.ini位置 [crayon-69d2aa1e2aad8272899244/] XDebug安装 安装必要的软件： [crayon-69d2aa1e2aadb482908128/] 修改配置文件：  [crayon-69d2aa1e2aadd801707658/] 重启Apache服务 [crayon-69d2aa1e2aae0518119787/] 现在调试客户端可以连接并进行调试了，需要注意的是，服务器必须能够连接到调试客户端。在调试位于外网服务器的PHP页面时，处于内网的调试客户端可能无法被直接访问，这时候最简单的方式就是使用VPN连接到服务器，上面的xdebug.remote_host填写VPN连接分配给客户端的IP地址即可。  调试完毕后，可以关闭xdebug模块： [crayon-69d2aa1e2aae2069350817/] 验证XDebug正常工作 可以执行[crayon-69d2aa1e2aae4564491449-i/]命令，如果输出： [crayon-69d2aa1e2aae6165505281/]  说明XDebug正常加载。如果输出： [crayon-69d2aa1e2aae9813014931/] 说明PHP引擎和XDebug的版本不兼容。 <a class="read-more" href="https://blog.gmem.cc/php-under-ubuntu">[...]</a></p>
<p>The post <a rel="nofollow" href="https://blog.gmem.cc/php-under-ubuntu">Ubuntu下安装PHP</a> appeared first on <a rel="nofollow" href="https://blog.gmem.cc">绿色记忆</a>.</p>
]]></description>
				<content:encoded><![CDATA[<div class="wri_content_clear_both"><div class="blog_h2"><span class="graybg">PHP5安装</span></div>
<p>安装必要的软件：</p>
<pre class="crayon-plain-tag">sudo apt-get install php5-cgi</pre>
<p>修改配置：</p>
<p>注意：Web服务器下编写info.php可以获知php.ini位置</p>
<pre class="crayon-plain-tag">vim /etc/php5/apache2/php.ini 
#根据需要修改以下内容：
#最大上传文件的大小
upload_max_filesize = 20M 
#错误报告相关配置
error_reporting = E_ALL
display_errors = On
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
error_log = /var/log/php_errors.log
ignore_repeated_errors = Off
report_memleaks = On
track_errors = On</pre>
<div class="blog_h2"><span class="graybg">XDebug安装</span></div>
<p>安装必要的软件：</p>
<pre class="crayon-plain-tag"># 安装XDebug
apt-get install php5-xdebug

# 上述安装方法，有可能安装不匹配的XDebug版本，你可以使用PHP提供的扩展管理器PECL来安装，确保版本兼容：
# 要使用PECL，必须安装PHP的开发版本 sudo apt-get install php5-dev
# 安装PHP5最新稳定版本的XDebug
sudo pecl install php5-xdebug

# 启用PHP模块
php5enmod xdebug</pre>
<p>修改配置文件： </p>
<pre class="crayon-plain-tag">#下面这一行不要忘记
[XDebug]
xdebug.remote_autostart = 0

zend_extension="/usr/lib/php5/20121212/xdebug.so"
#禁用性能剖析
xdebug.profiler_enable = 0
#启用远程调试
xdebug.remote_enable = 1
#调试客户端IP地址或者主机名
xdebug.remote_host = 172.21.0.100
#调试客户端的监听端口
xdebug.remote_port = 9000
#是否启用回连，即由服务器主动连接调试客户端，服务器通过检查HTTP请求得知客户端的IP
#启用该选项时xdebug.remote_host无意义
xdebug.remote_connect_back = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
#所有的远程调试连接都会被记录到该日志
xdebug.remote_log = /var/log/xdebug.log</pre>
<div class="blog_h3"><span class="graybg">重启Apache服务</span></div>
<pre class="crayon-plain-tag">service apache2 restart</pre>
<p>现在调试客户端可以连接并进行调试了，需要注意的是，服务器必须能够连接到调试客户端。在调试位于外网服务器的PHP页面时，处于内网的调试客户端可能无法被直接访问，这时候最简单的方式就是使用VPN连接到服务器，上面的xdebug.remote_host填写VPN连接分配给客户端的IP地址即可。 </p>
<p>调试完毕后，可以关闭xdebug模块：</p>
<pre class="crayon-plain-tag">php5dismod xdebug

#在我的服务器上测试，即使禁用仍然对Apache2的性能产生影响，因此可以删除，需要的时候重新安装
apt-get remove php5-xdebug</pre>
<div class="blog_h3"><span class="graybg">验证XDebug正常工作</span></div>
<p>可以执行<pre class="crayon-plain-tag">php -v</pre>命令，如果输出：</p>
<pre class="crayon-plain-tag">PHP 5.6.30 (cli) (built: Feb 28 2017 17:33:47) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans</pre>
<p> 说明XDebug正常加载。如果输出：</p>
<pre class="crayon-plain-tag">Xdebug requires Zend Engine API version 220121212.
The Zend Engine API version 220131226 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org/docs/faq#api for a later version of Xdebug.</pre>
<p>说明PHP引擎和XDebug的版本不兼容。</p>
<p>也可以通过phpinfo来验证，正常加载时，页面存在以下内容：</p>
<p><img class="aligncenter size-full wp-image-15104" src="https://blog.gmem.cc/wp-content/uploads/2011/12/phpinfo-xdebug.png" alt="phpinfo-xdebug" width="100%" /></p>
<div class="blog_h2"><span class="graybg">PHP7安装</span></div>
<pre class="crayon-plain-tag"># 独立构建并安装，避免影响系统既有PHP版本
tar xf php-7.0.6.tar.bz2
cd php-7.0.6
# 设置安装目录
./configure --prefix=/home/alex/PHP/7.0.6
make &amp;&amp; make install</pre>
<p>构建并安装XDebug：</p>
<pre class="crayon-plain-tag"># 安装XDebug
/home/alex/PHP/7.0.6/bin/php -i &gt; php7.txt
# 把输出拿到https://xdebug.org/wizard.php分析，该网站会显示如何构建XDebug
tar -xvzf xdebug-2.4.0.tgz
cd xdebug-2.4.0
/home/alex/PHP/7.0.6/bin/phpize
./configure --with-php-config=/home/alex/PHP/7.0.6/bin/php-config
make
cp modules/xdebug.so /home/alex/PHP/7.0.6/lib/php/extensions/no-debug-non-zts-20151012</pre>
<p>修改 /home/alex/PHP/7.0.6/lib/php.ini，添加：</p>
<pre class="crayon-plain-tag">[XDebug]
xdebug.remote_autostart = 0
zend_extension = /home/alex/PHP/7.0.6/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
xdebug.profiler_enable = 0
xdebug.remote_enable = 1
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_connect_back = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_log = /home/alex/PHP/7.0.6/var/log/xdebug.log</pre>
<div class="blog_h2"><span class="graybg">容器化</span></div>
<div class="blog_h3"><span class="graybg">PHP5+Apache2</span></div>
<p>参考：<a href="/apache2-under-ubuntu#containerization">Ubuntu下安装Apache2服务器</a></p>
<div class="blog_h2"><span class="graybg">常见问题</span></div>
<div class="blog_h3"><span class="graybg">PHP Fatal error: Call to undefined function curl_init()</span></div>
<p>more /var/log/apache2/error.log，发现错误该错误，原因：未安装CURL支持，解决方式：</p>
<pre class="crayon-plain-tag">apt-get install php5-curl
service apache2 restart</pre>
<p>&nbsp;</p>
</div><p>The post <a rel="nofollow" href="https://blog.gmem.cc/php-under-ubuntu">Ubuntu下安装PHP</a> appeared first on <a rel="nofollow" href="https://blog.gmem.cc">绿色记忆</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.gmem.cc/php-under-ubuntu/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
