Ubuntu 11.0下配置Web服务器详细教程[ 图文]
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>近日,有消息爆出Linux桌面已经趋于“死亡”,众多Linux爱好者感到失望,但令人可喜的是Linux在<span class="hui14_line">服务器</span>领域表现却尤为喜人,据IDC数据显示,部署了Linux系统的<span class="hui14_line">服务器</span>占到20%的市场份额。其中Red Hat和Ubuntu在服务器市场表现抢眼,由它们搭建的Web服务器在企业中应用最为广泛。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
同时,Ubuntu创始人表示近年来Ubuntu形式已经开始逆转,从2011年开始采用Ubuntu作为网页服务器的用户比RHEL更多,Ubuntu 在企业市场正不断扩张,相反RHEL却呈现下跌倾向。无疑Ubuntu有如此强势表现离不开其在Web服务器上的应用。而搭建Ubuntu的Web服务器 无疑是目前非常热门的技术。下面我们来看一下如何在Ubuntu下搭建大家熟悉的Web服务器。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;'>
<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" alt="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" src="https://zhuji.jb51.net/uploads/img/202305/596d6ba0666fd05afc76a02c639855fe.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
Ubuntu 11.10是目前官方发布的最新的正式版本,其在用户界面和内核架构等方面都有较大改善,是非常受欢迎的一个版本,下面这里给大家介绍一下如何在 Ubuntu 11.10下与Apache 2、PHP5、MySQL搭建Web服务器,希望与大家一同探讨用Ubuntu搭建Web服务器的优缺点。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>1.开始说明</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
首先需要跟大家说明一下,这个教程中使用的IP地址是192.168.0.23,主机名称为Server1.example.com这些设置可能会有所不同,你需要根据不同情况进行修改。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>安装Apache2</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>2.切换管理员身份</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
在Ubuntu中需要用root身份进行操作,所以用下面的命令确保以root身份登录:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
sudo su</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>3.开始安装MySQL5</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
apt-get install <u>mysql</u>-server <u>mysql</u>-client</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
你将被要求提供一个MySQL的root用户的密码,我们需要在红色区域设置密码。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
New pass<u>word</u> for the MySQL "root" user: <span><-- yourrootsqlpass<u>word</u></span><br>
Repeat pass<u>word</u> for the MySQL "root" user: <span><-- yourrootsqlpass<u>word</u></span></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>4.安装Apache2</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
Apache2的是作为一个Ubuntu的软件包,因此我们可以直接用下面命令安装它:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
apt-get install apache2</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
现在,您的浏览器到http://192.168.0.23,你应该看到Apache2的测试页:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;'>
<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" alt="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" src="https://zhuji.jb51.net/uploads/img/202305/af669cd91a1078d74452659678299e80.jpg"><br><strong>Apache 2首页</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
Apache的默认文档根目录是在Ubuntu上的/var/www目录 ,配置文件是/ etc/apache2/apache2.conf。配置存储在的子目录在/etc/apache2目录。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>安装PHP5</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>5.安装PHP5</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
我们可以直接安装PHP5和Apache的PHP5的模块,如下:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
apt-get install php5 libapache2-mod-php5</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
安装完需要重启</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
/etc/init.d/apache2 restart</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>6.测试的PHP5并获取PHP5</strong><strong>安装的</strong><strong>详细信</strong><strong>息</strong><strong>:</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
默认网站的文件根目录是在/var/www下中。现在我们将在该目录中创建一个小型PHP文件(info.php的)在浏览器中调用它。该文件将显示很多关于我们的PHP安装,如安装的PHP版本和有用的一些细节。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
vi /var/www/info.php</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;'>
<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" alt="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" src="https://zhuji.jb51.net/uploads/img/202305/a3e7d52b97e7b7f9d89aac5737cb9372.jpg"><br><strong>显示代码</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
现在,我们可以用浏览器访问例如http://192.168.0.23/info.php文件</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;'>
<img style="max-width:100%!important;height:auto!important;"title="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" alt="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" src="https://zhuji.jb51.net/uploads/img/202305/9db0776e5c458dd8e9f89648fb876aea.jpg"><br><strong>PHP页面</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
正如你所看到的,PHP5正常工作,它通过Apache 2.0的处理程序,在<span class="hui14_line">服务器</span>API线。如果你继续向下滚动,你会看到所有在PHP5中已经启用的模块。MySQL是没有列出,这意味着我们没有在PHP5支持MySQL。</p>
<div class="ad4682" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; font-family: tahoma, arial, "Microsoft YaHei";'>
</div>
<div class="ad300" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; font-family: tahoma, arial, "Microsoft YaHei";'>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>7.PHP5获得MySOL的支持</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
让PHP在MySQL中获得支持,我们可以安装的php-<u>mysql</u>软件包。安装一些其他的PHP5模块,以及您可能需要的应用程序,这是一个好主意:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
apt-cache search php5</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
还安装需要安装的</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
apt-get install php5-<u>mysql</u> php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
现在重新启动Apache2的:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
/etc/init.d/apache2 restart</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
现在,重载http://192.168.0.23/info.php在您的浏览器,并再次向下滚动到模块部分。现在,你应该找到许多新的模块,包括MySQL模块:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;'>
<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" alt="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" src="https://zhuji.jb51.net/uploads/img/202305/19801837e8ed31a8ff87971f6e1c5266.jpg"><br><strong>PHP支持</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>安装phpMyAdmin</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>8.安装phpMyAdmin</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
phpMyAdmin是一个网络接口,通过它可以管理你的MySQL数据库。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
apt-get install phpmyadmin </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
你会看到以下问题:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
Web server to reconfigure automatically: <span><-- apache2</span><br>
Configure database for phpmyadmin with dbconfig-common? <span><-- No</span></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
在地址栏输入http://192.168.0.100/phpMyAdmin/:你就可以访问phpMyAdmin了。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;'>
<br><img style="max-width:100%!important;height:auto!important;"title="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" alt="Ubuntu 11.0下配置Web服务器详细教程[ 图文]" src="https://zhuji.jb51.net/uploads/img/202305/0559a0ee0ad89e14f5e721789331a9cf.jpg"><br><strong>安装完毕</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>9.相应软件下载地址:</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
●Apache: http://httpd.apache.org/<br>
●PHP: http://www.php.net/<br>
●MySQL: http://www.mysql.com/<br>
●Ubuntu: http://www.ubuntu.com/<br>
●phpMyAdmin: http://www.phpmyadmin.net/</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
上面就是搭建Web<span class="hui14_line">服务器</span>的整个步骤,相比与之前写过的openSUSE和CentOS两个发行版本,Ubuntu搭建起来相对更容易一些,而且由Ubuntu搭建的Web<span class="hui14_line">服务器</span>应用也非常广泛,大家可以按照步骤自己大家来看看,非常简单。</p>
頁:
[1]