前面兩篇内容我們聊過了直播平台搭建前需要準備的内容,一切準備就緒之後就要進入正式的搭建部署環節了,本篇就先簡單介紹下LNMP環境下的PHP配置。
PHP 編譯安裝 1. 解決php安裝的庫依賴關系cp-frp /usr/lib64/libjpeg.* /usr/lib
cp-frp /usr/lib64/libpng* /usr/lib
cp -frp /usr/lib64/libldap* /usr/lib/
echo /usr/local/mysql/lib >> /etc/ld.so.conf.d/mysql-x86_64.conf
ldconfig -v
2. 編譯安裝phptar xf php-5.6.17.tar.gz
cdphp-5.6.17
./configure --prefix=/usr/local/php
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-iconv-dir=/usr/local --with-openssl
--enable-mbstring
--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib
--with-libxml-dir=/usr
--enable-xml --disable-rpath --enable-bcmath
--enable-shmop --enable-sysvsem
--enable-inline-optimization --enable-mbregex
--enable-mbstring --with-gd --enable-gd-native-ttf
--with-mhash --enable-pcntl
--enable-sockets --with-mcrypt --with-ldap --with-ldap-sasl--with-xmlrpc
--enable-zip --enable-soap --with-bz2 --with-config-file-path=/etc --enable-fpm
--with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts
make ZEND_EXTRA_LIBS='-liconv'
make install
3. 複制PHP配置檔案cp php.ini-production /etc/php.ini
4. 複制php-fpm配置檔案cp /usr/local/php/etc/php-fpm.conf.default
/usr/local/php/etc/php-fpm.conf
5. 設定php-fpm啟動腳本并開機啟動cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
web 功能基本實作 1.nginx,php 功能整合vim /etc/nginx/nginx.conf
#location ~ \.php$ {
# root html;
#
fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
fastcgi_param
SCRIPT_FILENAME
/scripts$fastcgi_script_name;
# include fastcgi_params;
#}
#修改為
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
增加LNMP測試頁面vim /usr/local/nginx/html/test.php
<?php$link = mysql_connect('127.0.0.1','root','you_passwd');
if($link)
echo"It's OK,Frank";
else"Failed,Frank";
mysql_close;
phpinfo();
?> 3.nginx 重載service nginx reload
通路 http://ip/test.php,LNMP 測試成功以上就是直播系統搭建過程中LNMP搭建環境下的PHP配置流程,希望對大家有所幫助。
備注:搭建資料整理自網絡,适用于直播系統搭建LNMP環境下的PHP配置
閱讀原文