Lighttpd+php+sqlite built under Fedora Linux platform

Source: Internet
Author: User
(a) lighttpd

1. Installation

Yum Install lighttpd

After the installation is complete, there should be one more user lighttpd and group lighttpd in the system. This user is not allowed to log on by default.

We modify the/etc/passwd to change the lighttpd to the following form.

LIGHTTPD:X:489:470:LIGHTTPD Web Server:/home/lighttpd/:/bin/bash

Note that the number you see may not be 489,470, this is OK, do not change, keep the original value.


2. Create a directory for LIGHTTPD users to put the content of the site in

Mkdir/home/lighttpd

Chown LIGHTTPD:LIGHTTPD/HOME/LIGHTTPD

Create the relevant subdirectory and put the contents of the site.

Note that the/home/lighttpd is done in the LIGHTTPD directory with the LIGHTTPD user's identity. Otherwise, the LIGHTTPD runtime may have permissions issues.

Su lighttpd

Cd/home/lighttpd

mkdir www

mkdir Www/cgi-bin

mkdir www/databases

mkdir www/images

mkdir Www/log

OK, now you can put content in various directories, Web pages, images, PHP scripts, SQLite database files and so on.

The index.html is placed in the WWW directory.


3. Configuration

Modify the LIGHTTPD configuration file/etc/lighttpd/lighttpd.conf

A) Turn on the CGI feature

Of course, you can also open other functions as needed. I modified the server.modules as follows.

Server.modules = (
"Mod_rewrite",
"Mod_redirect",
# "Mod_alias",
"Mod_access",
# "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")

b) The default file name

The default.xxx is also added here.

Index-file.names = ("index.php", "index.html",
"Index.htm", "default.htm", "default.php")


c) Set some paths

Server.document-root = "/home/lighttpd/www/"

# # Where to send Error-messages to
Server.errorlog = "/home/lighttpd/www/log/error.log"

Accesslog.filename = "/home/lighttpd/www/log/access.log"


# # # # # # # of PHP parser paths Plus
Cgi.assign = (". pl" = "/usr/bin/perl",
". php" = "/usr/bin/php")


4. Start LIGHTTPD

Service LIGHTTPD Start


5. Set LIGHTTPD boot automatically

Chkconfig--add lighttpd


(ii) SQLite

This simple, directly installed on the line.

Yum Install SQLite


(c) php

1. Compiling and installing

Download PHP Source Package

http://ar2.php.net/distributions/php-5.6.3.tar.bz2

Copy the source package to the/root directory

Then go to the/root directory and execute the following command sequence

TAR-XJF php-5.6.3.tar.bz2

CD php-5.6.3

./configure--prefix=/usr--with-config-file-path=/etc--enable-libxml--with-libxml-dir=/usr/lib--with-sqlite3-- Enable-pdo--with-pdo-sqlite Clags=-o2

Make Make install


It is important to note that this method of compiling supports access to sqlite3 in the form of PDO. This way, there is no need to rely on any extension


(iv) Testing

A

With lighttpd users, go to the/home/lighttpd/www/databases directory and create a database

[Lighttpd@localhost databases]$ sqlite3 test.db
SQLite version 3.6.22
Enter '. Help ' for instructions
Enter SQL statements terminated with a ";"
Sqlite> CREATE TABLE My_friends (name varchar (ten), age smallint);
sqlite> INSERT into my_friends values (' Tom ', 22);
sqlite> INSERT into my_friends values (' Liyan ', 21);

Input Ctrl+d Exit SQLite shell


b) With lighttpd users, go to the Cig-bin directory and create a PHP script haha.php, which reads as follows:





Phpinfo ();
echo "Hello my first php script \ n";
Echo GETCWD ();


$file _db = new PDO (' SQLite:.. /databases/test.db ');
$result = $file _db->query (' SELECT * from My_friends ');


foreach ($result as $row)
{
echo "Name:". $row [' name ']. " ";
}


?>







c) Use a browser to access the haha.php to see the effect:)

http://ip_of_lighttpd/cgi-bin/haha.php


If you are having trouble debugging a PHP program, you can open/etc/php.ini and set the following to open the error function of PHP:

error_reporting = E_all & ~e_notice

Display_errors = On

  • Related Article

    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.