Simple installation of nginx + php in Linux/Unix

Source: Internet
Author: User
I. Install nginx: 1. Install pcre Library, nginx rewrite template need to pcre Library: 1. mkdir-pworks2.cdworks3.wgetftp: ftp.csx.cam.ac.ukpubsoftwareprogrammingpcrepcre-8.20.tar.gz4.tar-zxvfpcre-8.20.tar.gz 5. configure6.makemakeinstall7

1. Install nginx: 1. install the pcre Library. The nginx rewrite template must be used in the pcre Library: 1. mkdir-p/works 2. cd/works 3. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.20.tar.gz 4. tar-zxvf pcre-8.20.tar.gz 5 .. /configure 6. make install 7

1. Install nginx:

1. Install the pcre Library. The nginx rewrite template must be used in the pcre Library:

1. mkdir-p/works

2. cd/works

3. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.20.tar.gz

4. tar-zxvf pcre-8.20.tar.gz

5 ../configure

6. make & make install

7. cd ..

2. Install nginx: www.2cto.com

1. wget http://nginx.org/download/nginx-1.0.10.tar.gz

2. tar-zxvf nginx-1.0.10.tar.gz

3. cd nginx-1.0.10

4../configure

5. make & make install

6. cd ..

3. Create a user and a group:

1. groupadd www

2. useradd-r-g www

Ii. Install PHP5

1. Install the dependency package:

1. libcurl:

2. wget http://curl.haxx.se/download/curl-7.23.1.tar.gz

3. tar-zxvf curl-7.23.1.tar.gz

4. cd curl: 7.23.1/

5 ../configure

6. make & make install

7. cd ..

Libxml2:

1. wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz

2. tar-zxvf libxml2-2.7.6.tar.gz

3. cd libxml2-2.7.6

4../configure

5. make & make install

6. cd ..

Libxslt:

1. wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz

2. tar-zxvf libxslt-1.1.24.tar.gz

3. cd libxslt-1.1.24

4../configure make & make install

5. cd ..

Freetype:

1. wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.gz

2. tar-zxvf freetype-2.4.6.tar.gz

3. cd freetype-2.4.6./configure

4. make & make install

5. cd ..

Libpng:

1. wget "http://prdownloads.sourceforge.net/libpng/libpng-1.5.6.tar.gz? Download"

2. tar-zxvf libpng-1.5.6.tar.gz

3. cd libpng-1.5.6./configure

4. make & make install

5. cd ..

Libjpeg:

1. wget http://ijg.org/files/jpegsrc.v8c.tar.gz

2. tar-zxvf restart src.v8c.tar.gz

3. cd jpeg-8c/

4../configure

5. make & make install

6. cd ..

2. Install php5 and php-fpm:

1. wget http://museum.php.net/php5/php-5.2.16.tar.gz

2. wget http://php-fpm.org/downloads/php-5.2.16-fpm-0.5.14.diff.gz

3. tar-zxvf php-5.2.16.tar.gz

4. gunzip php-5.2.16-fpm-0.5.14.diff.gz

5. cd php-5.2.16/

6. patch-p1 <../php-5.2.16-fpm-0.5.14.diff

7.

8 ../configure \

9. -- with-curl \

10. -- enable-calendar \

11. -- with-xsl \

12. -- with-libxml-dir \

13. -- enable-ftp \

14. -- with-gd \

15. -- with-freetype-dir \

16. -- with-jpeg-dir \

17. -- with-png-dir \

18. -- enable-mbstring \

19. -- with-zlib \

20. -- enable-shared \

21. -- with-mysql \

22. -- enable-fastcgi \

23. -- enable-fpm

24 ../configure & make install

Modify the configuration file/usr/local/etc/php-fpm.conf for php-fpm and set the user and group name for executing php-fpm:

About 62nd rows:

1. Unix user of processes

2.

3. Unix group of processes

4.

To:

1. Unix user of processes

2. Www

3. Unix group of processes

4. Www

Start php-fpm:

1./usr/local/sbin/php-fpm start

2. lsof-I: 9000

3. netstat-ant | grep 9000

4. #9000 is the default port for php-fpm, which can be modified in the/usr/local/etc/php-fpm.conf.

Modify the nginx configuration file/usr/local/nginx/conf/nginx. conf. My nginx configuration file is as follows:

1. worker_processes 10;

2. events {

3. worker_connections 1024;

4 .}

5. http {

6. include mime. types;

7. default_type application/octet-stream;

8. sendfile on;

9. keepalive_timeout 65;

10. gzip on;

11. server {

12. listen 80;

13. server_name ead;

14. root/data/faceshow/www;

15. location /{

16. root html;

17. index. php index.html index.htm;

18 .}

19. error_page 500 502 503 x.html;

20. location =/50x.html {

21. root html;

22 .}

23.

24. # This code segment is critical

25. location ~ \. Php $ {

26. fastcgi_pass 127.0.0.1: 9000; # port corresponding to php-fmp

27. fastcgi_index. php;

28. fastcgi_param SCRIPT_FILENAME/data/faceshow/www/$ fastcgi_script_name;

29. # physical path of the PHP File

30. include fastcgi_params;

31 .}

32.

33. location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $

34 .{

35. expires 30d;

36 .}

37. location ~ . * \. (Js | css )? $

38 .{

39. expires 1 h;

40 .}

41 .}

42 .}

43.

Start nginx:

1./usr/local/nginx/bin/nginx

2./usr/local/nginx/bin/nginx-s reload

Iii. FAQs:

Problem: nginx./configure reports the following error

1./configure: error: the HTTP rewrite module requires the PCRE library.

2. You can either disable the module by using -- without-http_rewrite_module

3. option, or install the PCRE library into the system, or build the PCRE library

4. statically from the source with nginx by using -- with-pcre = Option.

Solution: this is because the PCRE Library is not available. Install the PCRE Library to run./configure. You can also use the./configure with -- without-http_rewrite_module parameters, but this will cause nginx to not support the rewrite function!

Iv. Related documents:

Libcurl: http://curl.haxx.se/download.html

Libxml2: ftp://xmlsoft.org/libxml2/

Libxslt: ftp://xmlsoft.org/libxml2/

Libpng: http://www.libpng.org/pub/png/libpng.html

Libjpeg: http://ijg.org/files/

Freetype: http://download.savannah.gnu.org/releases/freetype/

PC: http://www.pcre.org/

Nginx: http://nginx.org/en/download.html

Php-fpm: http://php-fpm.org/

Php5: http://www.php.net/releases/

MySQL: http://www.mysql.com/downloads/mirror.php? Id = 404683 # mirrors

From the love family

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.