樹莓派上配置伺服器
樹莓派上配置伺服器
樹莓派上配置一個簡單的伺服器,這樣可以用來放個部落格或者測試靜態檔案
用python做一個最簡單的臨時伺服器
假設我希望我的靜態伺服器根目錄在~/workspace/web下
那麼,ssh到樹莓派上,cd到該目錄下直接輸入
$ nohup python -m SimpleHTTPServer
之後就可以關閉terminal了
這個方法的劣勢是如果按CTRL+c會自動結束程式,只能直接退出terminal.
那就用這條指令:
$ nohup python -m SimpleHTTPServer &
要結束該程式可以用jobs命令檢視程式號碼
$jobs
用fg %number來把後臺的任務喚醒到前臺,然後正常退出.
搭建一個wordpress用伺服器
前面那種也只能應急,要搭建一個靠譜的伺服器還是得用專業的.我們安個wordpress順便把nginx,php環境,mysql一起裝了 參考這篇文章和這篇文章
開始安裝:
$sudo apt-get update
$sudo apt-get install nginx php5-fpm php5-cli php5-curl php5-gd php5-mcrypt php5-mysql php5-cgi mysql-server
期間會要求輸入mysql的密碼
將/etc/nginx/sites-available/和/etc/nginx/sites-enabled/資料夾下defalt檔案刪除.新增一個叫wordpress的檔案
$sudo touch wordpress
$sudo chmod ugo+w wordpress
檔案內容如下:
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 8001;
server_name _;
## Your only path reference.
root /srv/www/wordpress/public_html;
## Your website name goes here. Change to domain.ltd in VPS
access_log /srv/www/wordpress/logs/access.log;
error_log /srv/www/wordpress/logs/error.log;
## This should be in your http block and if it is, it's not needed here.
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
下載wordpress
sudo mkdir -p /srv/www/wordpress/logs/
sudo mkdir -p /srv/www/wordpress/public_html
cd /srv/www/wordpress/public_html
sudo wget https://cn.wordpress.org/wordpress-4.2.2-zh_CN.tar.gz
sudo tar xzvf latest.tar.gz
sudo mv wordpress/* .
設定資料庫:
$mysql -u root -p
mysql> CREATE DATABASE wordpress;
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost"IDENTIFIED BY "raspi";
mysql> FLUSH PRIVILEGES;
mysql> EXIT
將/srv/www/wordpress/public_html目錄下的wp-config-sample.php檔名改為wp-config.php.
sudo cp wp-config-sample.php wp-config.php
然後開啟修改其中的以下幾行
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'raspi');
並在開頭MySQL 設定
之前新增如下程式碼:
$home = 'http://'.$_SERVER['HTTP_HOST'];
$siteurl = 'http://'.$_SERVER['HTTP_HOST'];
define('WP_HOME', $home);
define('WP_SITEURL', $siteurl);
重啟nginx和php5-fpm
sudo service nginx restart
sudo service php5-fpm restart
ok,瀏覽器開啟http://你的ip:80/wp-admin/install.php就可以安裝wordpress了
注意:要讓外網可以訪問,一定要讓路由器的埠對映與小pi上設定的埠一致
相關文章
- 在樹莓派上安裝 Ubuntu MATE樹莓派Ubuntu
- 在樹莓派上執行 DOS 系統樹莓派
- 在樹莓派上搭建智慧家居閘道器樹莓派
- OpenYurt 入門 - 在樹莓派上玩轉 OpenYurt樹莓派
- 樹莓派上安裝USB網路攝像頭樹莓派
- 關於在windows,ubuntu,樹莓派上安裝使用opencvWindowsUbuntu樹莓派OpenCV
- 樹莓派使用入門:在樹莓派上使用 Mathematica 進行高階數學運算樹莓派
- 在樹莓派上部署yolo模型推理並使用onnx加速樹莓派YOLO模型
- 如何將樹莓派配置為列印伺服器樹莓派伺服器
- 樹莓派配置watchdog樹莓派
- 樹莓派上利用Tensorflow實現小車的自動駕駛樹莓派自動駕駛
- 在樹莓派上安裝c++版本的opencv並執行樹莓派C++OpenCV
- 在樹莓派上開發SpringBoot 之使用VSCode遠端開發樹莓派Spring BootVSCode
- 在樹莓派上設定家庭網路的家長控制功能樹莓派
- (二)樹莓派配置MySQL樹莓派MySql
- [譯] 如何輕鬆地在樹莓派上使用深度學習檢測物件樹莓派深度學習物件
- 將搭建在樹莓派上的leanote用frp對映到自己的域名樹莓派FRP
- 【LEDE】樹莓派上玩LEDE終極指南-82-部署OpenVPN服務端樹莓派服務端
- 樹莓派搭建git伺服器 | 樹莓派小無相系列樹莓派Git伺服器
- 將樹莓派配置成路由樹莓派路由
- 「玩轉樹莓派」樹莓派 3B+ 配置無線WiFi樹莓派WiFi
- 樹莓派開發—基礎配置樹莓派
- 超強教程!在樹莓派上構建多節點K8S叢集!樹莓派K8S
- 使用樹莓派搭建Ubuntu伺服器樹莓派Ubuntu伺服器
- 將樹莓派配置成路由器樹莓派路由器
- 配置樹莓派linux的核心和編譯並將映象拷貝至樹莓派樹莓派Linux編譯
- 樹莓派+tomcat+mysql安裝及配置樹莓派TomcatMySql
- 樹莓派aria2下載器配置樹莓派
- 使用 Ansible 在樹莓派上構建一個基於 Linux 的高效能運算系統樹莓派Linux
- 樹莓派使用入門:如何更新樹莓派樹莓派
- 樹莓派是什麼 樹莓派能做什麼 樹莓派的功能用途樹莓派
- 樹莓派 —— ubuntu上透過netplan配置網路樹莓派Ubuntu
- 09. 樹莓派ASP.NET環境配置樹莓派ASP.NET
- 樹莓派使用入門:用樹莓派學 Linux樹莓派Linux
- 樹莓派使用樹莓派
- 樹莓派4B系列教程二 :常規配置樹莓派
- 樹莓派使用入門:慶祝樹莓派的 14 天樹莓派
- 樹莓派使用入門:如何用樹莓派來娛樂樹莓派
- 樹莓派使用入門:如何購買一個樹莓派樹莓派