版本:ubuntu 14.04(64位)
1.安裝Nginx(version:1.9)
1、首先添加nginx_signing.key
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
2、添加Nginx官方提供的源
echo "deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx">> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx">> /etc/apt/sources.list
3、更新源并安裝Nginx
sudo apt-get update
sudo apt-get install nginx
4、Nginx配置
打開配置文件。
vim /etc/nginx/nginx.conf
修改user:
user? www-data;
增加server:
server {
? ? listen 80 default_server;
? ? listen [::]:80 default_server ipv6only=on;
? ? root /var/www/
laravel/public;? ? index index.php index.html index.htm;
? ? server_name
server_domain_or_IP;? ? location / {
? ? ? ? try_files $uri $uri/ /index.php?$query_string;
? ? }
? ? location ~ \.php$ {
? ? ? ? try_files $uri /index.php =404;
? ? ? ? fastcgi_split_path_info ^(.+\.php)(/.+)$;
? ? ? ? fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
? ? ? ? fastcgi_index index.php;
? ? ? ? fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
? ? ? ? include fastcgi_params;
? ? }
}
注意:root中的laravel應(yīng)為你的項目名稱,server_name應(yīng)為你的服務(wù)器公網(wǎng)IP。
配置完之后重啟Nginx,使上面的配置項生效。
sudo service nginx restart
2.安裝PHP(version:7.0x)
1、添加PPA,添加過程中需要按一次回車(Enter)鍵
sudo apt-get install python-software-properties software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
2、安裝PHP7以及所需的一些擴(kuò)展
sudo apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-curl php7.0-cli php7.0-mcrypt php7.0-mbstring php7.0-dom php7.0-gd
3、配置PHP7
打開php.ini配置文件:
sudo vim /etc/php/7.0/fpm/php.ini
找到cgi.fix_pathinfo選項,去掉注釋;,然后將值設(shè)置為0 ?(這個操作是為了避免PHP7的一個漏洞,PS:vim使用“/”進(jìn)入查找模式)
cgi.fix_pathinfo=0
啟用php7.0-mcrypt
sudo phpenmod mcrypt
重啟php7.0-fpm
sudo service php7.0-fpm restart
3.安裝Mysql(version:5.6)
sudo apt-get install mysql-server-5.6 mysql-client-5.6
途中會提示設(shè)置MySQL的密碼,安裝好后:
mysql -uroot -p
然后輸入剛剛設(shè)置的密碼,能成功進(jìn)入即成功安裝。
4.安裝Laravel(version:latest)
1、安裝composer,分別執(zhí)行以下語句
sudo apt-get install curl
cd ~
curl -sS https://getcomposer.org/installer| php
sudo mv composer.phar /usr/local/bin/composer
2、安裝壓縮丶解壓縮程序
sudo apt-get install zip unzip
3丶安裝git
sudo apt-get install git
然后在Coding上創(chuàng)建一個私有項目laravel,里面包含所有該Laravel項目所需代碼。
4丶使用git將代碼clone到服務(wù)器上
cd /var
mkdir www
cd www
git clone
your-project-git-link
注意:git clone 的地址應(yīng)是你自己Coding倉庫中的項目SSL鏈接地址
5丶修改laravel項目的訪問權(quán)限
sudo chown -R :www-data /var/www/
laravel
sudo chmod -R 775 /var/www/
laravel/storage
6丶導(dǎo)入laravel 的vendor目錄
cd /var/www/
laravel
composer install
注意:5,6兩部操作中的“l(fā)aravel” 應(yīng)該是你自己項目的的名稱。
5.安裝Redis(version:3.0.7)
最新版地址:http://redis.io/download
cd ~
wget http://download.redis.io/releases/redis-3.0.7.tar.gz
tar xzf redis-3.0.7.tar.gz
配置并啟動Redis
cd redis-3.0.7
vi redis.conf
搜索bind,將# bind 127.0.0.1的注釋去掉后保存(這樣做后只有本地服務(wù)可以訪問Redis,不然就有安全隱患)
make
src/redis-server
看到redis的運行提示即完成。
6.安裝nodeJS
添加下面鏈接中的源,然后安裝
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
番外:安裝ZSH shell
sudo apt-get install zsh
chsh -s $(which zsh)
sh -c"$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"