欢迎使用CSDN-markdown编辑器

来源:互联网 发布:酷狗音乐连不上网络 编辑:程序博客网 时间:2024/06/06 20:30

ubuntu安装记录

1、下载ubuntu14.04 iso镜像文件

2、下载rufus软件制作ubuntu安装引导盘

3、安装步骤安装ubuntu

4、安装远程桌面

ubuntu16.04 service版安装GUI:sudo apt-get install --no-install-recommends ubuntu-desktopsudo apt-get updatesudo apt-get install xfce4sudo apt-get install xrdp vnc4serverecho "xfce4-session" >~/.xsessionsudo service xrdp restart需要关闭屏保,屏保占用大量带宽:setting->setting manager->Screensaver

5、在window上开启远程连接

sudo apt-get install gnome-terminal 安装新终端sudo update-alternatives --config x-terminal-emulator 设置默认终端为gnometerminal没有光标:在Terminal->Edit->Profile Preferences->Colors->反选Use colors from system theme即可

文件管理器无缩略图:执行

sudo apt-get install gnome-icon-theme-full tango-icon-theme

断开连接再次重连即可

6、ufw防火墙设置

sudo ufw default deny 默认拒绝所有请求sudo ufw enable/disable 开启或者关闭防火墙sudo ufw status 查看防火墙状态sudo ufw allow ssh/22 允许22端口可被访问 22端口为ssh端口sudo ufw allow 80 允许80端口 为apache使用sudo ufw allow from 192.168.1.107 允许该IP的主机访问所有端口sudo ufw reset 重置所有规则sudo ufw delete allow 3350 删除某条规则sudo ufw allow 3350sudo ufw allow 3389 windows远程桌面默认端口号为:3389,两个都开启才能连接到远程桌面sudo ufw allow 8000 django页面测试使用netstat -ap|grep 8080 查看被占用端口的pidkill + 对应的pid    强制关闭被占用的端口

7、文件互传

安装putty,在putty的安装目录中拷贝出pscp.exe文件至C:\Windows\System32,这样就可以在任意地方运行pscp命令。

在桌面打开cmd,欲传输ss.png至ubuntu,使用命令:

pscp ss.png dreamgo@192.168.1.102:/var/www 只有左斜杠可用pscp ss.png dreamgo@192.168.1.102:Downloads其中dramgo是ubuntu的用户名,192.168.1.102是ubuntu的IP地址。若出现unable to open /home/ss.png: permission denied 则需要对ubuntu服务器上的对应文件夹进行读写授权,使用命令sudo chmod -R 777 /home/修改该目录的权限为普通用户可访问。

从ubuntu服务器下载ss.png到window,使用命令:

pscp dreamgo@192.168.1.102:/var/www/ss.png C:/ss.png从远程服务器的/var/www/ss.png 下载到本地C盘ss.png

8、解压

tar -xvzf community_images.tar.gz 解压zip -r compressed_filename.zip foldername 压缩unzip dreamgo.zip 解压zip

Linux部署Apache开发环境

Ubuntu 14.04Apache 2.4.7Python 3.4Django 1.10.6

1、ubuntu安装python3.5

ubuntu14.04系统会自带python2.7,请不要卸载它。

sudo apt-get install python-software-propertiessudo apt-get install software-properties-commonsudo add-apt-repository ppa:fkrull/deadsnakessudo apt-get updatesudo apt-get install python3.5sudo cp /usr/bin/python /usr/bin/python_bak 先备份sudo rm /usr/bin/python 删除sudo ln -s /usr/bin/python3.5 /usr/bin/python 默认设置成python3.5

2、安装apache等必要模块

sudo apt-get updatesudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3在python3环境下使用pip3安装软件而不是pip(python2使用)sudo pip3 install virtualenvvirtualenv dreamgo_env 新建虚拟环境source dreamgo/bin/activate 激活虚拟环境pip isntall django_cleanup==0.4.2 -i http://pypi.douban.com/simple --trusted-host=pypi.douban.com使用豆瓣源安装Django所需模块pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host=pypi.douban.com使用豆瓣源批量安装所需模块deactivate 关闭虚拟环境

3、配置apache2

