这里选用 debian 8 作为OS.
- 1.创建基础用户并配置用户权限
sudo -s
usermod -g50 -G27,100 separes
chgrp -R staff .
exit
exit
id separes
- 2.配置apt源
vi /etc/apt/sources.list
由于____的原因,国内apt源与镜像可能经常不太稳定,只能多多尝试,以下提供较为稳定的几个源以备不时之需
// 阿里云
deb http://mirrors.aliyun.com/dotdeb jessie all
deb http://mirrors.aliyun.com/debian jessie main contrib non-free
deb http://mirrors.aliyun.com/debian jessie-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security jessie/updates main contrib non-free
// 163
deb http://mirrors.163.com/debian/ jessie main non-free contrib
deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
// 中科大
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
- 3.安装并更新apt
sudo apt-get update
sudo apt-get upgrade
- 4.安装vim与git
sudo -s
apt-get install vim git
- 5.配置git
wget -O ~/.gitconfig http://github.yourgit
git config --global user.name separes
git config --global user.email separes9@gmail.com
git config --global core.filemode false
cd
sudo vi .gitconfig (删除 push 模块代码)
- 6.配置个性化linux主题插件(个人习惯)
cd /usr/local/src
git clone git://github.com/snakevil/bashrc.x bashrc.x.git
mkdir ~/.local
ln -s /usr/local/src/bashrc.x.git/src ~/.local/bashrc.x
cd
rm -fr .bash_profile .bashrc .profile
ln -s .local/bashrc.x/etc/bash_profile .bash_profile
ln -s .local/bashrc.x/etc/bashrc .bashrc
exit
- 7.安装nginx
sudo -s
mkdir /var/www/index // 创建实际目录
chown -R www-data:www-data /var/www // 修改目录权限
chmod g+s /var/www
mkdir /var/www/index~nginx // 将目录下的nginx配置文件放在这里,便于统一管理与配置
apt-get install nginx-full // 完整安装nginx
rm -fr /etc/nginx/sites-enabled/*
vi /etc/nginx/nginx.conf // 引入配置文件
# include /var/www/*~nginx/*.conf;
service nginx reload
exit
- 8.安装mysql
sudo -s
apt-get install mysql-server mysql-client
vi /etc/mysql/my.cnf // 设置字符集为utf-8
# character-set-server = utf8
# init-connect = 'SET NAMES utf8'
service mysql restart
exit
- 9.安装并配置php
sudo -s
apt-get install php5-fpm php5-cli
vi /etc/php5/fpm/pool.d/www.conf // 配置error log
# php_admin_value[error_log]=/var/log/fpm-php.www.log
touch /var/log/fpm-php.www.log
chown www-data:www-data /var/log/fpm-php.www.log
service php5-fpm restart
- 10.安装php相关扩展
如在安装过程中出现相关依赖没有安装,逐项安装即可
sudo -s
apt-get install php5-mysqlnd
apt-get install php5-curl
apt-get install php5-memcached
apt-get install php5-imagick
apt-get install php5-gd
- 11.配置git ssh权限以便开发
ssh-keygen -C 'separes <separes9@gmail.com>' -N '' -t rsa -b 2048 (普通用户)(生成密钥)
cd
cat .ssh/id_rsa.pub (获取密钥)
将生成的秘钥配置在git PublicKey相关处即可
- 12.(如有需要)clone项目代码,配置composer及项目相关文件
git clone ssh://git@xxxxxxxxxx.com
mkdir ~/.bashrc.x/bin
cd ~/.bashrc.x/bin
php -r "readfile('https://getcomposer.org/installer');" | php
mv composer.phar composer
cd /home/项目目录
composer update
- 13.部署nginx及mysql配置文件
nginx配置不再赘述,保证 /etc/nginx/sites-enabled 和 /etc/nginx/sites-available 能正确读取项目配置文件即可.
// 导入数据库文件
mysql -u root -p
# create database test;
# grant all privileges on test.* to separes@localhost identified by 'test';
# flush privileges;
# exit;
# 导入数据库文件
# mysql -u test -p -D < 数据库文件.sql
- 14.(如有需要)配置hosts
vi /etc/hosts
网友评论