自PHP-5.3.3起,PHP-FPM加入到了PHP核心,編譯時加上--enable-fpm即可提供支持。 PHP-FPM以守護進程在后臺運行,Nginx響應請求后,自行處理靜態(tài)請求,PHP請求則經(jīng)過fastcgi_pass交由PHP-FPM處理,處理完畢后返回。 Nginx和PHP-FPM的組合,是一種穩(wěn)定、高效的PHP運行方式,效率要比傳統(tǒng)的Apache和mod_php高出不少。
創(chuàng)新互聯(lián)專注于黃驊網(wǎng)站建設(shè)服務及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供黃驊營銷型網(wǎng)站建設(shè),黃驊網(wǎng)站制作、黃驊網(wǎng)頁設(shè)計、黃驊網(wǎng)站官網(wǎng)定制、小程序開發(fā)服務,打造黃驊網(wǎng)絡公司原創(chuàng)品牌,更為您提供黃驊網(wǎng)站排名全網(wǎng)營銷落地服務。//系統(tǒng)說明
1.centos6.4 IP:10.10.54.157
2.軟件版本:nginx1.4.5+mysql5.5+php5.4
//編譯安裝nginx1.4.5
1.下載nginx1.4.5 shell>wget 2.解壓nginx.1.4.5 shell>tarxvfnginx-1.4.5.tar.gz 3.編譯安裝 shell>yum-yinstallzlib-develpcre-developenssl-devel#nginx依賴包 shell>./configure--prefix=/usr/local/nginx--with-pcre--with-http_stub_status_module--user=apache--group=apache--with-http_ssl_module--with-http_gzip_static_module shell>make&&makeinstall 4.啟動nginx shell>/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf 5.打開瀏覽器測試是否可以訪問
//編譯安裝mysql5.5
1.編譯安裝 shell>groupaddmysql&&useradd-gmysqlmysql-s/sbin/nologin shell>mkdir-p/data/mysql shell>cd/home/softs/mysql-5.5.30 shell>cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/dbdata-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DWITH_PERFSCHEMA_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DMYSQL_TCP_PORT=3306-DENABLED_LOCAL_INFILE=1-DWITH_EXTRA_CHARSETS=all-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_SSL=yes shell>make&&makeinstall #配置 shell>cp-f/home/softs/mysql-5.5.30/support-files/my-large.cnf/etc/my.cnf shell>cp-f/home/softs/mysql-5.5.30/support-files/mysql.server/etc/init.d/mysqld shell>chmod755/etc/init.d/mysqld shell>vim/etc/my.cnf --------------------------- [mysqld datadir=/data/mysql socket=/usr/local/mysql/tmp/mysql.sock --------------------------- shell>chownmysql.mysql/usr/local/mysql-R #初始化數(shù)據(jù)庫 shell>/usr/local/mysql/scripts/mysql_install_db--user=root--datadir=/data/mysql--basedir=/usr/local/mysql shell>chownmysql.mysql/data/mysql-R shell>/etc/init.d/mysqldrestart #添加環(huán)境變量 shell>echo"exportPATH=${PATH}:/usr/local/mysql/bin">>/etc/profile
//編譯安裝php5.4
1.編譯前說明 #yum安裝運行環(huán)境 shell>yum–yinstalllibxml2-develcurl-devellibpng-developenldap-devel #安裝PHP前需要編譯安裝這兩個源碼包:libmcryptmhash #nginx使用fpm的方式條用php,php5.4以后版本中已經(jīng)支持php-fpm,所以只需要在php編譯參數(shù)里指定--enable-fpm即可 2.首先安裝libmcrypt-2.5.8 wgethttp://pkgs.fedoraproject.org/repo/pkgs/libmcrypt/libmcrypt-2.5.7.tar.gz/b1be163143f8e8ed0474beeb642b3bad/libmcrypt-2.5.7.tar.gz tarxvflibmcrypt-2.5.7.tar.gz cdlibmcrypt-2.5.7 ./configure make&&makeinstall 3.安裝mhash-0.9.9.9 wgethttp://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2/download tar-jxvfmhash-0.9.9.9.tar.bz2 cdmhash-0.9.9.9 ./configure make&&makeinstall 4.建立軟連接到/usr/lib ln-s/usr/local/lib/libmcrypt*/usr/lib ln-s/usr/local/lib/libmhash.*/usr/lib ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config 5.安裝php5.4 tarxvfphp-5.4.25.tar.gz cdphp-5.4.25 ./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/usr/local/mysql/tmp/mysql.sock--with-zlib--enable-xml--disable-rpath--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--with-curl--with-curlwrappers--enable-fpm--enable-fastcgi--with-mcrypt--with-gd--with-openssl--with-mhash--enable-sockets--with-ldap--with-ldap-sasl--with-xmlrpc-enable-zip--enable-soap 【error1】 configure:error:Cannotfindldaplibrariesin/usr/lib. 【solution1】 shell>ln-s/usr/lib64/libldap*/usr/lib/ shell>ldconfig 【error2】 Generatingphar.php /home/softs/php-5.4.25/sapi/cli/php:errorwhileloadingsharedlibraries:libmysqlclient.so.18:cannotopensharedobjectfile:Nosuchfileordirectory make:***[ext/phar/phar.php]Error127 【solution2】 shell>ln-s/usr/local/mysql/lib/libmysqlclient*/usr/lib/ shell>ldconfig shell>make&&makeinstall
//配置nginx支持php
1.首先為php創(chuàng)建配置文件: cpphp.ini-production/usr/local/php/php.ini mv/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf ln-s/usr/local/php/bin/php/usr/bin/ 2.配置php-fpm.conf vi/usr/local/php/etc/php-fpm.conf -------------------------------- listen=/var/run/php-fpm.sock#使用unixsocket -------------------------------- #啟動php-fpm /usr/local/php/sbin/php-fpm shell>psaux|grepphp-fpm#查看php-fpm是否成功 root34120.00.0103236892pts/3S+13:560:00grepphp-fpm root298110.00.52816085280?SsMar120:05php-fpm:masterprocess(/usr/local/php/etc/php-fpm.conf) nobody298120.01.529057615832?SMar120:00php-fpm:poolwww nobody298130.01.829349619064?SMar120:01php-fpm:poolwww nobody308390.01.128649211300?SMar120:00php-fpm:poolwww 3.配置nginx,添加支持php vi/usr/local/nginx/conf/nginx.conf ------------------------------------------------------------- http{ server{ listen80; server_namelocalhost; charsetuft-8; access_loglogs/host.access.log; location/{ #默認網(wǎng)站根目錄 root/var/www/bbs; #添加index.php的首頁文件 indexindex.phpindex.htmlindex.htm; } #添加下面的內(nèi)容,注意$document_root在默認配置文件中沒有 location~.php${ fastcgi_passunix:/var/run/php-fpm/php-fpm.sock; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME$document_root/$fastcgi_script_name; includefastcgi_params; includefastcgi.conf; } } } ------------------------------------------------------------ #修改完之后重啟nginx
//支持ssl加密傳輸
-------------------------------------------------------------- userapacheapache; worker_processes2; error_loglogs/error_nginx.log; pidlogs/nginx.pid; events{ worker_connections1024; } http{ includemime.types; default_typeapplication/octet-stream; log_formatmain\'$remote_addr-$remote_user[$time_local]"$request"\' \'$status$body_bytes_sent"$http_referer"\' \'"$http_user_agent""$http_x_forwarded_for"\'; access_loglogs/access_nginx.logmain; sendfileon; tcp_nopushon; keepalive_timeout65; gzipon; #虛擬主機配置文件 #includevirtual/www.zijian.com.conf; server{ #https加密協(xié)議默認端口 listen443; server_namebbs.zijian.com; charsetuft-8; access_loglogs/bbs.access.logmain; #網(wǎng)站根目錄 root/var/www/bbs; indexindex.phpindex.html; location~.php${ fastcgi_passunix:/var/run/php-fpm.sock; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME$document_root/$fastcgi_script_name; includefastcgi_params; includefastcgi.conf; } #配置ssl,證書用openssl工具生成,下面的路徑是證書的存放目錄,證書需要用系統(tǒng)自帶的openssl工具生成 #訪問這個server時候,用https://xxx.com格式 sslon; ssl_certificate/usr/local/nginx/conf/ssl/client.pem; ssl_certificate_key/usr/local/nginx/conf/ssl/client.key; } } -------------------------------------------------------------------
本文名稱:centos6.4下編譯安裝LNMP環(huán)境
網(wǎng)頁鏈接:http://www.rwnh.cn/article10/cposgo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、服務器托管、云服務器、網(wǎng)站策劃、網(wǎng)站設(shè)計、App設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)