树莓派 编译nginx添加nginx-rtmp-module-master

牛兴安
2023-12-01

 编译nginx添加nginx-rtmp-module-master

更新软件和系统

sudo apt-get update
sudo apt-get upgrade
 

下载树莓派头文件

sudo apt install raspberrypi-kernel-headers

下载需要的文件

nginx官网下载 https://nginx.org/en/download.html

sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev


wget https://github.com/arut/nginx-rtmp-module/archive/master.zip


unzip master.zip

wget http://nginx.org/download/nginx-1.23.1.tar.gz

 tar -zxvf nginx-1.23.1.tar.gz

cd nginx-1.23.1

./configure --add-module=../nginx-rtmp-module-master --with-http_ssl_module --with-debug

 make


 sudo make install

sudo /usr/local/nginx/sbin/nginx
启动服务

make && make install

/usr/local/nginx/sbin/nginx                      //启动nginx

/usr/local/nginx/sbin/nginx -t                   //检查nginx配置文件

/usr/local/nginx/sbin/nginx -v                   // 查看版本

/usr/local/nginx/sbin/nginx -V                   // 查看编译参数

/usr/local/nginx/sbin/nginx -s reload            // 重新载入配置文件

/usr/local/nginx/sbin/nginx -s reopen            // 重启 Nginx

/usr/local/nginx/sbin/nginx -s stop             // 停止 Nginx
 

sudo /usr/local/nginx/sbin/nginx
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/nginx/conf/nginx.conf:151
nginx: [emerg] cannot load certificate "/usr/local/nginx/cert/server.crt": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/usr/local/nginx/cert/server.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
 拷贝证书文件开启ssl
 
 $ sudo cp -p -r -f "/media/rootfs/usr/local/nginx/cert" "/usr/local/nginx/cert"
 $ sudo /usr/local/nginx/sbin/nginx


nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/nginx/conf/nginx.conf:151
nginx: [emerg] mkdir() "/var/www/" failed (2: No such file or directory)
创建站点目录
 $ sudo mkdir -p /var/www/
 重新启动服务
 $ sudo /usr/local/nginx/sbin/nginx
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/nginx/conf/nginx.conf:151
nginx: [emerg] open() "/var/log/nginx/nginx-error.log" failed (2: No such file or directory)
 $  sudo mkdir -p /var/log/nginx/
建立日志文件
 $ sudo nano /var/log/nginx/nginx-error.log

安装php

#查询现有安装源的php版本号
apt-cache show php
#安装其他所需的软件包
sudo apt-get install apt-transport-https lsb-release ca-certificates -y
#保存php包相应密钥到本地信任
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
#把第三方源写入本地文件源文件
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
#更新安装包信息
sudo apt-get update
#查看安装情况
php -v
sudo apt install php7.3 php7.3-fpm php7.3-mysql php7.3-common php-pear php7.3-curl php7.3-gd php7.3-mcrypt
php -v
建立测试文件test.php

<?php 
    phpinfo(); 
?>

服务运行成功


