远程管理项目部署(lamp)@Author:Tim Lu

远程管理项目部署(lamp)@Author:Tim Lu

切换至root用户

su 切换到root用户

修改Ubuntu的apt-get源为国内镜像源

原文件备份

cp /etc/apt/sources.list /etc/apt/sources.list.bak

2 编辑源列表文件(建议用阿里云源)

vim /etc/apt/sources.list

把下面的任意一下复制到sources.list中去,并覆盖原来的文件内容

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

update命令

apt-get update

部署lamp运行环境

安装扩展PHP

Ubuntu 16.04默认安装php7.0环境,但是php7目前兼容性并不是很好,如果自行安装php5.6需要清除php7的已安装包,否则会报错

dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
apt-get install aptitude
aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`

添加 PPA

add-apt-repository ppa:ondrej/php

如果提示add-apt-repository找不到:
先安装
apt-get install python-software-properties
再安装
apt-get install software-properties-common
然后再执行上面的安装命令就行了。

安装php5.6及其它库安装

apt-get update
apt-get install php5.6
apt-get install php5.6-gd
apt-get install php5.6-dev
apt-get install php5.6-zip

测试:php -v

安装Apache2

apt install apache2
apt-get install libapache2-mod-php5.6

测试: 浏览器访问http://Ubuntu的IP,出现It Works!网页。
查看状态: service apache2 status/start/stop/restart
Web目录: /var/www
安装目录: /etc/apache2/
全局配置: /etc/apache2/apache2.conf
监听端口: /etc/apache2/ports.conf
虚拟主机: /etc/apache2/sites-enabled/000-default.conf

安装MySQL

apt-get install mysql-server mysql-client
apt-get install php5.6-mysql
mysql_secure_installation

初始账号:root 密码:123456

测试: mysql -u root -p
查看状态: service mysql status/start/stop/retart
查看监听端口的情况: netstat -tunlp 或 netstat -tap

重启服务

service apache2 restart
service mysql restart

测试Apache能否解析PHP
vim /var/www/html/phpinfo.php
文件中写:<?php echo phpinfo();?>
浏览器访问:http://ubuntu地址/phpinfo.php,出现PHP Version网页

其他扩展库安装及配置

Redis安装

redis安装及支持php

apt-get install redis-server
apt-get install php5.6-redis

安装完成后,Redis服务器会自动启动,我们检查Redis服务器程序
查看状态: service redis-server status/start/stop/restart

配置redis多端口,新增6380端口

配置端口

redis-server默认启动的端口是6379,使用的是默认的配置文件/etc/redis/redis.conf
比如现在要开启6380端口,先复制默认的配置文件为redis_6380:
cp /etc/redis/redis.conf /etc/redis/redis_6380.conf
编辑redis_6380.conf文件:
vim /etc/redis/redis_6380.conf
进行下面内容修改:
pidfile /var/run/redis/redis-server6380.pid
port 6380
logfile /var/log/redis/redis-server6380.log
dbfilename dump6380.rdb
保存,启动这个配置文件
redis-server /etc/redis/redis_6380.conf

查看redis运行进程

ps -ef | grep redis

redis出现6379、6380两个端口运行进程

测试

redis-cli -p 6379
redis-cli -p 6380

Curl安装

apt-get install curl

Composer安装

apt-get install composer

Zip安装

apt-get install zip

远程管理:remote_manage_system项目部署

删除/var/www/中html文件夹

rm -rf /var/www/html/

clone项目文件

将remote_manage_system,database放置/var/www/

执行数据库文件

执行database中mythware_remote.sql文件创建数据库

修改apache2默认访问文件夹,访问远程管理项目



1:访问远程管理系统,直接访问IP地址:
vi /etc/apache2/sites-available/000-default.conf
修改
DocumentRoot /var/www/html

DocumentRoot /var/www/dist

2:后端API访问地址需添加二级域名remote
vi /etc/apache2/apache2.conf
找到
<Directory /var/www/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
后面添加
Alias /remote /var/www/remote_manage_system/public/
<Directory /var/www/remote_manage_system/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

3:重启apache2
service apache2 restart

进入项目中(remote_manage_system)

根目录:
1:修改env文件
cp .env.example .env

修改mysql,redis配置信息
vi .env

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mythware_remote
DB_USERNAME=root
DB_PASSWORD=123456

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6380

.....

remote_api_url=http://192.168.0.240/remote/
vswitch_server_url=192.168.0.253
vswitch_server_port=8022
vswitch_redis_server_url=192.168.0.253
vswitch_redis_server_port=6379
dm_valid_url=192.168.0.240:7000/api/deviceinfo
dm_account=admin
dm_password=Mythware123

2:解压缩vendor.zip文件夹
unzip vendor.zip
rm vendor.zip

3:修改 storage/ bootstrap/cache/ public/这三个文件夹读写权限
chmod -R a+w storage/
chmod -R a+w bootstrap/cache
chmod –R a+w public/

4:项目根目录下:ext文件夹中将扩展库更新到php类库中
cp /var/www/remote_manage_system/ext/* /usr/lib/php/20131226/
php环境类库目录: /usr/lib/php/20131226/
更新php.ini,加载ext库
vi /etc/php/5.6/apache2/php.ini
找到;extension=php_xsl.dll这行 下面添加
extension=remoteproto.so
extension=vswitch.so
重启apache生效
service apache2 restart

访问项目

直接访问当前Ubantu IP地址



1:支持laravel URL重写
a2enmod rewrite
2:去除访问url中的index.php 支持.htaccess
vi /etc/apache2/apache2.conf

<Directory /var/www/>
Options FollowSymLinks
AllowOverride none
Require all granted
</Directory>

<Directory /var/www/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
3:重启apache2
service apache2 restart

5:启动crotab,修改定时执行任务,定时更新设备在线,离线状态



crontab -e
检查设备在线状态,更新设备在线离线,每三秒执行一次,添加下面内容:
*/1 * * * * /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 3 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 6 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 9 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 12 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 15 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 18 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 21 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 24 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 27 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 30 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 33 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 36 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 39 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 42 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 45 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 48 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 51 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 54 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy
*/1 * * * * sleep 57 && /usr/bin/php /var/www/remote_manage_system/artisan laravel:academy

重启crontab
service cron restart

6:启动workerman进程,socket服务端



进入项目文件夹
cd /var/www/remote_manage_system/
php artisan wk start
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值