lighttpd+mysql+php

來源:互聯網
上載者:User
部落格已經搬家,請訪問如下地址:http://www.czhphp.com

一:安裝mysql

下載:wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.1.33.zip

安裝:

unzip mysql-5.1.33.zip

cd mysql-5.1.33.zip

./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase
make
make install
useradd mysql -d /data/mysql -s/sbin/nologin
/usr/local/mysql/bin/mysql_install_db--user=mysql
cd /usr/local/mysql
chown -R root:mysql .
mkdir -p /data/mysql/data
chown -R mysql /data/mysql/data
cp share/mysql/my-huge.cnf /etc/my.cnf
cp share/mysql/mysql.server/etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysql

service mysqld start

當重新啟動時候總 報以下錯誤:

ERROR! MySQL manager or server PID file could not be found!

Starting MySQL. ERROR! Manager of pid-file quit without updating file.

解決辦法:

MySQL編譯安裝,初始化資料庫的時候出現:
unknown option '--skip-federated' 錯誤。

#vi /etc/my.cnf
#skip-federated 將此行注釋掉即可。或者編譯的時候加上如下參數:--with-plugins=all

如果還是不行的話那麼就是因為您在配置的時候沒有添加datadir,

#vi /etc/my.cnf

添加以下語句:

[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir = /usr/local/mysql/data
datadir是新加的

二、接著安裝php

tar zxf php-5.2.4.tar.gz

cd php-5.2.4

./configure --prefix=/usr/local/php-fcgi --enable-fastcgi --enable-force-cgi-redirect --without-iconv --enable-mbstring --with-mysql=/usr/local/mysql

注意:php安裝的過程中也許會報以下錯誤

collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1

解決辦法:

請安裝lib所需的安裝包

yum install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel pam-devel kernel

執行安裝完以後即可解決問題

make

make install


複製參數檔案到目標目錄:

cp php.ini-dist /usr/local/php-fcgi/lib/php.ini

檢查fast-cgi是否安裝成功可以運行如下命令

/usr/local/php-fcgi/bin/php-cgi -v

顯示如下資訊,內容裡包含“PHP 5.2.4 (cgi-fcgi)"表示支援fast-cgi了

PHP 5.2.4 (cgi-fcgi) (built: Oct 28 2007 20:08:41)

Copyright (c) 1997-2007 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

早就聽說lighttpd加PHP的FAST-CGI方式效能不錯,抽時間裝了下.只是完成了環境的安裝,還沒具體看效能什麼的!

以下是我裝lighttpd+PHP(FAST-CGI)+mysql的,如有問題,請給我評論.

三、最後安裝lighttpd

1.安裝配置lighttpd

1.1 首先建立運行lighttpd的使用者和組

# groupadd lighttpd

# useradd -g lighttpd -s /sbin/nologin -d /dev/null lighttpd

1.2 開始安裝lighttpd

# wget http://www.lighttpd.net/download/lighttpd-1.4.8.tar.gz

# tar -zxvf lighttpd-1.4.8.tar.gz

# cd lighttpd-1.4.8

# ./configure --prefix=/usr/local/lighttpd

# make

# make install

# mkdir /usr/local/lighttpd/conf

# mkdir /usr/local/lighttpd/log

# mkdir /usr/local/lighttpd/htdocs

# mv ./doc/lighttpd.conf /usr/local/lighttpd/conf/

# cp ./doc/rc.lighttpd.redhat /etc/init.d/lighttpd

vi conf/lighttpd.conf

將 #”mod_fastcgi”, 的#去掉

server.modules = (
"mod_rewrite",
"mod_redirect",
"mod_alias",
"mod_access",
"mod_cml",
"mod_trigger_b4_dl",
"mod_auth",
"mod_status",
"mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
"mod_evhost",
# "mod_userdir",
# "mod_cgi",
# "mod_compress",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_secdownload",
# "mod_rrdtool",
"mod_accesslog" )

## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = "/usr/local/lighttpd/htdocs/"

## where to send error-messages to
server.errorlog = "/usr/local/lighttpd/log/lighttpd/error.log"

找到fastcgi的定義

#### fastcgi module

## read fastcgi.txt for more info

## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini

fastcgi.server = ( ".php" =>

( "localhost" =>

( "socket" => "/var/run/lighttpd/php-fastcgi.socket",

"bin-path" => "/usr/local/php-fcgi/bin/php-cgi" )

)

)

/var/run/lighttpd 該目錄需要建立如果沒有的話
一開始我把配置寫"bin-path" => "/usr/local/php-fcgi/bin/php"這樣,發現報錯,後來改了下以上的配置,發現OK了!

啟動lighttpd命令是這樣的:

chown -R lighttpd:lighttpd /usr/local/lighttpd

service lighttpd restart

PHP FastCGI環境測試 --

echo "" > /usr/local/lighttpd/htdocs/index.php

curl http://127.0.0.1/index.php

大概的安裝過程如上,有什麼問題請大家多多指教,歡迎大家留下寶貴意見,謝謝。

部落格已經搬家,請訪問如下地址:http://www.czhphp.com

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.