Lighttpd + php installation

Source: Internet
Author: User
Lighttpd + php installation today, a small memory vps of apache occupies too much memory, decided to give up, the use of lighttpd from the internet to find a lot of articles, and finally installed successfully 1. compile and install mysql. /configure -- prefix =/srv/mysql -- without-debug -- with-extra-charsets = all -- enable-consumer er -- with-pthread -- enable-thread-safe-client --- client-ldflags =-all-static -- localstatedir =/srv/mysql/data -- with-unix-socket-path =/tmp/mysql. sock -- with-big-tables make install the remaining steps are omitted .... 2. install php phpcgi at the beginning After php5.3, no matter how you adjust the compilation parameters, you cannot compile it into php-cgi. you should use 5.2. I don't know if I didn't add any parameters or why, if anyone knows what I want to say about my 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 --- kerberos-with-bz2 -- enable-calendar -- enable-xmlreader -- enable-x Mlwriter -- 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-g Ettext = shared -- with-imap -- enable-fpm-user -- enable-fpm-group -- enable-cgi -- enable-fastcgi -- enable-force-cgi-redirect -- enable-pcntl make install 3. compile lighttpd. /configure -- prefix =/srv/lighttpd make install 4. install spawn-fcgi. /configure -- prefix =/srv/spawn-fcgi make install 5. write the spawn-fcgi script #! /Bin/sh # php-cgi-php-fastcgi swaping via spawn-fcgi # chkconfig:-85 15 # description: Run php-cgi as app server # processname: php-cgi # config:/etc/sysconfig/phpfastcgi (defaults RH style) # pidfile:/var/run/php_cgi.pid # Note: See how to use this script :# http://www.cyberciti.biz/faq/rhel-fedora-install-configure-nginx-php5/ # Source function library .. /etc/rc. d/init. d/functions # Source networking configuration .. /etc/sysconfig/network # Check that networking is 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: "daemon $ 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}] & amp;/bin/rm-f $ {pidfile} return $ retval} restart () {stop sleep 2 start} rh_status () {status-p $ {pidfile} $ prog} case "$1" in start) start; stop) stop; restart) restart; status) rh_status ;;*) echo $ "Usage: $0 {start | stop | restart | status}" exit 3 esac here we use port to start. Note 6. modify the lighttpd configuration ##################################### ######################################/etc /lighttp D/lighttpd. conf #### check/etc/lighttpd/conf. d /*. conf for the configuration of modules. ######################################## ######################################## ######################################## ########################### Some Variable definition which will 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/lighttpd" var. conf_dir = "/etc/lighttpd" #### run the server chrooted. #### This requires root permissions during startup. #### If you run Chrooted set the variables to directories relative to # the chroot dir. #### example chroot configuration: ### var. log_root = "/log S "# 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 variables 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/ro Ot/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 m Odules. # include "modules. conf "###################################### ######################################## ######################################## ############################ Basic Configuration ## ----------------- # server. port = 80 #### Use IPv6? # Server. use-ipv6 = "disable" #### bind to a specific IP ### server. bind = "localhost" #### Run as a different username/groupname. # This requires root permissions during startup. # server. username = "lighttpd" server. groupname = "lighttpd" #### enable core files. ### server. core-files = "disable" #### Document root # server.doc ument-root = "/www/root/mail" #### The value for the "Server: "response field. #### It wocould be 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 "#### The debug options are moved 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 are: #### select ## 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 syscallread () ## and write (). every modern OS provides its own syscall to help network # servers Transfer files as fast as possible #### linux-sendfile-is recommended for small files. # writev-is recommended for sending large files # server. network-backend = "linux-sendfile" #### As lighttpd is a single-threaded server, its main resource limit is ## the number of file descriptors, which is set to 1024 by default (on # most systems ). #### If you are 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 wocould not change the operation system default. # But setting it to 2048 is a better default for busy servers. # server. max-fds = 2048 #### Stat () call caching. #### lighttpd can utilize FAM/Gamin To cache stat call. #### possible values are: ## disable, simple or fam. # server. stat-cache-engine = "simple" #### Fine tuning for the request handling #### max-connections = max-fds/2 (maybe/3) # means the other file handles are used for fastcgi/files # server. max-connections = 100 #### 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 = 16 #### Maximum size of a request in kilobytes. # By default it is unlimited (0 ). #### Uploads to your server cant be 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 = 30 #### Time to write to a socket before we consider it idle. #### Default: 360 ### server. max-write-idle = 360 #### Traffic Shaping ## ----------------- ### see/usr/share/doc/lighttpd/traffic-shaping.txt ### Values are in kilobyte per second. #### Keep in mind that a limit below 32kB/s might actually limit the # traffic to 32kB/s. this is caused The size of the TCP send # buffer. #### per server: ### server. kbytes-per-second = 128 #### per connection: ### connection. kbytes-per-second = 32 ################################# ######################################## ######################################## ################################### Filename/File handling # # ------------------------ #### files to check for if... /is requested # # The index-file.names = ("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 ,... ##. inc is often used for code when Des which shoshould in general not be part # of the document-root url. access-deny = ("~ ",". Inc ") #### disable range requests for pdf files # workaround for a bug in the Acrobat Reader plugin. # $ HTTP [" url "] = ~ "\. Pdf $ "{server. range-requests = "disable" }#### url handling modules (rewrite, redirect) ### url. rewrite = ("^/$" => "/server-status") # url. redirect = ("^/wishlist /(. +) "=>" http://www.example.com/ $1 ") #### both rewrite/redirect support back reference to regex conditional using % n ### $ HTTP [" host "] = ~ "^ Www \. (. *)" {# url. redirect = ("^/(. *)" =>" http://%1/ $1 ") #}#### which extensions shoshould not be handle via static-file transfer ####. php ,. pl ,. fcgi are most often handled by mod_fastcgi or mod_cgi # static-file.exclude-extensions = (". php ",". pl ",". fcgi ",". scgi ") #### error-handler for status 404 ### server. error-handler-404 = "/error-handler.html" # server. error-handler-404 = "/error-handler.php" #### Format :. html ###-> .... /status-404. Html for 'file not found '### server. errorfile-prefix = "/srv/www/htdocs/errors/status-" ### mimetype mapping # include "conf. d/mime. conf "#### directory listing configuration # include" conf. d/dirlisting. conf "#### shocould 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 you have to provide a valid # certificate and have 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 ::: #### $ SERVER ["socket"] = "10.0.0.1: 443" {## ssl. engine = "enable" # ssl. pemfile = "/etc/ssl/private/www.example.com. pem "# server. name = "www.example.com" #### server.doc ument-root = "/srv/www/vhosts/example.com/www/" ##### If you have. crt and. key file, cat them together into a # single PEM file: ##$ cat/etc/ssl/private/lighttpd. key/etc/ssl/certs/lighttpd. crt ###>/etc/ssl/private/lighttpd. pem ### ssl. pemfile = "/etc/ssl/private/lighttpd. pem "#### optionally pass the CA certificate here. ##### ssl. ca-file = ""################################## ######################################## ######################################## ################################## custom supported des 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 start remarks: Do not use mysql5.5, this version occupies 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.