前提: 本教程基于Ubuntu系统 12.04版本并且需要以root用户操作机器,请在确保您的环境是否符合以上两个条件之后,再进行后续的操作。
本教程主要分为一下几个步骤:更新系统;安装并配置Nginx;安装MySQL;安装并配置PHP; 安装并配置EduSoho,测试Edusoho。
1:更新系统
1.1 更新软件源地址
sudo vim /etc/apt/sources.list
将正文文件内容替换为:
deb http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
1.2 升级软件包
sudo apt-get update
sudo apt-get upgrade
2: 安装Nginx
2.1:安装add-apt-repository
sudo apt-get install python-software-properties
2.2:添加nginx软件源
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
2.3:安装nginx
sudo apt-get install nginx
2.4:配置Nginx
sudo vim /etc/nginx/nginx.conf
然后 在http{} 字段里添加
client_max_body_size 1024M;
sendfile on;
3: 安装MySQL
安装MySQL
apt-get install mysql-server
在这个过程过程中会要求您输入MySQL数据库的root密码,请认真填写。
4:安装PHP
4.1安装PHP
sudo apt-get install php5 php5-cli php5-curl php5-fpm php5-intl php5-mcrypt php5-mysqlnd php5-gd
4.2:修改PHP上传文件的大小限制
sudo vim /etc/php5/fpm/php.ini
添加一下三行配置文字
post_max_size = 1024M
memory_limit = 1024M
upload_max_filesize = 1024M
4.3:配置PHP-FPM
编辑配置文件: vim /etc/php5/fpm/pool.d/www.conf
查找: listen = 127.0.0.1:9000
替换为: listen = /var/run/php5-fpm.sock
然后重启PHP-FPM
sudo /etc/init.d/php5-fpm restart
5: 配置安装EduSoho
5.1:下载/解压程序
mkdir /var/www
cd /var/www
wget http://www.edusoho.com/edusoho-VERSION.tar.gz
tar zxvf edusoho-VERSION.tar.gz
chown www-data:www-data edusoho/ -Rf
rm edusoho-VERSION.tar.gz
注:这里的下载地址可以在http://www.edusoho.com/中可以获取到,VERSION为下载来之后压缩包后面的版本号。
5.2:创建数据库
mysql -uroot -p
然后你需要输入MySQL数据库的密码。
进入数据库命令行模式后,执行:
CREATE DATABASE `edusohodb` DEFAULT CHARACTER SET utf8 ;
GRANT ALL PRIVILEGES ON `edusohodb`.* TO 'esuser'@'localhost' IDENTIFIED BY '';
quit
注: 这里的为edusoho数据库所拥有者esuser的密码,您可以按照您的需要修改。
测试数据库是否创建成功: mysql -uesuser -p--default-character-set=utf8 edusohodb
5.3:配置nginx的虚拟主机
sudo vim /etc/nginx/site-enabled/edusoho
输入以下内容:
server {
listen 80;
server_name YOUR_DOMAIN;
root /var/www/edusoho/web;
access_log /var/log/nginx/edusoho.access.log;
error_log /var/log/nginx/edusoho.error.log;
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/udisk {
internal;
root /var/www/edusoho/app/data/;
}
location ~ ^/(app|app_dev)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_param HTTP_X-Sendfile-Type X-Accel-Redirect;
fastcgi_param HTTP_X-Accel-Mapping /udisk=/var/www/edusoho/app/data/udisk;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
}
location ~* \.(jpg|jpeg|gif|png|ico|swf)$ {
expires 3y;
access_log off;
gzip off;
}
location ~* \.(css|js)$ {
access_log off;
expires 3y;
}
location ~ ^/files/.*\.(php|php5)$ {
deny all;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
配置文件中的 YOUR_DOMAIN 为您需要指定的域名,为了确保您的域名能被他人访问得到, 您需要将这个域名和您当前的机器IP地址做DNS解析工作。
5.4:重启nginx
sudo /etc/init.d/nginx restart
最后一步:
浏览器中打开:http://YOU_DOMAIN 安装,当然这里的YOU_DOMAIN是您的域名。