Detailed steps for configuring nginx + php + mysql in linux

Source: Internet
Author: User

This article will repost an lnpm configuration method. Here we will detail the nginx + php + mysql environment configuration steps in linux, I hope this tutorial will be helpful for you to configure the server.

1. Prepare resources:

Nginx: http://nginx.org/download/nginx-1.3.14.zip

PHP: http://windows.php.net/downloads/releases/php-5.2.17-nts-Win32-VC6-x86.zip

MySQL: http://www.mysql.com/downloads/installer/

1. Uninstall the built-in apache

The Code is as follows: Copy code

Yum remove httpd

2. Install mysql and set the password. You can refer to Centos6 to install mysql and configure import backup.

The Code is as follows: Copy code

Yum install mysql-server

3. Install nginx. If yum is installed

The Code is as follows: Copy code

Yum install nginx

4. install php and related modules

The Code is as follows: Copy code
Yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php- mssql php-snmp php-soap php-tidy


# Edit the php. ini file and add cgi. fix_pathinfo = 1 at the end of the file.
Vi/etc/php. ini

# Start php-fpm

The Code is as follows: Copy code
Service php-fpm start

Related nginx configuration files:

The Code is as follows: Copy code

Server {
Listen 80;
Server_name localhost;

# Access_log/var/nginx/logs/acccess-ebiz.log;

# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80

Location /{
Root/var/www/ecshop;
Index index.html index.htm index. php;
Autoindex on;
}

# Location ~ . Php $ {
# Proxy_pass http: // 127.0.0.1;
#}

# Pass the PHP scripts to FastCGI server listening on Fig: 9000

Location ~ . Php $ {
Root/var/www/ecshop;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}

# Error_page 404/404 .html;

# Redirect server error pages to the static page/50x.html
#
# Error_page 500 502 503 504/50 x.html;
Location =/50x.html {
Root/var/www/nginx-default;
}

}

Create a new PHP file and add:

The Code is as follows: Copy code

<? Php
Phpinfo ();
?>

Date. timezone = Asia/Chongqing

Session. auto_start = 1

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.