centos 安装php grpc docker记录

这是记录篇,方便自己查阅,未详细的记录步骤,大致如下.

centos 分区点击done
因为默认分区 根目录只有50g,所以要自己分区。不要默认
boot分区 500M ext4
/ 1024T ext4
/home ext4

/var ext4 100g

在开机之后,发现网卡没有启动起来,进行了如下操作,还是不行
1、[root@es1 es]# ifup ens33
错误:激活连接失败:No suitable device found for this connection.
2、[root@es1 es]# systemctl start network
Job for network.service failed because the control process exited with error code. See “systemctl status network.service” and “journalctl -xe” for details

解决、先停止网卡,设置disable,然后启动,发现网卡启动了
[root@es1 es]# systemctl stop NetworkManager
[root@es1 es]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
[root@es1 es]# service network restart

yum install wget vim gcc gcc-c++

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

yum clean all
yum makecache

yum -y update && yum -y upgrade

systemctl stop firewalld.service

systemctl disable firewalld.service

systemctl status firewalld.service

yum install vim gcc gcc-c++ openssh-server vsftpd lftp tree lrzsz binutils compat-libstdc+±33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static glibc glibc-common glibc-devel glibc-headers glibc-static kernel-headers pdksh libaio-devel libaio libgcc libgomp libstdc++ libstdc+±devel make sysstat numactl-devel unixODBC unixODBC-devel git

git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

git config --global http.postBuffer 524288000
git config --global http.sslVerify false
https://github.com/git/git.git --depth 1

git config --global user.name “username”
git config --global user.email “email”

git config --global credential.helper store

cd ~
wget https://dl.google.com/go/go1.4.3.linux-amd64.tar.gz
tar –xvf go1.4.3.linux-amd64.tar

mv go go1.4
cd go1.4/src
yum install bison ed gawk gcc libc6-dev make

CGO_ENABLED=0 ./all.bash

vim /etc/profile

// 必须是go1.4

export GOROOT= H O M E / g o 1.4 e x p o r t G O B I N = HOME/go1.4 export GOBIN= HOME/go1.4exportGOBIN=HOME/Code/Go/bin
export PATH= P A T H : PATH: PATH:GOROOT/bin
export GOPATH= H O M E / C o d e / G o e x p o r t P A T H = HOME/Code/Go export PATH= HOME/Code/GoexportPATH=PATH: G O B I N : GOBIN: GOBIN:GOPKG:$GOPATH/bin

source /etc/profile
vim ~/.bashrc
source /etc/profile
:wq

wget https://golang.google.cn/dl/go1.14.4.linux-amd64.tar.gz
tar -xvf go1.14.4.linux-amd64.tar.gz
mv go go1.14.4
cd go1.14.4/src
./all.bash

sudo vim /etc/profile
export GOROOT=$HOME/go1.14.4
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
source /etc/profile
重启就行了
go version

yum install -y gcc gcc-c++ make automake

yum install centos-release-scl
yum install devtoolset-9-gcc*
scl enable devtoolset-9 bash

把下面的脚本放入/etc/init.d目录下 并给文件加上执行权限,开机启动

#/bin/bash
source /opt/rh/devtoolset-9/enable

https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3.tar.gz

./bootstrap
gmake
gmake install

curl -O https://libzip.org/download/libzip-1.5.2.tar.gz
tar -zxvf libzip-1.5.1.tar.gz

mkdir build

cd build

cmake …

make && make install

configure: error: off_t undefined; check your library configuration
(1)输入以下命令,添加搜索路径到配置文件:

echo ‘/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64’>>/etc/ld.so.conf

或者
vim /etc/ld.so.conf
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64

ldconfig -v

编译安装mysql

https://blog.csdn.net/zhang_referee/article/details/88212695
https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.25.tar.gz

tar -zxvf mysql-boost-5.7.25.tar.gz -C /usr/local/mysql/
cmake -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost
make

make install

安装php

#添加依赖运用
yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

mkdir /usr/local/src/php

cd /usr/local/src/php

wget https://www.php.net/distributions/php-7.3.18.tar.gz

wget https://www.php.net/distributions/php-5.3.29.tar.gz

tar zxvf php-7.3.18.tar.gz
cd /usr/local/src/php/php-5.3.29

./configure --prefix=/usr/local/php5.3.29
–with-config-file-path=/usr/local/php5.3.29/etc
–enable-fpm
–enable-sysvsem
–enable-pcntl
–enable-mysqlnd
–enable-opcache
–enable-shmop
–enable-zip
–enable-gd-native-ttf
–enable-wddx
–with-xmlrpc
–with-openssl
–with-zlib
–with-freetype-dir
–with-gd
–with-jpeg-dir
–with-png-dir
–enable-short-tags
–enable-sockets
–enable-zend-multibyte
–enable-soap
–enable-mbstring
–enable-static
–enable-gd-native-ttf
–with-curl
–with-xsl
–enable-ftp
–with-libxml-dir
–with-mysql=/usr/local/mysql

make
make install

cp /usr/local/php5.3.29/etc/php-fpm.conf.default php-fpm.conf

cp /usr/local/src/php/php-5.3.29/php.ini-development /usr/local/php5.3.29/etc/php.ini-development

cp /usr/local/src/php/php-5.3.29/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm5.3.29

#给权限
chmod +x /etc/init.d/php-fpm5.3.29

加入开机启动
#chkconfig --add php-fpm

设置启动等级
chkconfig --level 35 php-fpm on

设置环境变量
vim /etc/profile

底部添加
PATH=$PATH:/usr/local/php5.3.29/bin

环境变量生效
source /etc/profile

php -v 查看php版本

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar

tar -xvf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar

