Lighttpd + PHP (FAST-CGI) + MySQL learning Notes

Source: Internet
Author: User
Lighttpd + PHP (FAST-CGI) + MySQL study notes, read lighttpd + PHP (FAST-CGI) + MySQL study notes, I have heard that lighttpd and PHP FAST-CGI mode good performance, time-consuming installation. the installation of the environment is complete, and performance is not detailed yet! Below is my installation of lighttpd + PHP (FAST-CGI) +


I have heard that lighttpd and PHP FAST-CGI method performance is good, take the time to install. Just completed the installation of the environment, not specific to see what performance!

The following is my installation of lighttpd + PHP (FAST-CGI) + mysql, if you have any questions, please comment on me.

 

1. Install MySQL first

Install mysql. You can install the source code package or compile it! Directly decompress and copy the file. I used to directly copy and compile the file!

1. Compile the source code package

./Configure -- prefix =/data2/ali -- enable-validator -- enable-thread-safe-client -- without-debug

Make

Make install

2. Use the compiled compressed package! Directly decompress and copy

Tar zxf mysql-standard-5.0.27-linux-i686-glibc23.tar.gz

Cd mysql-standard-5.0.27-linux-i686-glibc23

Cps-rf mysql-standard-5.0.27-linux-i686-glibc23/usr/local/mysql


// The following is to start multiple ports

Mkdir-p/data2/ali/mysql3308

Mkdir-p/data2/ali/mysql3309

./Scripts/mysql_install_db -- ldata =/data2/ali/mysql3308

Cpsupport-files/my-medium.cnf/data2/ali/mysql3308/my. cnf

Vi/data2/ali/mysql3308/my. cnf

The modification content is as follows:

#

[Mysqld]

Datadir =/data2/ali/mysql3308/

Port = 3308

Socket =/tmp/mysql-3308.sock

#


Cp/data2/ali/mysql3308 // data2/ali/mysql3309/

Vi/data2/ali/mysql3309/my. cnf

The modification content is as follows:

#

[Mysqld]

Datadir =/data2/ali/mysql3309/

Port = 3309

Socket =/tmp/mysql-3309.sock

#

Start mysql

/Usr/local/mysql/bin/mysqld_safe -- defaults-file =/data2/ali/mysql3308/my. cnf -- user = root &

/Usr/local/mysql/bin/mysqld_safe -- defaults-file =/data2/ali/mysql3309/my. cnf -- user = root &


Check whether mysql is successfully started.

Ps-ax | grep mysql

20835 pts/3 S/bin/sh./mysqld_safe -- defaults-file =/data2/ali/mysql3308/my. cnf -- user = root

20862 pts/3 Sl/usr/local/mysql/bin/mysqld -- defaults-file =/data2/ali/mysql3308/my. cnf -- basedir =/usr/local/mysql -- datadir =/data2/ali/mysql3308/-- user = root -- pid-file =/data2/ali/mysql3308 // XD_Blog_Web_132_42.pid -- skip -external-locking -- port = 3308 -- socket =/tmp/mysql-3308.sock

20872 pts/3 S/bin/sh./mysqld_safe -- defaults-file =/data2/ali/mysql3309/my. cnf -- user = root

20903 pts/3 Sl/usr/local/mysql/bin/mysqld -- defaults-file =/data2/ali/mysql3309/my. cnf -- basedir =/usr/local/mysql -- datadir =/data2/ali/mysql3309/-- user = root -- pid-file =/data2/ali/mysql3309 // XD_Blog_Web_132_42.pid -- skip -external-locking -- port = 3309 -- socket =/tmp/mysql-3309.sock


Connect to mysql

Mysql-S/tmp/mysql-3108.sock

 


II. Install 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

Make

Make install


Copy the parameter file to the target Directory:

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


Run the following command to check whether fast-cgi is successfully installed:

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

The following information is displayed. "PHP 5.2.4 (cgi-fcgi)" indicates that fast-cgi is supported.

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

 

3. Install lighttpd

1. Install and configure lighttpd


1.1 Create a user and group that runs lighttpd


# Groupadd lighttpd

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


1.2 Start lighttpd installation


# Wget

# 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


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

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

 


Vi conf/lighttpd. conf

Remove # of "mod_fastcgi"

Server. modules = (

"Mod_rewrite ",

"Mod_redirect ",

# "Mod_alias ",

"Mod_access ",

# "Maid ",

# "Mod_trigger_b4_dl ",

# "Mod_auth ",

# "Mod_status ",

# "Mod_setenv ",

"Mod_fastcgi ",


Find the definition of 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"

)

)

)


At first, I wrote the configuration "bin-path" => "/usr/local/php-fcgi/bin/php". Then I found an error and changed the above configuration, OK!

The following command is used to start lighttpd:

/Usr/local/lighttpd/sbin/lighttpd-f conf/lighttpd. conf


Finally, you can create test. php in the program directory and check whether it is normal!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.