Web servers have always been built with one click, but the environment built with one click is relatively old. If you want to use a new environment, especially the official server, you must manually compile and build it (the following is a linuxcentos6.532-bit server ). 1. nginx version: 1.5: nginx. orgdownload
Web servers have always been built with one click, but the environment built with one click is relatively old. If you want to use a new environment, especially the official server, you must manually compile and build it (the following is a 32-bit linux centos6.5 server ). 1. nginx version: 1.5: http://nginx.org/download/
Web servers have always been built with one click, but the environment built with one click is relatively old. If you want to use a new environment, especially the official server, you must manually compile and build it (the following is a 32-bit linux centos6.5 server ).
1. nginx
Version: 1.5
: Http://nginx.org/download/nginx-1.5.2.tar.gz
2. mysql
Release 5.5
: Http://downloads.mysql.com/archives/mysql-5.0/mysql-5.5.30.tar.gz
3. php
Release 5.4
: Http://am1.php.net/get/php-5.4.34.tar.gz/from/this/mirror
I. Install nginx
Install some dependency packages:
- yum -y install gcc gcc-c++ gcc-devel gcc-c++-devel ssl ssl-devel autoconf make aclocal libtool expat-devel libxml2-devel openssl openssl-devel zlib zlib-devel bzip2 bzip2-devel gd gd-devel libmcrypt libmcrypt-devel libXpm-devel curl-devel libgd-devel gd-devel openldap-devel
Enter a directory:
- cd /opt/
Download and unzip:
- wget http://nginx.org/download/nginx-1.5.2.tar.gz
- tar -zxf nginx-1.5.2.tar.gz
- wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz
- tar -zxf ngx_cache_purge-2.1.tar.gz
Go to the directory and compile:
- cd nginx-1.5.2
- ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/log/error.log --http-log-path=/usr/local/nginx/log/access.log --pid-path=/usr/local/nginx/run/nginx.pid --user=www --group=www --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/usr/local/nginx/tmp/client --http-proxy-temp-path=/usr/local/nginx/tmp/proxy/--http-fastcgi-temp-path=/usr/local/nginx/tmp/fcgi/--add-module=../ngx_cache_purge-2.1--with-pcre=../pcre-8.34
- make && make install
In this way, nginx is set up.
Run:/usr/local/nginx/sbin/nginx
Error: nginx: [emerg] getpwnam ("www") failed
In nginx. conf, remove the user nobody comment and change it to www.
Run again:/usr/local/nginx/sbin/nginx
Error: nginx: [emerg] getpwnam ("www") failed in/usr/local/nginx/conf/nginx. conf: 1
The error occurs because the www user is not created. Add the www user group and the www user to the server system. Run the following command:
- groupadd -f www
- useradd -g www www
Third run:/usr/local/nginx/sbin/nginx
Error: nginx: [emerg] mkdir () "/usr/local/nginx/tmp/client" failed (2: No such file or directory)
Run mkdir-p/usr/local/nginx/tmp/client.
Then the localhost access will show:
Get used to/etc/init. d/nginx start? Think/usr/local/nginx/sbin/nginx is too long?
Vim/etc/init. d/nginx
- #!/bin/bash
- #
- # Init file for nginx server daemon
- #
- # chkconfig: 234 99 99
- # description: nginx server daemon
- #
- # source function library
- ./etc/rc.d/init.d/functions
- # pull in sysconfig settings
- [-f /etc/sysconfig/nginx ]&&./etc/sysconfig/nginx
- RETVAL=0
- prog="nginx"
- PAT=/usr/local/nginx
- NGINXD=/usr/local/nginx/sbin/nginx
- PID_FILE=/usr/local/nginx/nginx.pid
- start()
- {
- echo -n $"Starting $prog: "
- $NGINXD 2>/dev/null $OPTIONS && success || failure
- RETVAL=$?
- ["$RETVAL"=0]&& touch /var/lock/subsys/nginx
- echo
- }
- stop()
- {
- echo -n $"Shutting down $prog: "
- killproc nginx
- RETVAL=$?
- echo
- [ $RETVAL -eq 0]&& rm -f /var/lock/subsys/nginx
- return $RETVAL
- }
- reload()
- {
- echo -n $"Reloading nginx: "
- killproc nginx -HUP
- RETVAL=$?
- echo
- return $RETVAL
- }
- case"$1"in
- "start")
- start
- ;;
- "stop")
- stop
- ;;
- "restart")
- stop
- start
- ;;
- "reload")
- reload
- ;;
- "status")
- status -p $PID_FILE nginx
- RETVAL=$?
- ;;
- *)
-
- echo $"Usage: $0 {start|stop|restart|reload|status}"
- RETVAL=1
- esac
- exit $RETVAL
Save and add the x permission.
If you need to start the instance at startup:
Chkconfig nginx on
More please support: http://www.webyang.net/Html/web/article_127.html