sudo chmod -R 777 /etc/apache2 为apache2目录开启读写权限,防止设置保存失败sudo chmod -R /home/dreamgo/dreamgo_official_site 为项目开启读写权限,方便编辑直接进入/etc/apache2/site-available/文件夹编辑000-default.conf或者使用命令:sudo gedit /etc/apache2/site-available/000-default.conf编辑配置文件

000-default.conf:

<VirtualHost *:8000>    ServerAdmin ykh@dreamgo.tech    ServerName 192.168.1.102    DocumentRoot /home/dreamgo/dreamgo_official_site    Alias /static /home/dreamgo/dreamgo_official_site/static    <Directory /home/dreamgo/dreamgo_official_site/static>        Require all granted    </Directory>    <Directory /home/dreamgo/dreamgo_official_site/dreamgo_official_site>        <Files wsgi.py>            Require all granted        </Files>    </Directory>    WSGIDaemonProcess 192.168.1.102 python-path=/home/dreamgo/dreamgo_official_site python-home=/home/dreamgo/dreamgo_official_site/dreamgo_env    WSGIProcessGroup 192.168.1.102    WSGIScriptAlias / /home/dreamgo/dreamgo_official_site/dreamgo_official_site/wsgi.py</VirtualHost>

使用8000端口需要配置:

sudo ufw allow 8000 防火墙开放8000端口编辑/etc/apache2/ports.conf文件,新增Listen 8000,保存。

使用命令开启站点:

sudo a2enmod wsgisudo a2ensite 000-default.confsudo service apache2 reloadsudo service apache2 restart

站点关闭命令

sudo a2dissite 000-default.conf

Django中文语言错误:

错误提示: no translation files found for default language zh_Hans解决方案: 在settings中将LANGUAGE_CODE = 'zh_Hans'改为LANGUAGE_CODE = 'zh-hans'可至,对应的语言代码可至django/conf/locale/__init__.py中查找。

4、MySql由Windows迁移至Ubuntu

Windows进入C:\Program Files\MySQL\MySQL Server 5.7\bin打开cmd:

Windows:

mysqldump -uroot -proot --all-databases >C:\all_data.sql 备份全部数据库

Linux:

mysql -uroot -proot 进入mysql命令交互终端    create database dreamgo; 新建数据库    create database portal_jrfamily default character set utf8;    drop database dreamgo; 删除数据库    show databases; 列出所有数据库    use database_name; 使用某个数据库

通用:

mysql --version 查看mysql版本mysqldump -uroot -p dreamgo >C:\dreamgo.sql 备份一个数据库 需要迁移的两个数据库版本相同mysqldump -uroot -p database_name <C:\dreamgo.sql 回复数据提示成功但是无表被添加mysql -uroot -p database_name <C:\dreamgo.sql 回复数据成功mysql_upgrade -uroot -proot --force 提示系统的session表不存在时执行

5、Apache模块配置

pip 安装wsgi的库时会自动向/etc/apache2/mods-available/中添加wsgi.conf和wsgi.load

wsgi.load:

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.somod_wsgi.so位于文件夹/usr/lib/apache2/modules/中

Apache默认的日志文件位于/var/log/apache2/error.log

配置虚拟主机:ErrorLog /django/dreamgo/error.log

安装xsendfile,用于文件上传下载。

sudo apt-get install libapache2-mod-xsendfilesudo a2enmod xsendfile

6、文件操作

sudo touch xxx.etx 新建文件sudo mkdir xxx 新建目录sudo mv dir1 dir2 剪切文件夹sudo rm -rf dir 删除文件夹

7、配置项目

Pillow安装错误

sudo apt-get install python3-devsudo apt-get install libjpeg8-devsudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/libpip install pillow

如果有log文件,必须对log文件所在的父级目录授权。

8、安装mysql5.7

由于不同版本的sql无法备份,故使用和windows上相同的mysql5.7,linux apt-get 安装的为5.5.54。

步骤:

wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.debsudo dpkg -i mysql-apt-config_0.6.0-1_all.debsudo apt-get updatesudo apt-get install mysql-servermysql --version

pip install “django-constance[database]”

sudo apt-get install rabbitmq-server
python manage.py celery beat –loglevel=info # 启动任务发送端

python manage.py celery worker -l info # 启动任务处理端 worke

原创粉丝点击