文件位置
php /usr/local/php php.ini /etc/php.ini Nginx /usr/local/nginx mysql /usr/bin/ web目錄 /var/www 準(zhǔn)備PHP環(huán)境 # yum install gd # yum install gd-devel # yum install libmcrypt # yum install libmcrypt-devel # yum install freetype # yum install freetype-devel # yum install mysql # yum install mysql-devel # yum install libtool-ltdl # yum install libtool-ltdl-devel 安裝PHP模塊 # ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-gd --enable-gd-native-ttf --with-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-debug --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect --enable-mbstring --with-mcrypt # make # make install 安裝memcache客戶端 # /usr/local/php/bin/phpize # ./configure --with-php-config=/usr/local/php/bin/php-config # make # make install # cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613 # cp memcache.so ../ 修改php.ini模塊.加載memcache # cp php.ini-dist /etc/php.ini # vi /etc/php.ini
編譯lighthttpd得到spawn-fcgi,用來運行FastCGI # ./configure # make # cp ./src/spawn-fcgi /usr/local/php/bin 運行FastCGI,-C參數(shù)為開啟進程數(shù),如果內(nèi)存大于3GB,可以開至64 # /usr/local/php/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 25 -u www -f /usr/local/php/bin/php-cgi 添加用戶以及web發(fā)布目錄 # /usr/sbin/groupadd www -g 48 # /usr/sbin/useradd -u 48 -g www www # mkdir -p /var/www # chmod +w /var/www # chown -R www:www /var/www 創(chuàng)建ngnix日志 # mkdir -p /var/log/nginx # chmod +w /var/log/nginx # chown -R www:www /var/log/nginx 編譯安裝Nginx # yum install pcre-devel # ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module # make # make install 配置運行Nginx # vi /usr/local/nginx/conf/ngnix.conf
#user nobody; worker_processes 10; events { use epoll; worker_connections 1024; } http { include conf/mime.types; default_type application/octet-stream; #log_format main ‘$remote_addr - $remote_user [$time_local] $request ‘ # ‘"$status" $body_bytes_sent "$http_referer" ‘ # ‘"$http_user_agent" "$http_x_forwarded_for"‘; access_log /var/log/nginx_access.log; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; server { listen 80; server_name localhost; charset gb2312; #access_log logs/host.access.log main; root /var/www; #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php?$ { include conf/fcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } #location ~ /\.ht { # deny all; #} } } # vi /usr/local/nginx/conf/fcgi.conf
fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect #fastcgi_param REDIRECT_STATUS 200; # /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 啟動腳本 # vi nginx.sh
# chmod 755 nginx.sh |
|