[root@centos-linux ~]# rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm

./configure
–prefix=/usr/local/php7.3.18
–with-config-file-path=/usr/local/php7.3.18/etc
–enable-fpm
–with-fpm-user=nginx
–with-fpm-group=nginx
–enable-inline-optimization
–disable-debug
–disable-rpath
–enable-shared
–enable-soap
–with-libxml-dir
–with-xmlrpc
–with-openssl
–with-mhash
–with-pcre-regex
–with-sqlite3
–with-zlib
–enable-bcmath
–with-iconv
–with-bz2
–enable-calendar
–with-curl
–with-cdb
–enable-dom
–enable-exif
–enable-fileinfo
–enable-filter
–with-pcre-dir
–enable-ftp
–with-gd
–with-openssl-dir
–with-jpeg-dir
–with-png-dir
–with-zlib-dir
–with-freetype-dir
–enable-gd-jis-conv
–with-gettext
–with-gmp
–with-mhash
–enable-json
–enable-mbstring
–enable-mbregex
–enable-mbregex-backtrack
–with-libmbfl
–with-onig
–enable-pdo
–with-mysqli=mysqlnd
–with-pdo-mysql=mysqlnd
–with-zlib-dir
–with-pdo-sqlite
–with-readline
–enable-session
–enable-shmop
–enable-simplexml
–enable-sockets
–enable-sysvmsg
–enable-sysvsem
–enable-sysvshm
–enable-wddx
–with-libxml-dir
–with-xsl
–enable-zip
–enable-mysqlnd-compression-support
–with-pear
–enable-opcache

make && make install

cp php.ini-production /usr/local/php7.3.18/etc/php.ini
cp /usr/local/php7.3.18/etc/php-fpm.conf.default /usr/local/php7.3.18/etc/php-fpm.conf
cp /usr/local/php7.3.18/etc/php-fpm.d/www.conf.default /usr/local/php7.3.18/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm7.3.18
chmod +x /etc/init.d/php-fpm7.3.18

// php-fpm默认监听端口是9000,若希望多版本php同时运行,则需要配置不同的监听端口
vim /usr/local/php7.2.8/etc/php-fpm.d/www.conf

查找 listen 127.0.0.1:9000
修改为 listen 127.0.0.1:9001 或其他端口

/etc/init.d/php-fpm7.2.8 start

安装grpc

git clone https://github.com/grpc/grpc.git

git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc

cd third_party/protobuf/

./configure
make
make install
ldconfig # refresh shared library cache.
which protoc
protoc --version

cd /root/grpc
make
make install

cd grpc
git pull --recurse-submodules && git submodule update --init --recursive
make & sudo make install

git submodule update --init

pecl install grpc
pecl install protobuf

Installing ‘/usr/local/php7.3.18/lib/php/extensions/no-debug-non-zts-20180731/protobuf.so’
install ok: channel://pecl.php.net/protobuf-3.12.2
configuration option “php_ini” is not set to php.ini location
You should add “extension=protobuf.so” to php.ini

Build process completed successfully
Installing ‘/usr/local/php7.3.18/lib/php/extensions/no-debug-non-zts-20180731/grpc.so’
install ok: channel://pecl.php.net/grpc-1.30.0
configuration option “php_ini” is not set to php.ini location
You should add “extension=grpc.so” to php.ini

extension=/usr/local/php7.3.18/lib/php/extensions/no-debug-non-zts-20180731/protobuf.so
extension=/usr/local/php7.3.18/lib/php/extensions/no-debug-non-zts-20180731/grpc.so

php -m | grep “protobuf”

php -m | grep “grpc”
grpc

php -r “copy(‘https://install.phpcomposer.com/installer’, ‘composer-setup.php’);”

php composer-setup.php

mv composer.phar /usr/local/bin/composer
composer config -g repo.packagist composer https://packagist.phpcomposer.com

composer selfupdate
composer self-update

或者:
composer require grpc/grpc --profile --prefer-dist --optimize-autoloader

composer require google/protobuf --profile --prefer-dist --optimize-autoloader

composer install
protoc --proto_path=./ --go_out=plugins=grpc:./ odbInterface.proto
protoc --php_out=./ --grpc_out=./ --plugin=protoc-gen-grpc=/usr/local/bin/grpc_php_plugin odbInterface.proto

protoc -I helloworld/ helloworld/helloworld.proto --go_out=plugins=grpc:helloworld

阿里云 :

vim /etc/ssh/sshd_config
找到以下两项配置

#ClientAliveInterval 0
#ClientAliveCountMax 3
修改为

ClientAliveInterval 30
ClientAliveCountMax 86400
1、客户端每隔多少秒向服务发送一个心跳数据

2、客户端多少秒没有相应,服务器自动断掉连接

重启sshd服务(centos7+)

systemctl restart sshd

server
{
listen 80;
server_name doc.feijianshen.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/doc.feijianshen.com;

location / {
proxy_pass http://xxxxxxx:8181;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

access_log  /www/wwwlogs/doc.feijianshen.com.log;
error_log  /www/wwwlogs/doc.feijianshen.com.error.log;

}

alpine 镜像

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install docker-ce

开机自动启动
service docker start
查看版本:
docker version
配置镜像加速器
https://cr.console.aliyun.com/cn-shanghai/instances/mirrors

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-‘EOF’
{
“registry-mirrors”: [“https://xxxx.mirror.aliyuncs.com”]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

安装 docker-compose

yum -y install epel-release

sudo yum -y install python-pip

sudo yum -y install python-devel

sudo python -m pip install --upgrade --force pip

~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

sudo pip install setuptools==33.1.1
pip install docker-compose
docker-compose --version

docker-compose up -d

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值