mysqlnd statistics	
bytes_sent	0
bytes_received	0
packets_sent	0
packets_received	0
protocol_overhead_in	0
protocol_overhead_out	0
bytes_received_ok_packet	0
bytes_received_eof_packet	0
bytes_received_rset_header_packet	0
bytes_received_rset_field_meta_packet	0
bytes_received_rset_row_packet	0
bytes_received_prepare_response_packet	0
bytes_received_change_user_packet	0
packets_sent_command	0
packets_received_ok	0
packets_received_eof	0
packets_received_rset_header	0
packets_received_rset_field_meta	0
packets_received_rset_row	0
packets_received_prepare_response	0
packets_received_change_user	0
result_set_queries	0
non_result_set_queries	0
no_index_used	0
bad_index_used	0
slow_queries	0
buffered_sets	0
unbuffered_sets	0
ps_buffered_sets	0
ps_unbuffered_sets	0
flushed_normal_sets	0
flushed_ps_sets	0
ps_prepared_never_executed	0
ps_prepared_once_executed	0
rows_fetched_from_server_normal	0
rows_fetched_from_server_ps	0
rows_buffered_from_client_normal	0
rows_buffered_from_client_ps	0
rows_fetched_from_client_normal_buffered	0
rows_fetched_from_client_normal_unbuffered	0
rows_fetched_from_client_ps_buffered	0
rows_fetched_from_client_ps_unbuffered	0
rows_fetched_from_client_ps_cursor	0
rows_affected_normal	0
rows_affected_ps	0
rows_skipped_normal	0
rows_skipped_ps	0
copy_on_write_saved	0
copy_on_write_performed	0
command_buffer_too_small	0
connect_success	0
connect_failure	0
connection_reused	0
reconnect	0
pconnect_success	0
active_connections	0
active_persistent_connections	0
explicit_close	0
implicit_close	0
disconnect_close	0
in_middle_of_command_close	0
explicit_free_result	0
implicit_free_result	0
explicit_stmt_close	0
implicit_stmt_close	0
mem_emalloc_count	0
mem_emalloc_amount	0
mem_ecalloc_count	0
mem_ecalloc_amount	0
mem_erealloc_count	0
mem_erealloc_amount	0
mem_efree_count	0
mem_efree_amount	0
mem_malloc_count	0
mem_malloc_amount	0
mem_calloc_count	0
mem_calloc_amount	0
mem_realloc_count	0
mem_realloc_amount	0
mem_free_count	0
mem_free_amount	0
mem_estrndup_count	0
mem_strndup_count	0
mem_estrdup_count	0
mem_strdup_count	0
mem_edupl_count	0
mem_dupl_count	0
proto_text_fetched_null	0
proto_text_fetched_bit	0
proto_text_fetched_tinyint	0
proto_text_fetched_short	0
proto_text_fetched_int24	0
proto_text_fetched_int	0
proto_text_fetched_bigint	0
proto_text_fetched_decimal	0
proto_text_fetched_float	0
proto_text_fetched_double	0
proto_text_fetched_date	0
proto_text_fetched_year	0
proto_text_fetched_time	0
proto_text_fetched_datetime	0
proto_text_fetched_timestamp	0
proto_text_fetched_string	0
proto_text_fetched_blob	0
proto_text_fetched_enum	0
proto_text_fetched_set	0
proto_text_fetched_geometry	0
proto_text_fetched_other	0
proto_binary_fetched_null	0
proto_binary_fetched_bit	0
proto_binary_fetched_tinyint	0
proto_binary_fetched_short	0
proto_binary_fetched_int24	0
proto_binary_fetched_int	0
proto_binary_fetched_bigint	0
proto_binary_fetched_decimal	0
proto_binary_fetched_float	0
proto_binary_fetched_double	0
proto_binary_fetched_date	0
proto_binary_fetched_year	0
proto_binary_fetched_time	0
proto_binary_fetched_datetime	0
proto_binary_fetched_timestamp	0
proto_binary_fetched_string	0
proto_binary_fetched_json	0
proto_binary_fetched_blob	0
proto_binary_fetched_enum	0
proto_binary_fetched_set	0
proto_binary_fetched_geometry	0
proto_binary_fetched_other	0
init_command_executed_count	0
init_command_failed_count	0
com_quit	0
com_init_db	0
com_query	0
com_field_list	0
com_create_db	0
com_drop_db	0
com_refresh	0
com_shutdown	0
com_statistics	0
com_process_info	0
com_connect	0
com_process_kill	0
com_debug	0
com_ping	0
com_time	0
com_delayed_insert	0
com_change_user	0
com_binlog_dump	0
com_table_dump	0
com_connect_out	0
com_register_slave	0
com_stmt_prepare	0
com_stmt_execute	0
com_stmt_send_long_data	0
com_stmt_close	0
com_stmt_reset	0
com_stmt_set_option	0
com_stmt_fetch	0
com_deamon	0
bytes_received_real_data_normal	0
bytes_received_real_data_ps	0
openssl
OpenSSL support	enabled
OpenSSL Library Version	OpenSSL 1.1.1n 15 Mar 2022
OpenSSL Header Version	OpenSSL 1.1.1n 15 Mar 2022
Openssl default config	/usr/lib/ssl/openssl.cnf
Directive	Local Value	Master Value
openssl.cafile	no value	no value
openssl.capath	no value	no value
pcre
PCRE (Perl Compatible Regular Expressions) Support	enabled
PCRE Library Version	10.40 2022-04-14
PCRE Unicode Version	14.0.0
PCRE JIT Support	enabled
PCRE JIT Target	ARM-64 64bit (little endian + unaligned)
Directive	Local Value	Master Value
pcre.backtrack_limit	1000000	1000000

二、安装配置phpmyadmin

1. 下载并解压到phpmyadmin
官方下载页面:http://www.phpmyadmin.net/home_page/downloads.php
(中文用户应该选择下载all-languages版本)

下载完成后,解压:

unzip phpMyAdmin-4.1.12-all-languages.zip

移动到相应的目录位置,并改成容易访问的名称:

mv phpMyAdmin-4.1.12-all-languages /www/phpmyadmin

2. 配置phpmyadmin

复制一份配置文件:

#cd /www/phpmyadmin
#cp config.sample.inc.php config.inc.php

配置config.inc.php

#vi config.inc.php

设置一个内部使用的秘钥(和内部加密有关,与页面登录没有直接关系)

$cfg['blowfish_secret'] = ‘www.tudaxia.com';

三、配置Nignx下的站点

vi /etc/nginx/conf.d/phpmyadmin.conf
server {
 listen 8081;
 server_name localhost;
 access_log /var/log/nginx/phpmyadmin-access.log main;

 location / {
  root /www/phpmyadmin;
  index index.php;
 }

 location ~ \.php$ {
  root /www/phpmyadmin;
  fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
 }

 location ~ /\.ht {
  deny all;
 }
}

重启nginx:

#service nginx restart

完成安装,访问http://yourserver:8081/,测试phpmyadmin。

四、phpmyadmin加载缓慢的解决方法


phpmyadmin4.0系列通通加载缓慢的最终原因是最近phpmyadmin的官网经常打不开,而phpmyadmin页面会自动检查官网上的程序 版本更新,所以当你进入phpmyadmin管理页面点击数据库的时候phpmyadmin一直在尝试连接官网从而把整个打开过程拖得很慢。

最终的解决办法是不让phpmyadmin检查更新,找到phpmyadmin目录下version_check.php文件,具体修改如下:

if (isset($_SESSION['cache']['version_check'])
  && time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6
) {
  $save = false;
  $response = $_SESSION['cache']['version_check']['response'];
} else {
//  $save = true;
//  $file = 'http://www.phpmyadmin.net/home_page/version.json';
//  if (ini_get('allow_url_fopen')) {
//    $response = file_get_contents($file);
//  } else if (function_exists('curl_init')) {
//    $curl_handle = curl_init($file);
//    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
//    $response = curl_exec($curl_handle);
//  }
}

上面代码是通过注释掉else{......}中间这段来取消phpmyadmin连接官网version.json来检查更新

修改完后phpmyadmin马上又回到秒开了。

 类似资料: