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 |