lighttpd+php Installation

Source: Internet
Author: User
Tags chroot example fam imap syslog
Today made a small memory vps Apache too accounted for memory, decided to give up, the use of lighttpd from the Internet to find a lot of articles, finally installed successfully 1. Compile and install MySQL./configure--prefix=/srv/mysql-- Without-debug--with-extra-charsets=all--enable-assembler--with-pthread--enable-thread-safe-client-- With-client-ldflags=-all-static--localstatedir=/srv/mysql/data--with-unix-socket-path=/tmp/mysql.sock-- The remaining steps of the with-big-tables make make install are omitted .... 2. Install PHP phpcgi The beginning of the installation of the php5.3 version, and no matter how to adjust the compilation parameters can not be compiled into php-cgi give up, the use of 5.2, do not know that I did not add any parameters or what reason, if anyone know that I want to tell me the compilation parameters:. Configure--enable-gd-native-ttf--enable-gd-jis-conv--enable-xml--enable-mbstring--enable-soap--enable-bcmath-- With-mysql=/srv/mysql--with-gd--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-ldap-- Enable-ftp--with-kerberos--with-bz2--enable-calendar--enable-xmlreader--enable-xmlwriter--enable-zip-- With-mysqli=/srv/mysql/bin/mysql_config--enable-rpath--enable-magic-quotes--enable-sockets--enable-sysvsem-- Enable-sysvshm--enable-sysvmsg--ENABLE-WDDX--enable-ucd-snmp-hack--enablE-shmop--enable-dom--with-xsl--enable-pdo--with-pdo-mysql=/srv/mysql--with-xmlrpc--with-mcrypt--with-iconv-- With-openssl-dir=/usr/local/ssl--with-imap-ssl=/usr/local/ssl--with-gettext=shared--with-imap--enable-fpm-- Enable-fpm-user--enable-fpm-group--enable-cgi--enable-fastcgi--enable-force-cgi-redirect--enable-pcntl make make Install 3. Compile lighttpd./configure--prefix=/srv/lighttpd make do install 4. Installing spawn-fcgi./configure--prefix=/srv/ spawn-fcgi make do install 5. Write spawn-fcgi Script #!/bin/sh # # php-cgi-php-fastcgi swaping via spawn-fcgi # # Chkconfig:- Description:run php-cgi as App server # processname:php-cgi # config:/etc/sysconfig/phpfastcgi (defaults RH sty Le) # Pidfile:/var/run/php_cgi.pid # Note:see How to use this script: # http://www.cyberciti.biz/faq/rhel-fedora-instal L-CONFIGURE-NGINX-PHP5/# Source function library. . /etc/rc.d/init.d/functions # Source Networking configuration. . /etc/sysconfig/network # Check that networking are up. ["$NETWORKING" = "No" && exit 0 spawnfcgi= "/usr/bin/spawn-fcgi" php_cgi= "/usr/bin/php-cgi" prog=$ (basename $php _cgi) server_ip=127.0.0.1 server_port=9000 server_user=nginx server_group=nginx server_childs=5 pidfile= "/var/run/ Php_cgi.pid "# do not edit, put changes in/etc/sysconfig/phpfastcgi [-f/etc/sysconfig/phpfastcgi] &&. /etc/sysconfig/phpfastcgi start () {[-X $php _cgi] | | Exit 1 [-X $spawnfcgi] | | Exit 2 ECHO-N $ "Starting $prog:" Daem On $spawnfcgi-A ${server_ip}-P ${server_port}-u ${server_user}-G ${server_group}-P ${pidfile}-C ${server_childs}-F ${PHP_CGI} retval=$? echo return $retval} stop () {echo-n $ "stopping $prog:" Killproc-p ${pidfile} $prog-quit retval=$? echo [-F ${pidfile}] &&/bin/rm-f ${pidfile} return $retval} restart () {Stop sleep 2 start} rh_status () {stat Us-p ${pidfile} $prog} case "$" in start) start; stop) stop;; restart) restart;; status) Rh_status;; *) echo $ "Usage: $ Start|stop|restart|status}" Exit 3 Esac Here we are using the port to boot, note 6. Modify the LIGHTTPD Configuration ####################################################################### # # # # # #/ etc/lighttpd/lighttpd.conf # # # # check/etc/lighttpd/conf.d/*.conf for the configuration of modules. ## ####################################################################### ###################################### ################################# # # # Some Variable definition which would make chrooting easier. # # # # If you add a variable here. ADD the corresponding variable in the # # Chroot example Aswell. # # Var.log_root = "/srv/lighttpd/log" var.server_root = "/srv/lighttpd" #var. State_dir = "/var/run" Var.home_dir = "/srv/l IGHTTPD "Var.conf_dir ="/etc/lighttpd "# # # # # Run the server chrooted. # # # # This requires root permissions during startup. # # # # IF You run chrooted set the ' the ' variables to directories relative to # # the chroot dir. # # # # example Chroot Configu Ration: # # #var. Log_root = "/logs" #var. Server_root = "/" #var. State_dir = "/run" #var. Home_dir = "/lib/liGhttpd "#var. Vhosts_dir ="/vhosts "#var. Conf_dir ="/etc "# #server. chroot ="/SRV/LIGHTTPD "# # # Some Additional Variab Les to make the configuration easier # # # # # # # # # # # # # # # # Base directory for all Virtual hosts # # # used in: # conf.d/evhost.conf conf.d/simple_vhost.conf # # vhosts.d/vhosts.template # var.vhosts_dir = "/www/root/mail" # # # # # Cache for mod_compress # # # # used in: # # conf.d/compress.conf # var.cache_dir = "/tmp" # # # # # # # Base directory for sockets. # # # used in: # # conf.d/fastcgi.conf # conf.d/scgi.conf # # Var.socket_dir = Home_dir + "/sockets" # # ################### #################################################### ########################################################### ############ # # # # Load the modules. # include "Modules.conf" # # ####################################################################### ############### ######################################################## # # # # Basic Configuration # #---------------------# # Server.port = # # # # # # # Use IPV6? # # ServEr.use-ipv6 = "Disable" # # # # # bind to a specific IP # # #server. bind = "localhost" # # # # Run as a different username/groupn Ame. # # This requires root permissions during startup. # # Server.username = "lighttpd" server.groupname = "Lighttpd" # # # # # # Enable core files. # # #server. core-files = "Disable" # # # # # Document Root # # server.document-root = "/www/root/mail" # # # # # # # # The value for the ' Server: "Response field. # # # # # It would is nice to keep it at "lighttpd". # # #server. Tag = "Lighttpd" # # # # Store a PID file # # server.pid-file = "/tmp/lighttpd.pid" # # ########################### ############################################ ################################################################### # # # # # # # # # # Logging Options # #------------------# # # All Logging options can be overwritten per vhost. # # # # # Path to the error log file # # # Server.errorlog = log_root + "/error.log" # # # # # IF you want to log to syslog you have To unset the # # Server.errorlog setting and uncomment the next line. # # #server. Errorlog-use-syslog = "Enable" # # # # # # # # # # # # Access Log config # # #include "conf.d/access_log.conf" # # # # # Oved into their own file. # # See conf.d/debug.conf for various options for request debugging. # # #include "conf.d/debug.conf" # # ####################################################################### ######## ############################################################### # # # tuning/performance # #--------------------# # # # corresponding Documentation: # # http://www.lighttpd.net/documentation/performance.html # # # # # # Set the Event-handler ( Read the performance section in the Manual) # # # Possible options on Linux is: # # # # # # # poll # # # Linux-sysepoll # # # Linux-sysepoll is recommended on kernel 2.6. # # Server.event-handler = "Linux-sysepoll" # # # # # # # # # # # # # # # The basic network interface for all platforms at the Syscalls Read () # nd write (). Every modern OS provides it own syscall to help network # # servers transfer files as fast as possible # # # # Linux-sendfil E-isRecommended for small files. # # Writev-is recommended for sending many large files # # # server.network-backend = "Linux-sendfile" # # # # # as LIGHTTPD is A single-threaded server, its main resource limit is # # The number of the file descriptors, which is set to 1024x768 by default (o N # # Most systems). # # # # IF You is running a high-traffic site you might want to increase this # # limit by setting Server.max-fds. # # # # Changing this setting requires root permissions on startup. See # # Server.username/server.groupname. # # # By default LIGHTTPD would the operation system default. # # But setting it to 2048 are a better default for busy servers. # # Server.max-fds = 2048 # # # # # # Stat () call caching. # # # # LIGHTTPD can utilize fam/gamin to the cache stat call. # # # # # # Possible values are: # # Disable, simple or fam. # # Server.stat-cache-engine = "Simple" # # # Fine tuning for the Req uest Handling # # # max-connections = = MAX-FDS/2 (MAYBE/3) # # means the other file handles is used for fastcgi/files# # server.max-connections = # # # How many seconds to keep a keep-alive connection open, # # until we consider it idle. # # # # default:5 # server.max-keep-alive-idle = 3 # # # How many keep-alive requests until closing the connection. # # # # # # default:16 # # #server. max-keep-alive-requests = # # # # Maximum size of a request in kilobytes. # # By the default it is unlimited (0). # # # # uploads to your server cant is larger than this value. # # #server. max-request-size = 0 # # # # time to read from a socket before we consider it idle. # # # # # default:60 # server.max-read-idle = # # # # Time to write to a socket before we consider it idle. # # # # default:360 # # #server. Max-write-idle = Traffic Httpd/traffic-shaping.txt # # # Values is in kilobyte per second. # # # # Keep in mind that a limit below 32kb/s might actually limit the # # traffic to 32kb/s. This was caused by the size of the TCP send # # buffer. # # # Per Server: # # #servEr.kbytes-per-second = # # # per connection: # # #connection. Kbytes-per-second = 32 # # ################################ ####################################### ####################################################################### # # # # # # # # # # # # Filename/file # # # # # #------------------------# # # files to check for if .../is requested = ("index.php", "index.rb", "index.html", # # "index.htm", "Default.htm") # # Index-file.names + = ("index.xhtml", "Index.") HTML "," index.htm "," default.htm "," index.php ") # # # # # Deny Access the File-extensions # # # ~ is for backupfiles from VI, Emacs, Joe, ... # # often used for code includes which should on general not being part # # of the Document-root URL.A Ccess-deny = ("~", ". Inc") # # # Disable range requests for PDF files # # Workaround for a bug in the Acrobat Reader plug In. # # $HTTP ["url"] =~ "\.pdf$" {server.range-requests = "Disable"} # # # # URL handling modules (rewrite, redirect) # # #u Rl.rewrite = ("^/$" = "/serv"Er-status ") #url. redirect = (" ^/wishlist/(. +) "=" http://www.example.com/$1 ") # # # # both Rewrite/redirect support B ACK reference to regex conditional using%n # # # $HTTP ["host"] =~ "^www\. (. *) "{# Url.redirect = (" ^/(. *) "=" http://%1/$1 ") #} # # # which extensions should not be handle via Static-file Transfer # # # #. PHP,. PL,. fcgi is most often handled by mod_fastcgi or mod_cgi # # static-file.exclude-extensions = (". P HP ",". Pl ",". fcgi ",". scgi ") # # # # Error-handler for Status 404 # # #server. error-handler-404 ="/error-handler.html "#se rver.error-handler-404 = "/error-handler.php" # # # # # Format:. HTML # # ..../status-404.html for ' File not found ' # # #s Erver.errorfile-prefix = "/srv/www/htdocs/errors/status-" # # # # # MimeType Mapping # # include ' conf.d/mime.conf ' # # # # # Direc Tory listing configuration # # include "Conf.d/dirlisting.conf" # # # # should lighttpd follow symlinks? # # Server.follow-symlink = "Enable" # # # # Force all filenames to be lowercase? # # #server. ForcE-lowercase-filenames = "Disable" # # # # Defaults to/var/tmp As we assume it is a local harddisk # # server.upload-dirs = ( "/tmp") # # ####################################################################### ############################### ######################################## # # # # # # SSL Support # #-------------# # To enable SSL for the whole server Ave to provide a valid # certificate and has to enable the SSL engine.:: # # # # Ssl.engine = "Enable" # # Ssl.pemfile = "/ Path/to/server.pem "# # # # # # # # # # The HTTPS protocol does not allow you to use name-based virtual # # Hosting with SSL. If you want to run multiple SSL servers with # One LIGHTTPD instance you must use ip-based virtual hosting::: # # # # $SER ver["socket"] = = "10.0.0.1:443" {# # Ssl.engine = "Enable" # # Ssl.pemfile = "/etc/ssl/private/www.example.com.pem" # # Serv Er.name = "www.example.com" # # # # # # server.document-root = "/srv/www/vhosts/example.com/www/" # # # # # # # # If you have a. crt and a. key file, cat them together into a # # Single PEM file: # # $ CAT/ETC/SSL/PRIVATE/LIGHTTPD.KEY/ETC/SSL/CERTS/LIGHTTPD.CRT \ # # >/etc/ssl/private/lighttp D.PEM # # #ssl. Pemfile = "/etc/ssl/private/lighttpd.pem" # # # # Optionally pass the CA certificate here. # # # # # #ssl. Ca-file = "" # # ####################################################################### ################### #################################################### # # # custom includes like vhosts. # # #include "conf.d/config.conf" #include_shell "cat/etc/lighttpd/vhosts.d/*.conf" # # ############################## ######################################### server.modules = ("Mod_access", "mod_rewrite", "mod_fastcgi",) Fastcgi.server = (". php" = ("host" = "127.0.0.1", "port" = "9000", "docroot" = "/www/root/mail")) OK to start Note: Do not use mysql5.5, this version takes up too much memory
  • 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.