centos6.2 64位LNMP(linux+nginx+mysql+php)实现
??? 現在nginx運用越來越廣泛。這是因為NGINX在某些方面優于apache。并且NGINX在web服務當中占有一定的比例,我們有必要了解和學習。下面步入正題,看LNMP架構怎么搭建。
? ? ? 首先,分析下LAMP架構的安裝。在LAMP架構中mysql,apache是可以單獨安裝不需要關聯其他兩個,而PHP即要關聯MYSQL,又要關聯apache,所以,裝PHP是關鍵。那么,在LNMP架構中,也一樣。關鍵的地方是讓NGINX來支持PHP。那怎么讓NGINX來支持PHP呢?這就用到了,PHP中的fastcgi跟fpm這兩個東東,在正常情況下Nginx和PHP他倆之間是一點感覺沒有的。在之前,很多朋友都搭建過Apache+PHP,Apache+PHP編譯后生成的是模塊文件,而Nginx+PHP需要PHP生成可執行文件才可以,所以要利用fastcgi技術來實現Nginx與PHP的整合,這個只要我們安裝是啟用FastCGI即可。此次我們安裝PHP不僅使用了FastCGI,而且還使用了PHP-FPM這么一個東東,PHP-FPM說白了是一個管理FastCGI的一個管理器。
? ? ? ?好了,現在明白了。那么,就動手吧。首先,安裝MYSQL和NGINX,
?最后添加環境變量到系統
vim?/etc/profile?PATH=$PATH:/usr/local/mysql/bin/??????????????????????????????????????????????????????????????????????????????????????????????????????????????????export?PATH然后安裝nginx,安裝nginx比較簡單了,直接運行
[root@shiyan1?nginx-1.2.6]#./configure?--prefix=/usr/local/nginx?[root@shiyan1?nginx-1.2.6]#?make?&&?make?installnginx完了,就裝PHP,這個是關鍵
[root@localhost?libmcrypt-2.5.7]#?./configure?--prefix=/usr/local/libmcrypt???[root@localhost?libmcrypt-2.5.7]#?make?&&?make?install?[root@localhost?php-5.3.10]#?./configure?--prefix=/usr/local/php5?--with-mysql=/usr/local/mysql?--with-curl?--with-libxml-dir?--with-config-file-path=/usr/local/php5/etc?--enable-ftp?--with-freetype-dir?--with-jpeg-dir?--with-png-dir?--with-zlib?--enable-xml?--enable-bcmath?--enable-shmop?--enable-sysvsem?--enable-inline-optimization?--with-curlwrappers?--enable-mbregex?--enable-zip??--with-mcrypt=/usr/local/libmcrypt??--with-gd?--enable-soap?--enable-fpm?--enable-fastcgi?運行完會提示,找不到參數enable-fastcgi.這個不用理會。直接make && make install
????[root@localhost?php-5.3.10]#?cp?php.ini-production?/usr/local/php5/etc/php.ini??????[root@localhost?php-5.3.10]#?cd?/usr/local/php5/etc/??????[root@localhost?etc]#?cp?php-fpm.conf.default?php-fpm.conf??????[root@localhost?etc]#?vim?php-fpm.conf??????[global]??????;?Pid?file??????;?Note:?the?default?prefix?is?/usr/local/php5/var??????;?Default?Value:?none??????pid?=?run/php-fpm.pid??????;?Error?log?file??????;?If?it's?set?to?"syslog",?log?is?sent?to?syslogd?instead?of?being?written??????;?in?a?local?file.??????;?Note:?the?default?prefix?is?/usr/local/php5/var??????;?Default?Value:?log/php-fpm.log??????;error_log?=?log/php-fpm.log??????[root@localhost?etc]#?cd?/usr/local/src/php-5.3.10/sapi/fpm/??????[root@localhost?fpm]#?cp?init.d.php?/etc/rc.d/init.d/php-fpm??????[root@localhost?fpm]#?service?php-fpm?start??????[root@localhost?fpm]#?cd?/usr/local/nginx/conf/nginx.conf??????????????#?pass?the?PHP?scripts?to?FastCGI?server?listening?on?127.0.0.1:9000??????????????#??????????????location?~?\.php$?{??????????????????root???????????html;??????????????????fastcgi_pass???127.0.0.1:9000;??????????????????fastcgi_index??index.php;??????????????????fastcgi_param??SCRIPT_FILENAME??/usr/local/nginx/html$fastcgi_script_name;??????????????????include????????fastcgi_params;??????????????}????????????????????#?deny?access?to?.htaccess?files,?if?Apache's?document?root??????????????#?concurs?with?nginx's?one??[root@localhost?fpm]#?/usr/local/nginx/sbin/nginx?? 把fpm跟nginx配置文件修改好啟動,lnmp就完成了。值得注意的是:php-fpm.conf這個配置文件修改的時候,只需修改一處就是,把pid?=?run/php-fpm.pid這個前面的分號去掉就可以了,而nginx配置文件把支持PHP打開就OK!
轉載于:https://blog.51cto.com/duyunlong/1142908
總結
以上是生活随笔為你收集整理的centos6.2 64位LNMP(linux+nginx+mysql+php)实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2013年2月最后一周
- 下一篇: 有用的mysql语句