yum -y remove httpd 如何默认有APACHE先卸载APACHE
spawn-fcgi是一个小程序,这个程序的作用是管理fast-cgi进程,功能和php-fpm类似
先YUM查找需要的库:
代码如下
- yum -y install gcc gcc-c++ make imake autoconf automake
-
- yum -y install gcc gcc-c++ openssl openssl-devel pcre pcre-devel gdbm gdbm-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel libtool-ltdl libtool-ltdl-devel curl-devel
-
由于mysql编译比较慢我用yum安装了
yum -y install mysql-server mysql-devel
----------------------------------------------------------------------------------------------------
wget http://www.nginx.org/download/nginx-0.8.32.tar.gz
ls
tar zxvf nginx-0.8.32.tar.gz
cd nginx-0.8.32
代码如下
- groupadd www
- useradd -g www -s /sbin/nologin -d /dev/null www
- ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
- make && make install
- cd /usr/local/nginx/conf
- mv nginx.conf nginx.conf.bak
vim nginx.conf
=====================================================
代码如下
- user www www;
-
- worker_processes 8;
-
- error_log logs/error.log crit;
-
- pid logs/nginx.pid;
-
- #Specifies the value for maximum file descriptors that can be opened by this process.
- worker_rlimit_nofile 65535;
-
- events
- {
- use epoll;
- worker_connections 65535;
- }
-
- http
- {
- include mime.types;
- default_type application/octet-stream;
-
- #charset gb2312;
-
- server_names_hash_bucket_size 128;
- client_header_buffer_size 32k;
- large_client_header_buffers 4 32k;
- client_max_body_size 8m;
-
- sendfile on;
- tcp_nopush on;
-
- keepalive_timeout 30;
-
- tcp_nodelay on;
-
- fastcgi_connect_timeout 300;
- fastcgi_send_timeout 300;
- fastcgi_read_timeout 300;
- fastcgi_buffer_size 64k;
- fastcgi_buffers 4 64k;
- fastcgi_busy_buffers_size 128k;
- fastcgi_temp_file_write_size 128k;
-
- 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;
-
- include /usr/local/nginx/conf/vhosts/*.conf;
- }
-
========================================
mkdir vhosts
cd vhosts/
vim s157.com.conf
==============================
代码如下
- server {
- listen 184.82.2.206:80;
- server_name s157.com www.s157.com;
-
- #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 /usr/local/nginx/logs/www.access.log;
- access_log off;
-
- location / {
- root /ftp/s157;
- index index.html index.htm index.php;
-
- location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
- expires 30d;
- }
-
- location ~ .*.(htm|html|js|css)$ {
- expires 1h;
- }
-
- }
-
- #error_page 404 =200 http://$host;
- #error_page 404 /404.html;
-
- location ~ .php$ {
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /ftp/s157/$fastcgi_script_name;
- include fastcgi_params;
- }
-
-
- }
-
- =================================
- 其中 可有可无 功能是防盗链的
- location ~* .(gif|jpg|png|swf|flv)$ {
- valid_referers none blocked abc.com www.abc.com;
- if ($invalid_referer) {
- #rewrite ^/ http://www.abc.com/403.jpg;
- return 404;
- }
- }
- =============
然后 找了个针对 CentOS 的nginx重启控制脚本
chmod 755 nginx
cp nginx /etc/init.d/
/etc/init.d/nginx restart 测试能不能成功 启动 !!!!!!!!!!!!!