1. obtain basic open-source programs:
Yum-y install gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses- devel curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel openldap-devel nss_ldap openldap-clients openldap-servers
2. Two RPM packages are recommended to search websites.
Http://rpm.pbone.net/
Http://www.rpmfind.net/
3. Run the command rpm-qa | grep libjpeg to check whether the preceding packages exist. Otherwise, library support is missing during installation.
Rpm-ivh (filename) is the command for installing the RPM package
4. Obtain the nginx source code package
Wget http://sysoev.ru/nginx/nginx-0.8.46.tar.gz
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz (library support required to install nginx)
5. Create www: www users and groups
Groupadd www
Useradd-g www
Install nginx under/usr/local/webserver/
In the future, place the web program under/var/www /.
@ 1 install the pcre Library required by Nginx:
@ 2 install Nginx
Ruby code
- Tar zxvf nginx-0.8.46.tar.gz
- Cd nginx-0.8.46/
- ./Configure -- user = www -- group = www -- prefix =/usr/local/webserver/nginx -- with-http_stub_status_module -- with-http_ssl_module
- Make & make install
- Cd ../
tar zxvf nginx-0.8.46.tar.gzcd nginx-0.8.46/./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_modulemake && make installcd ../
@ 3 create an Nginx log directory
Ruby code
- Mkdir-p/data1/logs
- Chmod + w/data1/logs
- Chown-R www: www/data1/logs
mkdir -p /data1/logschmod +w /data1/logschown -R www:www /data1/logs
Nginx. conf recommended online
Mv/usr/local/webserver/nginx/conf/nginx. conf/usr/local/webserver/nginx/conf/nginx. conf. bak
Vi/usr/local/webserver/nginx/conf/nginx. conf
Ruby code
- User www;
- Worker_processes 8;
- Error_log/data1/logs/nginx_error.log crit;
- Pid/usr/local/webserver/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 32 k;
- Large_client_header_buffers 4 32 k;
- Client_max_body_size 8 m;
- Sendfile on;
- Tcp_nopush on;
- Keepalive_timeout 60;
- Tcp_nodelay on;
- Fastcgi_connect_timeout 300;
- Fastcgi_send_timeout 300;
- Fastcgi_read_timeout 300;
- Fastcgi_buffer_size 64 k;
- Fastcgi_buffers 4 64 k;
- Fastcgi_busy_buffers_size 128 k;
- Fastcgi_temp_file_write_size 128 k;
- Gzip on;
- Gzip_min_length 1 k;
- Gzip_buffers 4 16 k;
- Gzip_http_version 1.0;
- Gzip_comp_level 2;
- Gzip_types text/plain application/x-javascript text/css application/xml;
- Gzip_vary on;
- # Limit_zone crawler $ binary_remote_addr 10 m;
- Server
- {
- Listen 80;
- Server_name <A href = "http://www.test.com; % 09"> www.test.com;
- </A> index index.html index.htm index. php;
- Root/data0/htdocs/blog;
- # Limit_conn crawler 20;
- Location ~ . * \. (Php | php5 )? $
- {
- # Fastcgi_pass unix:/tmp/php-cgi.sock;
- Fastcgi_pass 127.0.0.1: 9000;
- Fastcgi_index index. php;
- Fcinclude gi. conf;
- }
- Location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $
- {
- Expires 30d;
- }
- Location ~ . * \. (Js | css )? $
- {
- Expires 1 h;
- }
- Log_format access' $ remote_addr-$ remote_user [$ time_local] "$ request "'
- '$ Status $ body_bytes_sent "$ http_referer "'
- '"$ Http_user_agent" $ http_x_forwarded_for ';
- Access_log/data1/logs/access. log access;
- }
- }
Ruby code
- Tar zxvf pcre-8.10.tar.gz
- Cd pcre-8.10/
- ./Configure
- Make & make install
- Cd ../
tar zxvf pcre-8.10.tar.gzcd pcre-8.10/./configuremake && make installcd ../