rasp架设网站

配置apache

sudo apt-get install apache2		#安装
cd /var/www/  #网站默认路径
cd  /etc/apache2/	#配置文件目录
cat apache2.conf  #配置文件
#网站配置文件
cd sites-available  
cd sites-enabled

sudo vi /etc/apache2/ports.conf		#修改监听端口号

sudo service apache2 restart		#重启服务

ports.conf

Listen 80
Listen 81
Listen 82
Listen 83
Listen 84
Listen 85
<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

用来添加新站点的shell

#need 0.conf

files1=sites-available
files2=sites-enabled
if [[ ! -n "$1" || ! -n "$2" ]];then
echo "create website"
echo
elif [ $1 = "1" ];then
echo 
else

echo  'copy file'
sudo cp 0.conf ${files1}/$1.conf      
sudo cp 0.conf $files2/$1.conf


echo 'replace letter'
sudo sed  -i 's/#dir#/'$1'/g'  $files1/$1.conf  
sudo sed  -i 's/#port#/'$2'/g'  $files1/$1.conf	


sudo sed  -i 's/#dir#/'$1'/g'  $files2/$1.conf
sudo sed  -i 's/#port#/'$2'/g'  $files2/$1.conf

echo
echo 'restart service ...'

sudo service apache2 restart
echo 'done'
fi

0.conf

<VirtualHost *:#port#>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/#dir#

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

  • apache里一个站对应一个端口,初始站点调用的是80
  • 有固定ip的时候可以通过域名对80端口进行解析,区分不同的站点
  • 更改apache配置文件之后需要重启apache服务

配置mysql

 sudo apt-get install mysql-server

配置php


sudo apt-get update				#更新list

apt-cache search php5-mysql			#查找mysql拓展

sudo apt-get install php5	#安装php5,需要更改list源
sudo apt-get install php5-mysql		#安装mysql拓展
sudo apt-get install php5-mysqlnd		#安装mysqlnd
sudo apt-get install php5-gd		#安装gd



php --ini	#查看配置文件的路径
php -v		#版本信息
php -i		#查看php详细信息(包括拓展信息)

添加list源

sudo nano /etc/apt/sources.list
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi

#中科大 
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ jessie main non-free contrib 
  • 添加list源之后需要更新list
  • 需要添加“中科大”的list源来完善list库
  • 有些php函数依赖于php拓展,不安装相应拓展就无法识别那些函数
  • 安装php拓展之后需要重启php才能生效

配置ftp

安装ftp

  • sudo apt-get install vsftpd
  • 默认情况下,写入权限是关闭的,需要更改配置文件
  • sudo nano /etc/vsftpd.conf
  • write_enable=YES
  • sudo service vsftpd restart #重启ftp(更改配置文件之后重启ftp才能使之生效)
  • sudo service vsftpd status #查看运行状态

重置ftp

  • 有时候会把config改乱,或者误删config,这时就需要重置ftp的config
  • sudo apt-get purge vsftpd
  • sudo apt-get install vsftpd
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值