啥也没写
分类: LINUX
2009-10-16 10:46:26
首先,更新PHP,MYSQL源
#rpm –import
#vi /etc/yum.repos.d/utterramblings.repo
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=
enabled=1
gpgcheck=1
gpgkey=
安装mysql和php
#yum install -y mysql-server
#yum install -y php php-cli php-xcache php-mysql php-mbstring php-gd
安装EPEL,启用RHEL的附加软件包
#rpm -Uvh
rpm -Uvh
安装nginx
#yum install -y nginx
#chkconfig nginx on
#service nginx start
通过lighttpd的spawn-fcgi跑php
#yum install -y lighttpd-fastcgi
cp /usr/bin/spawn-fcgi /usr/bin/spawn-fcgi.back
#yum remove -y lighttpd
#mv /usr/bin/spawn-fcgi.back /usr/bin/spawn-fcgi
#chmod 777 /usr/bin/spawn-fcgi
//设置MYSQL
#vi /etc/my.cnf
#chkconfig mysqld on
#chkconfig –list mysqld
#service mysqld restart
//改变MYSQL目录的权限
#chgrp -R mysql /var/lib/mysql
#chown -R mysql.mysql /var/lib/mysql
#updatedb
#locate php-cgi
#locate spawn-fcgi
//设置开机启动
#vi /etc/rc.local
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u nobody -f /usr/bin/php-cgi
参数含义如下
-f 指定调用FastCGI的进程的执行程序位置,根据系统上所装的PHP的情况具体设置
-a 绑定到地址addr
-p 绑定到端口port
-s 绑定到unix socket的路径path
-C 指定产生的FastCGI的进程数,默认为5(仅用于PHP),3G以上可以50个,
-P 指定产生的进程的PID文件路径
-u和-g FastCGI使用什么身份(-u 用户 -g 用户组)运行,Ubuntu下可以使用www-data,其他的根据情况配置,如nobody、apache等
//查看PHP进程
#ps -aux |grep php
//设置fastcgi
#vi /etc/nginx/fastcgi_params
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
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;
#vi /etc/nginx/nginx.conf
server_name 192.168.0.1;
index index.php index.html index.htm;
location ~ \.php$ {
include fastcgi_params;
}
//设置PHP
#vi /etc/php.ini
;doc_root =''
cgi.fix_pathinfo=1
#service nginx stop
#service nginx start
nginx虚拟主机设置(多个虚拟主机建立多个文件即可)
#vi abc.conf
server {
listen 80;
server_name ;
index index.html index.htm index.php;
root /data/vhosts/abc;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
location ~ .*\.(css|gif|jpg|jpeg|png|bmp|swf|js)$ {
expires 7d;
}
}