linux下搭建LAMP环境
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
#准备工作 安装相应的系统包
yum update
yum -y install curl-devel
yum install libpng
yum install libpng-devel
yum install freetype-devel
yum install libxslt-devel* -y
# 源码准备
cd ~
tar -zxvf nginx-1.15.2.tar.gz
tar -zxvf php-7.2.12.tar.gz
tar -zxvf phpredis-4.1.0RC3.tar.gz
mkdir /usr/local/php72soft
cd /usr/local/php72soft/
cp -r ~/nginx-1.15.2 ./
cp -r ~/php-7.2.12 ./
cp -r ~/phpredis-4.1.0RC3 ./
# 源码安装nginx
cd /usr/local/php72soft/nginx-1.15.2/
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make & make install
# 源码安装php 包含相应的依赖
cd /usr/local/php72soft/php-7.2.12/
./configure --prefix=/usr/local/php72 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
make & make install
# 通过源码安装phpredis扩展
cd /usr/local/php72soft/phpredis-4.1.0RC3/
/usr/local/php72/bin/phpize
./configure --with-php-config=/usr/local/php72/bin/php-config --enable-redis
make & make install
# 修改nginx.conf 添加如下内容
fastcgi_buffer_size 64k;
fastcgi_buffers 8 64k;
server {
location ~ \.php$ {
root /www/wwwroot/phonelive/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
client_max_body_size 64m; # 改为你需要的大小!
}
location / {
root /www/wwwroot/phonelive/public;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/([0-9]+)$ /home/show/index?roomnum=$1 last;
#rewrite ^/([0-9]+)$ /index.php?m=Show&a=index&roomnum=$1 last;
#rewrite ^(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
client_max_body_size 64m; # 改为你需要的大小!
}
}
# 启动nginx
usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# 重载nginx配置
usr/local/nginx/sbin/nginx -s reload
# 重启nginx
usr/local/nginx/sbin/nginx -s reopen
# 拷贝php.ini(源码安装默认没有配置文件)
cp /usr/local/php72soft/php-7.2.12/php.ini-production /usr/local/php72/lib/php.ini
# 修改php.ini,添加redis依赖,在最末尾添加
upload_max_filesize = 200M
extension=/usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/mongodb.so
extension=/usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/redis.so
# 拷贝php-fpm配置
cp /usr/local/php72/etc/php-fpm.d/www.conf.default /usr/local/php72/etc/php-fpm.d/www.conf
# php-fpm测试启动
/usr/local/php/sbin/php-fpm -c /usr/local/php72/lib/php.ini -y /usr/local/php72soft/php-7.2.12/sapi/fpm/php-fpm.conf -t
# 正式启动php-fpm
/usr/local/php/sbin/php-fpm -c /usr/local/php72/lib/php.ini -y /usr/local/php72soft/php-7.2.12/sapi/fpm/php-fpm.conf
# 部署项目
mkdir /www
mkdir /www/wwwroot
mv ~/phonelive.tar.gz /www/wwwroot/
tar -zxvf phonelive.tar.gz
##############如果是内网部署的,还需要一台跳板转发进内网,进行测试,使用nginx进行反向代理即可#############
server {
listen 80;
server_name localhost;
#index index.php index.html index.htm;
#access_log logs/host.access.log main;
location / {
proxy_pass http://172.16.0.7:80; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让8080端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
项目中用到了一个多线程的扩展,如果目标位置没有需要编译一下
/usr/local/php72soft/php-7.2.12/ext/pcntl/modules/pcntl.so
编译步骤
cd /usr/local/php72soft/php-7.2.12/ext/pcntl
/usr/local/php72/bin/phpize
./configure --with-php-config=/usr/local/php72/bin/php-config
make & make install
安装包下载链接
https://download.csdn.net/download/wang386476890/14038056
最后贴上nginx配置文件
#user nobody;
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
error_log logs/error.log crit;
pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 16 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
tcp_nodelay on;
client_max_body_size 200m; # 请求体大小
#gzip on;
#gzip_min_length 1k;
#gzip_buffers 4 16k;
#gzip_http_version 1.0;
#gzip_comp_level 2;
#gzip_types text/plain application/x-javascript text/css application/xml;
#gzip_vary on;
server {
listen 80;
server_name localhost;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root /www/wwwroot/phonelive/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
root /www/wwwroot/phonelive/public;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/([0-9]+)$ /home/show/index?roomnum=$1 last;
#rewrite ^/([0-9]+)$ /index.php?m=Show&a=index&roomnum=$1 last;
#rewrite ^(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
}
}
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:23 天前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献4条内容
所有评论(0)