红联Linux门户
Linux帮助

腾讯云ubuntu14.04建apache+php+python(导入dlib库)+mysql环境

发布时间:2016-10-17 11:26:42来源:linux网站作者:zyf318428
(以下命令执行过程中仍然出现权限不够,就直接使用 sudo su 输入当前密码进入root)
 
一、申请腾讯云
去腾讯云官网购买一台云服务器,选择ubuntu14.04LTS系统
 
二、安装apache2
sudo apt-get update
sudo apt-get install apache2
可以用浏览器输入你云主机的外网ip,如果显示如图 1,则apache安装成功。
腾讯云ubuntu14.04建apache+php+python(导入dlib库)+mysql环境
 
三、安装PHP
1.sudo apt-get install php5
2.sudo apt-get installlibapache2-mod-php5
3.sudo apt-get installphp5-mcrypt
4.sudo apt-get install php5-curl
5.sudo apt-get installphp5-imagick
6.sudo apt-get install php5-cli
 
四、安装Python
1.sudo apt-get install python2.7python2.7-dev
2.sudo apt-get installbuild-essential
3.sudo apt-get install libssl-dev
4.sudo apt-get installlibevent-de
5.sudo apt-get install libjpeg-dev
6.sudo apt-get installlibxml2-dev
7.sudo apt-get installlibxslt-dev
 
五、安装dlib与其他Python库
1.sudo apt-get install python-pip
2.sudo pip install Pillow
3.sudo apt-get install libboost-python-dev cmake
4.dlib库需要从官网下载
将其解压后放到/usr/local/lib/python2.7/dist-packages目录下
5.cd /usr/local/lib/python2.7/dist-packages/(dlib文件夹名称)/python_examples     
6.sudo mkdir build
7.cd build
8.sudo apt-get installlibopenblas-dev liblapack-dev
9.sudo cmake ../../tools/python
10.sudo apt-get install libx11-dev
(执行接下来的命令是需要扩大虚拟内存,否则会提示失败,方法如下)
1.sudo mkdir /opt/images
2.rm –rf /opt/images/swap
3.dd if=/devzeroof=/opt/images/swap/ bs=1024 count=2048000
4.mkswap /opt/images/swap
5.swapon /opt/images/swap
(至此为止,添加了2G的虚拟内存)
11.sudo cmake --build . --configRelease
12.sudo cp dlib.so/usr/local/lib/python2.7/dist-packages
添加其他python库
1.sudo apt-get install libblas-dev
2.sudo apt-get install liblapack-dev
3.sudo apt-get install libatlas-base-dev
4.sudo apt-get install gfortran
5.sudo pip install numpy
6.sudo pip install scipy
7.sudo pip install cython
8.sudo apt-get installlibfreetype6-dev libxft-dev
9.sudo apt-get install pkg-config
10.sudo pip install matplotlib
11.sudo pip install scikit-image
确实是否安装成功,需进入python使用import命令
 
六、安装MySQL
1.sudo apt-get install mysql-server   (会提示输入root密码)
让apache支持mysql
2.sudo apt-get install libapache2-mod-auth-mysql
让PHP支持mysql
3.sudo apt-get install php5-mysql
4.sudo service mysql restart
 
七、建立网站
网站的目录在 /var/www/html/ 下
需要将该目录的权限设置为 777,命令如下
1、cd /var/www/
2、sudo chmod 777 html
至此,便可在html目录下添加网页及python、php脚本了,用外网执行浏览了。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/25111.html