日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Ubuntu >内容正文

Ubuntu

Ubuntu 12.10下配置Web服务器详细教程

發布時間:2025/4/16 Ubuntu 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ubuntu 12.10下配置Web服务器详细教程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

搭建Ubuntu的Web服務器?無疑是目前非常熱門的技術。下面我們來看一下如何在Ubuntu下搭建大家熟悉的Web服務器。

Linux在服務器領域表現卻尤為喜人,據IDC數據顯示,部署了Linux系統的服務器占到20%的市場份額。其中Red Hat和Ubuntu在服務器市場表現搶眼,由它們搭建的Web服務器在企業中應用最為廣泛。

同時,Ubuntu創始人表示近年來Ubuntu形式已經開始逆轉,從2011年開始采用Ubuntu作為網頁服務器的用戶比RHEL更多,Ubuntu 在企業市場正不斷擴張,相反RHEL卻呈現下跌傾向。無疑Ubuntu有如此強勢表現離不開其在Web服務器上的應用。而搭建Ubuntu的Web服務器 無疑是目前非常熱門的技術。下面我們來看一下如何在Ubuntu下搭建大家熟悉的Web服務器。

?

Ubuntu 11.10是目前官方發布的最新的正式版本,其在用戶界面和內核架構等方面都有較大改善,是非常受歡迎的一個版本,下面這里給大家介紹一下如何在 Ubuntu 11.10下與Apache 2、PHP5、MySQL搭建Web服務器,希望與大家一同探討用Ubuntu搭建Web服務器的優缺點。

1.開始說明

首先需要跟大家說明一下,這個教程中使用的IP地址是192.168.0.23,主機名稱為Server1.example.com這些設置可能會有所不同,你需要根據不同情況進行修改。

Ubuntu 查看版本命令?,在終端中執行下列指令:?

?

  cat /etc/issue?

安裝Apache2

2.切換管理員身份

在Ubuntu中需要用root身份進行操作,所以用下面的命令確保以root身份登錄:

sudo su

3.開始安裝MySQL5

apt-get install?mysql-server?mysql-client

你將被要求提供一個MySQL的root用戶的密碼,我們需要在紅色區域設置密碼。

New password?for the MySQL "root" user:?<-- yourrootsqlpassword

Repeat password?for the MySQL "root" user:?<-- yourrootsqlpassword

4.安裝Apache2

Apache2的是作為一個Ubuntu的軟件包,因此我們可以直接用下面命令安裝它:

apt-get install apache2

現在,您的瀏覽器到http://192.168.0.23,你應該看到Apache2的測試頁:

?

Apache 2首頁

Apache的默認文檔根目錄是在Ubuntu上的/var/www目錄 ,配置文件是/ etc/apache2/apache2.conf。配置存儲在的子目錄在/etc/apache2目錄。

安裝PHP5

5.安裝PHP5

我們可以直接安裝PHP5和Apache的PHP5的模塊,如下:

apt-get install php5 libapache2-mod-php5

安裝完需要重啟

/etc/init.d/apache2 restart

?

6.測試的PHP5并獲取PHP5安裝的詳細信息:

默認網站的文件根目錄是在/var/www下中。現在我們將在該目錄中創建一個小型PHP文件(info.php的)在瀏覽器中調用它。該文件將顯示很多關于我們的PHP安裝,如安裝的PHP版本和有用的一些細節。

gedit /var/www/info.php

<?php
phpinfo();
?php>

?

顯示代碼

現在,我們可以用瀏覽器訪問例如http://192.168.0.23/info.php文件

PHP頁面

正如你所看到的,PHP5正常工作,它通過Apache 2.0的處理程序,在服務器API線。如果你繼續向下滾動,你會看到所有在PHP5中已經啟用的模塊。MySQL是沒有列出,這意味著我們沒有在PHP5支持MySQL。

7.PHP5獲得MySOL的支持

讓PHP在MySQL中獲得支持,我們可以安裝的php-mysql軟件包。安裝一些其他的PHP5模塊,以及您可能需要的應用程序,這是一個好主意:

apt-cache search php5

還安裝需要安裝的

apt-get install php5-mysql?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

現在重新啟動Apache2的:

/etc/init.d/apache2 restart

現在,重載http://192.168.0.23/info.php在您的瀏覽器,并再次向下滾動到模塊部分。現在,你應該找到許多新的模塊,包括MySQL模塊:

?

PHP支持

安裝phpMyAdmin

8.安裝phpMyAdmin

phpMyAdmin是一個網絡接口,通過它可以管理你的MySQL數據庫。

apt-get install phpmyadmin?

你會看到以下問題:

Web server to reconfigure automatically:?<-- apache2

Configure database for phpmyadmin with dbconfig-common??<-- No

在地址欄輸入http://192.168.0.100/phpMyAdmin/:你就可以訪問phpMyAdmin了。

錯誤1

我試的地址是http://127.0.0.1/phpMyAdmin/,php和mysql正常,但phpmyadmin

出現下面的請況,

Not Found

The requested URL /phpMyAdmin was not found on this server.

解決辦法:試一下http://localhost/phpmyadmin/,如可以的話請留言,還不行的話,則需要做/usr/share/phpmyadmin/個的軟連接到/var/www目錄下:?

