Compiling and constructing php + mysql + nginx in Linux (1)

Source: Internet
Author: User
Tags nginx server
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:

 
 
  1. 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:

 
 
  1. cd /opt/

Download and unzip:

 
 
  1. wget http://nginx.org/download/nginx-1.5.2.tar.gz
  2. tar -zxf nginx-1.5.2.tar.gz
  3. wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz
  4. tar -zxf ngx_cache_purge-2.1.tar.gz

Go to the directory and compile:

 
 
  1. cd nginx-1.5.2
  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
  3. 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:

 
 
  1. groupadd -f www
  2. 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

 
 
  1. #!/bin/bash
  2. #
  3. # Init file for nginx server daemon
  4. #
  5. # chkconfig: 234 99 99
  6. # description: nginx server daemon
  7. #
  8. # source function library
  9. ./etc/rc.d/init.d/functions
  10. # pull in sysconfig settings
  11. [-f /etc/sysconfig/nginx ]&&./etc/sysconfig/nginx
  12. RETVAL=0
  13. prog="nginx"
  14. PAT=/usr/local/nginx
  15. NGINXD=/usr/local/nginx/sbin/nginx
  16. PID_FILE=/usr/local/nginx/nginx.pid
  17. start()
  18. {
  19. echo -n $"Starting $prog: "
  20. $NGINXD 2>/dev/null $OPTIONS && success || failure
  21. RETVAL=$?
  22. ["$RETVAL"=0]&& touch /var/lock/subsys/nginx
  23. echo
  24. }
  25. stop()
  26. {
  27. echo -n $"Shutting down $prog: "
  28. killproc nginx
  29. RETVAL=$?
  30. echo
  31. [ $RETVAL -eq 0]&& rm -f /var/lock/subsys/nginx
  32. return $RETVAL
  33. }
  34. reload()
  35. {
  36. echo -n $"Reloading nginx: "
  37. killproc nginx -HUP
  38. RETVAL=$?
  39. echo
  40. return $RETVAL
  41. }
  42. case"$1"in
  43. "start")
  44. start
  45. ;;
  46. "stop")
  47. stop
  48. ;;
  49. "restart")
  50. stop
  51. start
  52. ;;
  53. "reload")
  54. reload
  55. ;;
  56. "status")
  57. status -p $PID_FILE nginx
  58. RETVAL=$?
  59. ;;
  60. *)
  61. echo $"Usage: $0 {start|stop|restart|reload|status}"
  62. RETVAL=1
  63. esac
  64. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.