Install nginx + mysql + php-fastcgi on yum on CentOS

Source: Internet
Author: User
Tags php mysql openldap
Use the yum command provided by CentOS Linux to install and upgrade the library.

1. change yum source to NetEase source to increase speed

Vi/etc/yum. repos. d/CentOS-Base.repo
The changes are as follows:

  1. # CentOS-Base.repo
  2. #
  3. # This file uses a new release list system developed by Lance Davis for CentOS.
  4. # The mirror system uses the connecting IP address of the client and
  5. # Update status of each mirror to pick mirrors that are updated to and
  6. # Geographically close to the client. You shoshould use this for CentOS updates
  7. # Unless you are manually picking other mirrors.
  8. #
  9. # If the specified list = does not work for you, as a fall back you can try
  10. # Remarked out baseurl = line instead.
  11. #
  12. #
  13. [Base]
  14. Name = CentOS-$ releasever-Base
  15. # Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = OS
  16. # Baseurl = http://developer.centos.org/centos/?releasever/ OS /?basearch/
  17. Baseurl = http://mirrors.163.com/centos/?releasever/ OS /?basearch/
  18. Gpgcheck = 1
  19. Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  20. # Released updates
  21. [Updates]
  22. Name = CentOS-$ releasever-Updates
  23. # Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = updates
  24. # Baseurl = http://developer.centos.org/centos/?releasever/updates/?basearch/
  25. Baseurl = http://mirrors.163.com/centos/?releasever/updates/?basearch/
  26. Gpgcheck = 1
  27. Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  28. # Packages used/produced in the build but not released
  29. [Addons]
  30. Name = CentOS-$ releasever-Addons
  31. # Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = addons
  32. # Baseurl = http://developer.centos.org/centos/?releasever/addons/?basearch/
  33. Baseurl = http://mirrors.163.com/centos/?releasever/addons/?basearch/
  34. Gpgcheck = 1
  35. Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  36. # Additional packages that may be useful
  37. [Extras]
  38. Name = CentOS-$ releasever-Extras
  39. # Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = extras
  40. # Baseurl = http://developer.centos.org/centos/?releasever/extras/?basearch/
  41. Baseurl = http://mirrors.163.com/centos/?releasever/extras/?basearch/
  42. Gpgcheck = 1
  43. Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  44. # Additional packages that extend functionality of existing packages
  45. [Centosplus]
  46. Name = CentOS-$ releasever-Plus
  47. # Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = centosplus
  48. # Baseurl = http://developer.centos.org/centos/?releasever/centosplus/?basearch/
  49. Baseurl = http://mirrors.163.com/centos/?releasever/centosplus/?basearch/
  50. Gpgcheck = 1
  51. Enabled = 0
  52. Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

II. update yum

  1. Yum-y update

3. use the yum command provided by CentOS Linux to install and upgrade the required Library

  1. LANG = C
  2. 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

4. install php and mysql

  1. Yum-y install php mysql-server mysql-devel php-mysql php-cgi php-mbstring php-gd php-fastcgi

5. install nginx
Because centos does not have the default nginx package, you need to enable the REHL attachment package.

  1. Rpm-Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  2. Yum-y install nginx

Set startup

  1. Chkconfig nginx on

6. install spawn-fcgi to run php-cgi

  1. Yum install spawn-fcgi

7. download the startup script of spawn-fcgi

  1. Wget http://bash.cyberciti.biz/dl/419.sh.zip
  2. Unzip 419.sh.zip
  3. Mv 419.sh/etc/init. d/php_cgi
  4. Chmod + x/etc/init. d/php_cgi

Start php_cgi

  1. /Etc/init. d/php_cgi start

View processes

  1. Netstat-tulpn | grep: 9000

If the following occurs, everything is normal.

  1. Tcp 0 0 127.0.0.1: 9000 0.0.0.0: * LISTEN 4352/php-cgi

8. Configure nginx. for detailed configuration, see nginx. conf)

  1. Location ~ \. Php $ {
  2. Root html;
  3. Fastcgi_pass 127.0.0.1: 9000;
  4. Fastcgi_index index. php;
  5. Fastcgi_param SCRIPT_FILENAME/usr/share/nginx/html $ fastcgi_script_name;
  6. Include fastcgi_params;
  7. }

IX. View phpinfo
Write scripts

  1. Phpinfo ();

10. install phpmyadmin
The permission for modifying/var/lib/php/session is the same as that for nginx and php_cgi.

  1. Chown-R www. www/var/lib/php/session

FPM installation method: install lnmp (Nginx + PHP + MySQL) fpm in CentOS

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.