As a load balancing server: Nginx can directly support Rails and PHP internally, and can also support external services as an HTTP proxy server.
As a mail proxy server: Nginx is also a very good mail proxy server (one of the first purposes of developing this product was also as a mail proxy server), Last/fm describes a successful and wonderful experience using it.
Nginx installation is very simple, and the configuration file is very concise (it also supports perl syntax). Nginx supports smooth loading of new configurations, and can also upgrade software versions without interruption of service.
The architecture of LNMP is therefore very popular, especially the emergence of VPS and cloud hosting, which further promotes the development and integration of the architecture of LNMP, which has natively supported the php-fpm method since php5.4. PHP-FPM is a PHP FastCGI manager. It is no longer a third-party package. PHP-FPM provides a better PHP process management method, which can effectively control memory and processes, and can smoothly reload PHP configuration, which is better than spawn-fcgi. has more advantages.
1. Before installation, turn off the firewall and clean up the installed packages:
rpm -e httpd
rpm -e mysql
rpm -e php
yum -y remove httpd
yum -y remove mysql
yum -y remove php #Search
apache package
rpm -qa http* #Force
uninstall apache package
rpm -e --nodeps Query the file name #Check
whether to uninstall cleanly
rpm -qa|grep http*
2. Configure CentOS 6.0 third-party yum source (there is no nginx package in the default standard source of CentOS)
sh ./atomic
yum check-update
3. Install the development package and library files
4. Install Nginx
service nginx start
chkconfig --levels 235 nginx on #Set 2, 3, 5 levels to start
5. Install Mysql
service mysqld start
chkconfig --levels 235 mysqld on #After
installation, the default user name is root and the password is empty #Change
root password
mysqladmin -uroot password 666666 -p
6. Install php
7.安装FastCGI(FPM)
service php-fpm start
chkconfig --levels 235 php-fpm on
8.配置Nginx支持php
#1.将“location /”处增加php的扩展
#2.将“location ~ \.php$”解除注释,并修改成以下那样。
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
9.配置php
cgi.fix_pathinfo = 1 #将注释去掉,开启PHP的pathinfo伪静态功能。
max_execution_time = 0 #脚本运行的最长时间,默认30秒
max_input_time = 300 #脚本可以消耗的时间,默认60秒
memory_limit = 256M #脚本运行最大消耗的内存,根据你的需求更改数值,默认128M
post_max_size = 100M #单提交的最大数据,此项不是限制上传单个文件的大小,而是针对整个表单的提交数据进行限制的。限制范围包括表单提交的所有内容.例如:发表贴子时,贴子标题,内容,附件等…默认8M
upload_max_filesize = 10M #上载文件的最大许可大小 ,默认2M
10.安装phpmyadmin
cd /usr/share/nginx/html/
wget https://files.phpmyadmin.net/phpMyAdmin/4.4.15.5/phpMyAdmin-4.4.15.5-all-languages.zip
unzip phpMyAdmin-4.4.15.5-all-languages.zip
mv phpMyAdmin-4.4.15.5-all-languages zhaonimei
10.重启Nginx php-fpm
service php-fpm restart
11.测试Nginx是否解析php
显示phpmyadmin登录界面 环境搭建成功
参考文章:
http://www.centoscn.com/CentosServer/www/2015/0422/5245.html
http://www.cnblogs.com/xiaoit/p/3991037.html