有流媒體功能的lnmp部署練習,強化練習

第一步:

         安裝redis3.0.2:

                   下載安裝包並解壓:

                   tar-zxvf redis-3.0.2.tar.gz

                   yuminstall gcc gcc-c++ cmake make automake tcl –y

                   makeMALLOC=libc

                   cd  src && make test (建議測試)

                   makeinstall (生成redis命令)l

                   cdutils && ./install_server.sh  按照交互命令配置即可

         配置 redis.conf

                   可以設置成daemonizeyes

 

第二步:

         基本要求如圖:

         說明: E:\qq\data\769079707\FileRecv\MobileFile\BI8FNBXU`E{L%PFWM}%PY6Y.png

         安裝nginx

                   創建nginx用戶和組

                   Groupaddnginx

                   Useradd–g nginx nginx

                   Yuminstall –y pcre-devel openssl-devel

                   下載並解壓nginx  nginx 的兩個流媒體第三方模塊

Wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz

              tar –zxvf nginx_mod_h264_streaming-2.2.7.tar.gz

                   unzipngx_cache_purge-master.zip

                   unzipnginx-rtmp-module-master.zip

tar -zxvf nginx-1.2.1.tar.gz

                   cdnginx-1.2.1

                   ./configure--prefix=/usr/local/nginx --user=nginx --group=nginx--add-module=../nginx-rtmp-module-master --add-module=../ngx_cache_purge-master--add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_stub_status_module--with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module--with-http_flv_module --with-http_secure_link_module

 

                   Make

 

Make 中可能遇到問題:
/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:In function ‘ngx_streaming_handler’:
/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158:error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’
make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o]Error 1
make[1]: Leaving directory `/root/nnginx-1.5.9'
make: *** [build] Error 2
那麼將src/ngx_http_streaming_module.c文件中以下代碼刪除或者是註釋掉就可以了:

/* TODO: Win32 */
if (r->zero_in_uri)
{
     return NGX_DECLINED;
}

 

Make install  成功安裝

 

 

安裝mysql:

         解壓mysql

         tar-zxvf mysql-5.5.51.tar.gz

         cdmysql-5.5.51

         yuminstall ncurses-devel -y

 

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk-DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1-DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

 

make && make install

 

 

cp surpport-files/my-medium.cnf /etc/my.cnf

3.2 初始化數據庫

 

scripts/mysql_install_db --user=mysql –basedir=/usr/local/mysql–datadir=/usr/local/mysql/data

 

請注意使用這個support下面的腳本文件,不要使用編譯目錄中的support-file中的

Cd /usr/local/mysql

cp surpport-files/mysql.server/etc/init.d/mysqld

 

chmod 755 /etc/init.d/mysql

ln –s /usr/local/mysql/bin/* /usr/bin/

 

啓動之前建議在修改兩個文件中/etc/my.cnf /etc/init.d/mysqld basedir datadir參數

例如:

         Basedir=/usr/local/mysql

         Datadir=/usr/local/mysql/data

還有就是mysql.sock client端和mysqld 端應該一致如都指向

 mysql.sock = /tmp/mysql.sock     

不然啓動的時候會報錯:

                   spacer.gif

/etc/init.d/mysql start

使用mysqladmin創建root用戶密碼(注意先啓動服務後才能重置密碼)

如:

mysqladmin -u root password '123456'

 

mysql 安裝完畢!! 

 

php 安裝:    

         下載並解壓php5.5.35

         tar-zxvf php-5.5.35.tar.gz

        

準備php 編譯條件:

groupadd www

useradd –g www www

        

Yum install freetype-devel openssl-devel libxml2-devellibjpeg-devel libpng-devel curl-devel  -y

開始編譯:

cd php-5.5.35

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --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 --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache–-with-curl=/usr/local/curl

 

 

 

如果報錯: vim /etc/ld.so.conf.d/local.conf

                    /usr/local/lib64 (64os)

                   /usr/local/lib(i386os)

然後   ldconfig –v

再次編譯就好了

# cp php.ini-development/usr/local/php/lib/php.ini

# cp/usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

# cp/usr/local/php/etc/php-fpm.d/www.conf.default/usr/local/php/etc/php-fpm.d/www.conf

# cp -R ./sapi/fpm/php-fpm/etc/init.d/php-fpm

測試:

         spacer.gif

 

端口監聽正常即可

 

 

最後一步:配置nginx php fastcgi:

我這裏配置的是vhost 域名主機版本

1.  首先將主配置文件nginx.conf下做一些全局的參數,我這裏就不配置了

2.  將主配置文件中的server全部註釋

3.  在主配置文件的末尾引入 vhost即:

spacer.gif

4.  測試一下配置文件:     

spacer.gif

 

5.  conf目錄下新建vhost 目錄 並將所有者和所屬組設置成www

Mkdir /usr/local/nginx/conf/vhost && chown –Rwww:www /usr/local/nginx/conf/vhost

spacer.gif

6.  vhost 目錄下 vim 一個新的域名主機 名字隨便起,我就叫default.conf

         spacer.gif

6.  再次測試 配置文件的正確性

spacer.gif

7.  在項目下寫一段phpinfo()函數的文件並啓動或重啓nginx測試

spacer.gif

8 測試結果:

                   spacer.gif

         Ok!! 今天完工。明天繼續,睡覺!! 晚安!!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章