YUM搭建LNMP框架


CentOS6.5搭建LNMP

1:查看環境:

[root@10-4-14-168html]# cat /etc/redhat-release php

CentOSrelease 6.5 (Final)html

 

2:關掉防火牆

[root@10-4-14-168html]# chkconfig iptables offmysql

 

3:配置CentOS 6.0 第三方yum源(CentOS默認的標準源裏沒有nginx軟件包)

#wgethttp://www.atomicorp.com/installers/atomicnginx

#sh./atomicc++

#yumcheck-updatesql

 

4:安裝開發包和庫文件 

#yum-y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devellibjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-develapache

gccgcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devellibxml2 瀏覽器

libxml2-develimake autoconf automake screen sysstat compat-libstdc++-33 curl curl-develcurl

 

5:卸載已安裝的apachemysqlphp

# yumremove httpdide

# yumremove mysql

# yumremove php

 

6:安裝nginx

# yuminstall nginx

#service nginx start

# chkconfig--levels 235 nginx on  //設二、三、5級別開機啓動

 

7:安裝mysql

# yuminstall mysql mysql-server mysql-devel

#service mysqld start

#chkconfig --levels 235 mysqld on

 

8:登錄MySQL刪除空用戶,修改root密碼

mysql>selectuser,host,password from mysql.user;

mysql>dropuser ''@localhost;

mysql>updatemysql.user set password = PASSWORD('*********') where user='root';

mysql>flushprivileges;

  

8:安裝php

# yuminstall php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap

php-odbcphp-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap

//安裝php和所需組件使PHP支持MySQL、FastCGI模式

#yuminstall  php-tidy php-common php-develphp-fpm php-mysql

#service php-fpm start

#chkconfig --levels 235 php-fpm on

 

9:配置nginx支持php

# mv/etc/nginx/nginx.conf /etc/nginx/nginx.confbak    //將配置文件改成備份文件

 

# cp/etc/nginx/nginx.conf.default /etc/nginx/nginx.conf   //因爲原配置文件要本身去寫所以能夠使用默認的配置文件做爲配置文件

 

//修改nginx配置文件,添加fastcgi支持

# vi/etc/nginx/nginx.conf

 

indexindex.php index.html index.htm;   //加入index.php

 

location~ \.php$ {

            root           /usr/share/nginx/html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;

            include        fastcgi_params;

        }

//將以上代碼註釋去掉,並修改爲nginx默認路徑

  

10:配置php

//編輯文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1

[root@CentOS~]# vi /etc/php.ini

 

11:重啓nginx php-fpm

#service nginx restart

#service php-fpm restart

  

12:創建info.php文件

# vi/usr/share/nginx/html/info.php

<?php

   phpinfo();

?>

13:測試nginx是否解析php

本地瀏覽器輸入:http://ip/info.php

顯示php界面 環境搭建成功

相關文章
相關標籤/搜索