新聞中心
centos 6.5 源碼編譯搭建LNMP(三臺(tái)獨(dú)立主機(jī)實(shí)現(xiàn))

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供桃城網(wǎng)站建設(shè)、桃城做網(wǎng)站、桃城網(wǎng)站設(shè)計(jì)、桃城網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、桃城企業(yè)網(wǎng)站模板建站服務(wù),十余年桃城做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
搭建前準(zhǔn)備:
1.三臺(tái)獨(dú)立主機(jī)
nginx:192.168.1.102
php-fpm:192.168.1.105
MySQL:192.168.1.103
2.相關(guān)軟件的源碼包
nginx:nginx-1.10.2
php:php-5.6.28
mysql:mariadb-5.5.53
3.開(kāi)發(fā)環(huán)境及依賴包組
包:openssl-devel;pcre-devel;zlib-devel
包組:Development Tools;Server Platform Development
開(kāi)始搭建:
第一臺(tái)主機(jī)的操作:nginx服務(wù)器主機(jī)
1.解壓展開(kāi)源碼包nginx-1.10.2.tar.gz
tar -xf nginx-1.10.2.tar.gz
2.創(chuàng)建相應(yīng)路徑以便編譯時(shí)使用
mkdir -pv /var/cache/nginx
3.cd至nginx-1.10.2目錄,運(yùn)行以下命令
./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-file-aio --with-http_v2_module
4.make && make install 即可
5.開(kāi)啟nginx,在瀏覽器測(cè)試,出現(xiàn)即沒(méi)有問(wèn)題
6.配置nginx支持php-fpm
#vim /etc/nginx/nginx.conf 寫入
server {
listen 80;
server_name www.a.com;
location / {
root /test/html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /test/html;
fastcgi_pass 192.168.1.105:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/test1/$fastcgi_script_name;
include fastcgi_params;
}
}
第二臺(tái)主機(jī)的操作:php的主機(jī)
1.解壓展開(kāi)源碼包php-5.6.28.tar.bz2
2.cd至php-5.6.28目錄,執(zhí)行
./configure --prefix=/usr/local/php56 --with-mysql --with-openssl --with-mysqli --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-mcrypt --with-config-file-path=/etc/php56 --with-config-file-scan-dir=/etc/php56.d --with-bz2 --enable-fpm
其中,--enable-fpm是關(guān)鍵選項(xiàng)
3.make && make install
4.配置文件的操作
?、?cp php.ini-development /etc/php.ini
②#cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm (將php-fpm加入到系統(tǒng)服務(wù)中)
?、?chkconfig --add php-fpm
查看添加結(jié)果:#chkconfig --list php-fpm
則完成添加;
注意:此處復(fù)制php-fpm到/etc/rc.d/init.d/目錄下時(shí),有可能php-fpm自身沒(méi)有任何執(zhí)行權(quán)限,會(huì)導(dǎo)致添加系統(tǒng)服務(wù)時(shí)失敗,自行添加執(zhí)行權(quán)限即可解決這個(gè)問(wèn)題
5.修改php-fpm配置文件
?、傩薷膒hp-fpm的pid設(shè)置
?、谛薷膒hp-fpm的進(jìn)程屬主
?、坌薷膒hp-fpm的監(jiān)聽(tīng)地址
這幾項(xiàng)是服務(wù)正常開(kāi)啟運(yùn)行的比較關(guān)鍵的幾項(xiàng),其余配置在此不再贅述
6.開(kāi)啟php-fpm服務(wù)
service php-fpm start
確保PHP主機(jī)的IP:9000處于監(jiān)聽(tīng)狀態(tài)即可
7.創(chuàng)建動(dòng)態(tài)資源目錄,做測(cè)試用,此處是/www/test1目錄,創(chuàng)建一個(gè)index.php文件
8.開(kāi)始測(cè)試,效果如下
新聞名稱:CentOS6.5源碼編譯搭建LNMP(三臺(tái)獨(dú)立主機(jī)實(shí)現(xiàn))
網(wǎng)頁(yè)地址:http://m.fisionsoft.com.cn/article/dhhgdch.html


咨詢
建站咨詢
