python 环境
cd /opt;
yum -y install openssl-devel zlib-devel gcc gcc-c++ git curl zip sqlite-devel bzip2-devel tcl tk tix-devel tk-devel;
wget https://www.python.org/ftp/python/3.5.5/Python-3.5.5.tar.xz;
xz -d Python-3.5.5.tar.xz && tar xvf Python-3.5.5.tar;
cd Python-3.5.5; ./configure; make && make install;
ln -s /opt/Python-3.5.5/python /usr/bin/python3;
# 然后 Successfully installed pip-9.0.1 setuptools-28.8.0 都自动安装好了,考虑周到,点赞!
TF 和 TFServing 环境
pip3 install tensorflow;
pip3 install tensorflow-serving-client;
wget https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-7/vbatts-bazel-epel-7.repo -O /etc/yum.repos.d/vbatts-bazel-epel-7.repo;
yum -y install bazel;
cd /opt; git clone --recurse-submodules https://github.com/tensorflow/serving;
yum -y install pkg-config patch swig automake libtool;
pip3 install autograd enum34;
# 参考 https://blog.csdn.net/cq361106306/article/details/52929468
cd /opt/serving; export TEST_TMPDIR=/opt/TFSserving/cache_bazel; bazel build -c opt --jobs 1 --local_resources 2048,0.5,1.0 --verbose_failures //tensorflow_serving/model_servers:tensorflow_model_server;
# 注意:自己有更新过一个文件,改成for循环传多个参数;拷过去时还要记得把__pycache__删掉啊:
vi /usr/local/lib/python3.5/site-packages/tensorflow_serving_client/client.py:
/* add begin*
for i in range(len(input_data)):
data = input_data[i]
name = input_tensor_name[i]
/* add end*/
copy_message(tf.contrib.util.make_tensor_proto(data), request.inputs[name])
response = self.execute(request, timeout=timeout)
Django 环境
pip3 install Django
pip3 install django-werkzeug-debugger-runserver django_extensions urllib3 easydict opencv-python genius python_speech_features matplotlib python-Levenshtein;
cd /opt/Django; django-admin startproject HelloWorld;
# 修改domains
vi HelloWorld/settings.py
python3 manage.py runserver 0.0.0.0:8080
nginx 和 php
- yum安装和设置开机自启动,很简单
yum -y install nginx php php-fpm; systemctl start nginx php-fpm; systemctl enable httpd.service php-fpm.service
设置个php默认时区: https://blog.csdn.net/yanlintao1/article/details/25835223
关闭一些不必要的Notice: https://www.cnblogs.com/apolloren/p/7826988.html
就修改 /etc/nginx/nginx.conf 或 /etc/nginx/conf.d/xxxx.conf 配置自己的web服务了,比如一个最简单的:
server {
listen 443;
server_name wss.my.com;
root /usr/share/nginx/vhosts/wss;
index index.html index.htm index.php;
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
ssl_certificate "/opt/Django/server.crt";
ssl_certificate_key "/opt/Django/server.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:80;
}
location /record {
proxy_pass http://localhost:8080;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
mysql
CentOS7的yum源中默认好像是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。
- 下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
- 安装mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
#安装这个包后,会获得两个mysql的yum repo源:
# /etc/yum.repos.d/mysql-community.repo
# /etc/yum.repos.d/mysql-community-source.repo
- 安装mysql
yum -y install mysql-server php-mysqlnd
systemctl start mysql; netstat -anp | grep :3306
mysqladmin -u root flush-privileges password 'password'
- 允许远程连接 (可参考 https://www.cnblogs.com/julyme/p/5969626.html)
phpMyAdmin
参考文档: http://dditblog.com/itshare_571.html
- 直接通过yum安装
yum -y install php-mbstring phpmyadmin
- 拷贝到自己的web目录:
cp -r /usr/share/phpMyAdmin /usr/share/nginx/html/
- 修改配置文件:
cp phpMyAdmin/libraries/config.default.php phpMyAdmin/config.inc.php
vi phpMyAdmin/config.inc.php
$cfg[´Servers´][$i][´auth_type´] = ´cookie´; //在本机调试用config、否则用cookie、这里建议用cookie
$cfg[´Servers´][$i][´user´] = ´root´; //设定mysql的用户名
$cfg[´Servers´][$i][´password´] = ´password´; //设定mysql的用户密码
$cfg[´DefaultLang´] = ´zh-utf-8´; //设定默认语言
- 重启 php-fpm 然后就可以在浏览器访问: http://www.my.com/phpMyAdmin
others
- 确保都启动起来了,也都设置了开机自启动:
netstat -anp | grep -E "\bLISTEN\b";
systemctl list-unit-files | grep -P "nginx|php|mysql";
- 过程在如果有什么问题,主要是nginx配置相关的,查看 /var/log/nginx 目录下的 error 和 access 日志, 弄不明白的问题 百度 or 必应