YUM安装LNMP架构

CentOS默认源里没有nginx软件 :wget http://www.atomicorp.com/installers/atomic

sh ./atomic #安装YUM源

yum check-update #更新yum软件包

一、安装nginx

1
2
3
yum install nginx
service nginx start
chkconfig nginx on

二、安装mysql

1
2
3
yum install mysql mysql-server mysql-devel
service mysqld start
chkconfig mysqld on

三、安装php

#安装PHP及组件,使PHP支持 MySQL、PHP支持FastCGI模式

1
2
3
4
5
yum install php php-mysql php-gd libjpeg* php-pear php-xml php-mbstring
php-mcrypt php-mhash libmcrypt libmcrypt-devel php-imap php-ldap php-odbc php-bcmath php-xmlrpc php-fpm
service mysqld restart
service nginx restart
service php-fpm start

四、配置nginx支持php

1
2
3
4
5
6
7
8
9
10
11
vi /etc/nginx/nginx.conf  #修改运行用户
user nginx;
vi /etc/nginx/conf.d/default.conf #开启php支持
index index.php index.html index.htm;
location ~ \.php$ {
    root html; #取消FastCGI server部分location的注释
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME                      /usr/share/nginx/html/$fastcgi_script_name;    #$document_root设置为网站根目录
    include fastcgi_params;
 }

1、配置php

1
2
date.timezone = Asia/Shanghai #设置时区
expose_php = OFF #禁止显示版本信息

2、配置php-fpm

1
2
3
vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx

3、测试

1
2
3
4
5
6
7
8
chown -R nginx.nginx /usr/share/nginx/html/ #设置目录所有者
chmod 774 -R /usr/share/nginx/html/ #设置目录权限
service mysqld restart
service nginx restart
service php-fpm restart
cd /usr/share/nginx/html/
vi index.php
<?Php phpinfo();?>

http://127.0.0.1 #可以看到相关的配置信息!

上一篇:Lnmp安装收集资料


下一篇:c#.net实现文件夹的上传和下载