1.lnmp 搭建nginx+mysql+php
分別nginx,mysql,php -v查詢版本,正確沒問題
2.啓動nginx,直接輸入 nginx即可,
配置nginx,輸入nginx -t查詢config路徑,在/usr/local/nginx/conf/nginx.conf ,修改上傳,一定要在xshell裏面nginx -s reload重新加載
nginx -s reopen
nginx -s stop
關鍵網頁路徑訪問位置
3.可以另起一個端口,root路徑改一下,經過改動的路徑需要chmod 777 -R /***/** 設置可讀寫
4.把onethink放入第3步路徑底下。
5.安裝node+npm+forever http://www.cnblogs.com/hamhog/p/3574582.html
如下 apt-get 改爲 yum運行
1. 安裝node
apt-get install nodejs
2. 安裝npm
apt-get update
apt-get install npm
3. 安裝forever
此時安裝forever失敗。提示:
npm ERR! Error: failed to fetch from registry:
執行:
npm config set registry http://registry.npmjs.org
如果被牆,可以設置如下:npm config set registry https://registry.npm.taobao.org
安裝forever仍然失敗。提示:
/usr/local/lib/node_modules/forever/node_modules/microtime/wscript:9: error: could not configure a cxx compiler!
於是安裝g++:
最後安裝forever:
npm install forever -g
如果一直卡住不動,說明被牆,看這個帖子:http://blog.csdn.net/qq591840685/article/details/53385365
這裏等的要久一些,耐心一下
4. 啓動node
進入node所在目錄,然後執行(以server.js爲例):
forever start server.js
1.lnmp搭建redis緩存數據庫
eAccelerator、xcache、memcached、imageMagick、ionCube、redis、opcache的安裝
https://lnmp.org/faq/addons.html
此腳本是用來安裝Redis,Redis是一個開源、支持網絡、基於內存、鍵值對存儲數據庫。
1------安裝
進入lnmp解壓後的目錄,執行:./addons.sh install redis
運行後有如下提示:
,安裝穩定版Redis 2.8.8 輸入:s 回車;安裝測試版Redis 3.0.0輸入:b 回車;安裝舊版Redis 2.6.17輸入:o 回車。
2----安裝phpredis驅動
http://www.runoob.com/redis/redis-php.html
PHP 使用 Redis
安裝
開始在 PHP 中使用 Redis 前, 我們需要確保已經安裝了 redis 服務及 PHP redis 驅動,且你的機器上能正常使用 PHP。 接下來讓我們安裝 PHP redis 驅動:下載地址爲:https://github.com/phpredis/phpredis/releases。
PHP安裝redis擴展
以下操作需要在下載的 phpredis 目錄中完成:
$ wget https://github.com/phpredis/phpredis/archive/2.2.4.tar.gz
://github.com/phpredis/phpredis/archive/2.2.4.tar.gz
tar -xzvf 2.2.4.tar.gz
$ cd phpredis-2.2.4 # 進入 phpredis 目錄
$ /usr/local/php/bin/phpize # php安裝後的路徑
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make && make install
-2.2.4 # 進入 phpredis 目錄
$ /usr/local/php/bin/phpize # php安裝後的路徑
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make && make install
如果你是 PHP7 版本,則需要下載指定分支:
git clone -b php7 https://github.com/phpredis/phpredis.git
-b php7 https://github.com/phpredis/phpredis.git
修改php.ini文件
vi /usr/local/php/lib/php.ini
/usr/local/php/lib/php.ini
注意:***** 這個目錄不一定準確,/usr/local/php/etc/php.ini也可能。
增加如下內容:
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
= "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
注意:*****no-debug-zts-20090626 這個字符串需要更換掉,你自己該目錄裏面的文件夾的名字。
安裝完成後重啓php-fpm 或 apache。重啓LNMP,1.2+輸入命令:lnmp restart 即可;單獨重啓mysql:/etc/init.d/mysql restart 也可以 lnmp mysql restart
查看phpinfo信息,就能看到redis擴展。
連接到 redis 服務
<?php
//連接本地的 Redis 服務
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//查看服務是否運行
echo "Server is running: " . $redis->ping();
?>
php
//連接本地的 Redis 服務
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//查看服務是否運行
echo "Server is running: " . $redis->ping();
?>
執行腳本,輸出結果爲:
Connection to server sucessfully
Server is running: PONG
to server sucessfully
Server is running: PONG
Redis PHP String(字符串) 實例
<?php
//連接本地的 Redis 服務
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//設置 redis 字符串數據
$redis->set("tutorial-name", "Redis tutorial");
// 獲取存儲的數據並輸出
echo "Stored string in redis:: " . $redis->get("tutorial-name");
?>
php
//連接本地的 Redis 服務
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//設置 redis 字符串數據
$redis->set("tutorial-name", "Redis tutorial");
// 獲取存儲的數據並輸出
echo "Stored string in redis:: " . $redis->get("tutorial-name");
?>
執行腳本,輸出結果爲:
Connection to server sucessfully
Stored string in redis:: Redis tutorial
to server sucessfully
Stored string in redis:: Redis tutorial
Redis PHP List(列表) 實例
<?php
//連接本地的 Redis 服務
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//存儲數據到列表中
$redis->lpush("tutorial-list", "Redis");
$redis->lpush("tutorial-list", "Mongodb");
$redis->lpush("tutorial-list", "Mysql");
// 獲取存儲的數據並輸出
$arList = $redis->lrange("tutorial-list", 0 ,5);
echo "Stored string in redis";
print_r($arList);
?>
php
//連接本地的 Redis 服務
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//存儲數據到列表中
$redis->lpush("tutorial-list", "Redis");
$redis->lpush("tutorial-list", "Mongodb");
$redis->lpush("tutorial-list", "Mysql");
// 獲取存儲的數據並輸出
$arList = $redis->lrange("tutorial-list", 0 ,5);
echo "Stored string in redis";
print_r($arList);
?>
執行腳本,輸出結果爲:
Connection to server sucessfully
Stored string in redis
Redis
Mongodb
Mysql
to server sucessfully
Stored string in redis
Redis
Mongodb
Mysql
Redis PHP Keys 實例
<?php
//連接本地的 Redis 服務
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
// 獲取數據並輸出
$arList = $redis->keys("*");
echo "Stored keys in redis:: ";
print_r($arList);
?>
php
//連接本地的 Redis 服務
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
// 獲取數據並輸出
$arList = $redis->keys("*");
echo "Stored keys in redis:: ";
print_r($arList);
?>
執行腳本,輸出結果爲:
Connection to server sucessfully
Stored string in redis::
tutorial-name
tutorial-list
to server sucessfully
Stored string in redis::
tutorial-name
tutorial-list
oneThink裏面用到redis方法:$redis = new \Redis(); 斜槓不能少
今天嘗試編譯內核,下載到了一份tar.xz結尾的壓縮文件,網上解決方法比較少,不過還是找到了,如下
補充:目前可以直接使用 tar xvJf ***.tar.xz來解壓
tar.gz 文件:tar zxvf 文件.tar.gz
yum安裝:
# yum install 包名
yum卸載:
# yum -y remove 包名
在Linux系統安裝Nodejs 最簡單步驟
1、去官網下載和自己系統匹配的文件:
英文網址:https://nodejs.org/en/download/
中文網址:http://nodejs.cn/download/
通過 uname -a 命令查看到我的Linux系統位數是64位(備註:x86_64表示64位系統, i686 i386表示32位系統),如圖
故下載一下紅色框中文件 ,版本爲v6.10.0
2、下載下來的tar文件上傳到服務器並且解壓,然後通過建立軟連接變爲全局;
1)上傳服務器可以是自己任意路徑,目前我的放置路徑爲 cd /app/software/
2)解壓上傳(解壓後的文件我這邊將名字改爲了nodejs,這個地方自己隨意,只要在建立軟連接的時候寫正確就可以)
① tar -xvf node-v6.10.0-linux-x64.tar.xz
② mv node-v6.10.0-linux-x64 nodejs
③確認一下nodejs下bin目錄是否有node 和npm文件,如果有執行軟連接,如果沒有重新下載執行上邊步驟;
3)建立軟連接,變爲全局
①ln -s /app/software/nodejs/bin/npm /usr/local/bin/
②ln -s /app/software/nodejs/bin/node /usr/local/bin/
4)最後一步檢驗nodejs是否已變爲全局
在Linux命令行node -v 命令會顯示nodejs版本,如圖所示爲大功告成