ln -s /usr/share/phpmyadmin/ /var/www/

最后在瀏覽器中輸入:http://localhost/phpmyadmin/

成功后會進入登錄界面

?

9、安裝lighttpd的過錯中出現的問題和解決方法

apt-get install lighttpd

?

從配置文件啟動,輸入指令

?

1 sudo lighttpd -f /etc/lighttpd/lighttpd.conf

?

? ? ?我的機器上提示 ?2013-01-13 14:36:08: (network.c.379) can't bind to port: ?80 Address already in use?

? ? ?我的80端口被Apache服務器占用了,所以我們要修改配置文件

gedit /etc/lighttpd/lighttpd.conf

? ? ? 加上

? ? server.port ? ? ? ? ? ? ? ?= 8090 ?##設置端口

? ?保存退出 ,輸入指令

1 sudo lighttpd -f /etc/lighttpd/lighttpd.conf

? 啟動 lighttpd 服務器

? 瀏覽器中輸入

???localhost:8080? ?/默認訪問的是 /var/www/ 目錄

?gedit /etc/lighttpd/lighttpd.conf

?

?

sudo lighttpd -f /etc/lighttpd/lighttpd.conf

? 安裝Lighttpd
Lighttpd是一個Ubuntu包,因此我們可以這樣安裝它:
Aptitude install lighttpd
在瀏覽器輸入你的本機IP就可以看到Lighttpd的頁面了。
在ubuntu中,Lighttpd的文件根目錄默認是在/var/www,配置文件是在/etc/lighttpd/lighttpd.conf。額外的配置文件存儲在/etc/lighttpd/conf-available目錄,可以用lighttpd-enable-mod啟用,也可以用lighttpd-disable-mod禁用。

3、? 安裝php5
我們使php5通過FastCGI工作在Lighttpd下。Ubuntu提供了一個這樣的包:
Aptitude install php5-cgi

4、? 配置Lighttpd和php5
為了在Lighttpd中啟用php5,必須修改在/etc/php5/cgi/php.ini配置文件下添加一行:
Cgi.fix_pathinfo=1
要啟用fastcgi(存放在/etc/lighttpd/conf-available/10-fastcgi.conf)運行下面的命令:
Lighttpd-enable-mod fastcgi
然后創建一個鏈接/etc/lighttpd/conf-enables/10-fastcgi.conf指向/etc/lighttpd/conf-available/10-fastcgi.conf

sudo ln -s /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/10-fastcgi.conf
再重新加載Lighttpd:
/etc/init.d/lighttpd force-reload

安裝完畢

上面就是搭建Web服務器的整個步驟,Ubuntu搭建起來相對更容易一些,而且由Ubuntu搭建的Web服務器應用也非常廣泛,大家可以按照步驟自己大家來看看,非常簡單。

錯誤2

Ubuntu下Apache重啟出現錯誤提示:Could not reliably determin

Linuxidc.com@Ubuntu

錯誤信息:
* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

解決方法:
sudo gedit /etc/apache2/apache2.conf

在文件后面加上:
#Server Name
ServerName 127.0.0.1

錯誤3

/etc/init.d/apache2 restart
?* Restarting web server apache2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

解決辦法:不要用sudo?/etc/init.d/apache2 restart 和?service apache2 restart ?改用?sudo?/etc/init.d/apache2 restart ? 和 ?sudo?service apache2 restart

403 forbidden

問題:

按照?http://wiki.ubuntu.org.cn/Lighttpd?的說明裝好Lighttpd并啟動之后,在訪問php頁面的時候,提示403 forbidden,html頁面正常。

解決

這個403錯誤其實是誤報,并非沒有權限訪問php文件,而是沒有權限訪問php-cgi模塊。

Lighttpd安裝后,默認只啟用了一個mod,就是fastcgi,但沒有啟用php支持。必須手動啟用fastcgi-php模塊才支持php訪問:

?View Code?BASH

1 2 lighty-enable-mod fastcgi-php service lighttpd force-reload

Ubuntu英文官方Wiki說得很清楚:?https://wiki.ubuntu.com/Lighttpd+PHP。

啟用PHP-FPM

問題

按照上面的方式啟用的php運行在fast-cgi模式。如何啟用PHP-FPM?

解決

建立?/etc/lighttpd/conf-availeable/10-fastcgi-fpm.conf?文件,寫入如下內容:

?View Code?BASH

1 2 3 4 5 6 7 server.modules += ("mod_fastcgi") fastcgi.server = ( ".php" =>(("host" => "127.0.0.1","port" => "9000")) )

禁用fastcgi模塊和fastcgi的php支持,使用剛才建立的?fastcgi-fpm?模塊同時支持兩者。

?View Code?BASH

1 2 3 4 lighty-disable-mod fastcgi lighty-disable-mod fastcgi-php lighty-enable-mod fastcgi-fpm service lighttpd force-reload

查看phpinfo,可以看到已經是FPM支持了:

參考文獻:

Ubuntu12.10下安裝lighttpd1.4.32詳細步驟Ubuntu 9.10下安裝Lighttpd支持PHP和MySQL

從Apache到Lighttpd

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的Ubuntu 12.10下配置Web服务器详细教程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。