1.更換系統(tǒng)源? 編輯?/etc/apt/sources.list 文件? 修改內(nèi)容為?
deb http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free
把鏡像地址更改為國內(nèi)阿里云源? 加粗部分為系統(tǒng)codename 使用命令? lsb_release -a 可以查看當前系統(tǒng)codename
apt-get update -y 執(zhí)行更新操作?
2.apt-get update && apt-get upgrade 升級當前系統(tǒng)源文件?
apt-get install curl vim wget sudo unzip apt-transport-https lsb-release ca-certificates 安裝常用命令
3.先安裝SSH 服務 遠程連接服務器?apt-get install openssh-server??
修改 PermitRootLogin without-password 為PermitRootLogin yes 此功能為開放遠程登錄root賬戶
4.加入 Backports 源父虑,方便安裝更新的軟件
cat >> /etc/apt/sources.list.d/backports.list << EOF
deb http://ftp.cn.debian.org/debian $(lsb_release -sc)-backports main
EOF
5.執(zhí)行升級?
apt-get -t stretch-backports update && apt-get -t stretch-backports upgrade
6.增加 Ond?ej Sury (捷克)大神打包的 Nginx 源并安裝?
增加 Key?
wget -O /etc/apt/trusted.gpg.d/nginx-mainline.gpg https://packages.sury.org/nginx-mainline/apt.gpg
然后增加 Nginx 源
cat >> /etc/apt/sources.list.d/nginx.list << EOF
deb https://mirror.xtom.com.hk/sury/nginx-mainline/ $(lsb_release -sc) main
EOF
apt-get update
apt-get install nginx-extras
安裝完畢后宵呛,我們可以使用?nginx -v?命令看到 Nginx 已經(jīng)是最新的 1.13.3 主線版了
7.本次安裝nginx 版本為 1.12 使用另一種方法
更改系統(tǒng)自帶的源倉庫文件,用Vim打開:vim /etc/apt/sources.list
然后復制下面兩行灶搜,粘貼到文件末尾:
deb http://nginx.org/packages/debian/ stretch nginx
deb-src http://nginx.org/packages/debian/ stretch nginx?
保存之后退出。這樣我們就添加了Nginx的官方源床绪,再次更新系統(tǒng)以讓系統(tǒng)下載Nginx的官方源信息就能安裝Nginx了
apt update?添加了源之后碌冶,安裝Nginx的軟件包其實很簡單盅藻,只需要一行命令就好了:
apt install nginx?如果安裝過程出現(xiàn)提示需要確認,只需按y然后回車就好了群嗤。
8.配置nginx
出于安全性考慮菠隆,我們非常不建議使用root用戶運行網(wǎng)站,因為如果網(wǎng)站一旦被黑狂秘,可能會導致整臺服務器安全性都受到影響骇径,于是,我們可以選擇添加一個專門的www-data用戶來運行這些相關進程者春。添加www-data組 groupadd www-data?添加www-data用戶到www-data組?
useradd -g ???? www-data?這樣我們就添加了專門用來運行網(wǎng)站的www-data用戶破衔。
打開Nginx的配置文件:vim /etc/nginx/nginx.conf
更改user的值,將其改成www-data用戶钱烟,以及worker_processes改成實際的CPU核心數(shù)晰筛,比如:
user www-data;
worker_processes? 10;
新建項目目錄 mkdir??/data/www; 修改項目目錄所屬組 權限 chmod -R 755 /data/www
chown -R www-data:www-data /data/www?
修改項目根目錄:
?location / {
? ? ? ? ? ? root? /data/www;
? ? ? ? ? ? index? index.html index.htm index.php;
? ? ? ? }
修改支持PHP-fpm?
location ~ \.php$ {
? ? ? ? ? ? root? ? ? ? ? /data/www;
? ? ? ? ? ? fastcgi_pass? unix:/run/php/php5.6-fpm.sock;? ? ? ? ?
? ? ? ? fastcgi_index? index.php;
? ? ? ? ? ? fastcgi_param? SCRIPT_FILENAME $document_root$fastcgi_script_name;
? ? ? ? ? ? include? ? ? ? fastcgi_params;
? ? ? ? }
9.安裝MySQL
?下載:wget http://dev.mysql.com/get/mysql-apt-config_0.3.5-1debian8_all.deb?
?安裝:dpkg -i mysql-apt-config_0.3.5-1debian8_all.deb 系統(tǒng)會詢問選擇版本 選擇server
然后選擇 Apply 就可以安裝 安裝過程中會提示輸入mysql root密碼 輸入2次 即可?
然后mysql -uroot -ppassword 登錄mysql status 查看mysql版本? exit退出
10安裝PHP
使用命令 安裝:
apt-get install php5.6-fpm php5.6-mysql php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-xml php5.6-xmlrpc php5.6-zip php5.6-opcache php-memcached php-memcache php-common php-igbinary php-msgpack libmemcached11 libmemcachedutil2 php5.6-cli php5.6-json php5.6-common php5.6-readline libmcrypt4 libxmlrpc-epi0 libzip5
配置php?vim /etc/php/5.6/fpm/php.ini 增加extension=memcached.so 開啟memcached 模塊?
重啟php-fpm?pkill php-fpm關閉進程??/etc/php/5.6/fpm 啟動服務
查看memcached 是否開啟服務?ps aux | grep memcached????
在/data/www/目錄下新建index.html index.php php文件寫 phpinfo(); 先訪問查看index.html是否能訪問 再訪問index.php 文件 查看是否解析 在phpinfo里 查看memcached 是否開啟