這里選用 debian 8 作為OS.
- 1.創(chuàng)建基礎(chǔ)用戶并配置用戶權(quán)限
sudo -s
usermod -g50 -G27,100 separes
chgrp -R staff .
exit
exit
id separes
- 2.配置apt源
vi /etc/apt/sources.list
由于____的原因,國內(nèi)apt源與鏡像可能經(jīng)常不太穩(wěn)定,只能多多嘗試,以下提供較為穩(wěn)定的幾個源以備不時之需
// 阿里云
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主題插件(個人習(xí)慣)
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 // 創(chuàng)建實(shí)際目錄
chown -R www-data:www-data /var/www // 修改目錄權(quán)限
chmod g+s /var/www
mkdir /var/www/index~nginx // 將目錄下的nginx配置文件放在這里,便于統(tǒng)一管理與配置
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 // 設(shè)置字符集為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相關(guān)擴(kuò)展
如在安裝過程中出現(xiàn)相關(guān)依賴沒有安裝,逐項安裝即可
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權(quán)限以便開發(fā)
ssh-keygen -C 'separes <separes9@gmail.com>' -N '' -t rsa -b 2048 (普通用戶)(生成密鑰)
cd
cat .ssh/id_rsa.pub (獲取密鑰)
將生成的秘鑰配置在git PublicKey相關(guān)處即可
- 12.(如有需要)clone項目代碼,配置composer及項目相關(guān)文件
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 能正確讀取項目配置文件即可.
// 導(dǎo)入數(shù)據(jù)庫文件
mysql -u root -p
# create database test;
# grant all privileges on test.* to separes@localhost identified by 'test';
# flush privileges;
# exit;
# 導(dǎo)入數(shù)據(jù)庫文件
# mysql -u test -p -D < 數(shù)據(jù)庫文件.sql
- 14.(如有需要)配置hosts
vi /etc/hosts