1.固定IP设置
使用ifconfig查看当前网卡设备名
更改/etc/dhcpcd.conf
interface 网卡名
static ip_address=192.168.1.88/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
2.更改软件源
/etc/apt/sources.list
deb http://mirrors.aliyun.com/raspbian/raspbian/ jessie main contrib non-free rpi
3.搭建LNMP服务器
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
nginx设置
修改配置/etc/nginx/sites-available/default
server {
listen 80;
server_name localhost;
root /var/www/html/;
access_log /var/log/nginx/localhost.access.log;
#error_page 404 /404.html;
location / {
index index.html index.htm index.php default.html default.htm default.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 1d;
}
location ~ .*\.php(\/.*)*$ {
root /var/www/html;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
4.安装phpmyadmin
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www/html
5.mysql设置账户
create database wordpress;
create user ‘joshliu357’@’%’ identified by ‘123456’;
grant all on wordpress.* to joshliu357@’%’ identified by ‘123456’;
6.安装wordpress
将wordpress安装包解压至/var/www/html/wordpress
开启权限
chmod -R 777 /var/www/html/wordpress为了保证正常安装插件
生成wp-config.php后
最后添加
define(“FS_METHOD”,”direct”);
define(“FS_CHMOD_DIR”, 0777);
define(“FS_CHMOD_FILE”, 0777);
为了更改wordpress上传图片大小限制
在/etc/nginx/nginx.conf适当地方添加
client_max_body_size 100m;
在wordpress根目录添加一个文件maxsize.ini
内容为
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 300
创建链接
sudo ln -s /var/www/html/wordpress/maxsize.ini /etc/php5/fpm/conf.d/
或者在.htaccess添加
php_value upload_max_filesize 100M
php_value post_max_size 100M
nginx静态链接设置
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location /wordpress/ {
try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}
apache和nginx反向代理设置
/etc/apache2/ports.conf 中
NameVirtualHost *:8080
Listen 8080
/etc/apache2/sites-enabled/000-default中
<VirtualHost *:8080>
/etc/nginx/sites-available/default中
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
apache的wordpress伪静态
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
7.树莓派swap扩容
sudo dd if=/dev/zero of=/swapfile bs=1M count=3072
sudo mkswap /swapfile
sudo swapoff /var/swap
sudo swapon /swapfile
更改/etc/fstab加入行
/swapfile swap swap defaults 0 0
8.ftp设置
/etc/vsftpd.conf中
local_enable=YES
write_enable=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
allow_writeable_chroot=YES
/etc/vsftpd.chroot_list中
pi
/var/www/html/目录所有者root所属组pi
chown -R root:pi /var/www/html/
设置权限
chmod -R 775 /var/www/html/
chmod -R 777 /var/www/html/wordpress/wp-content
创建ftp用户
useradd -d /var/www/html/ -s /bin/bash ftpuser
passwd ftpuser
把ftpuser加入pi组
usermod -a -G pi ftpuser
并sudo ln -s /medai/pi/TOSHIBA samba把移动硬盘链接至主目录下
通过这些设置ftp用户pi可访问其主目录和移动硬盘目录以及父目录
ftpuser仅可访问网站根目录
9.samba设置
sudo apt-get install samba samba-common-bin
/etc/samba/smb.conf中
[Raspberry Pi Share]
path = /media/pi/TOSHIBA
valid users = root pi
public = yes
writable = yes
[HTTP Server Root]
path = /var/www/html
valid users = root pi
public = yes
writable = yes
并smbpasswd –a pi添加samba用户
通过以上设置root和pi用户可访问移动硬盘和网站根目录