9、 配置nginx
代码:
sudo vi /etc/nginx/nginx.conf
具体配置网上可以搜到,我的 配置:
代码:
user www-data;
worker_processes 2;
error_log /dev/null crit;
pid /var/run/nginx.pid;
events {
worker_connections 3000;
}
http {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_http_version 1.1;
gzip_comp_level 3;
gzip_types text/css text/xml text/plain application/x-javascript application/xml application/pdf application/x-perl application/x-tcl application/msword application/rtf application/vnd.ms-excel application/vnd.ms-powerpoint application/vnd.wap.xhtml+xml image/x-ms-bmp;
gzip_disable "MSIE [1-6] \.";
gzip_vary on;
output_buffers 4 32k;
client_max_body_size 20m;
server {
listen 80;
server_name localhost;
charset utf-8,gb2312;
access_log /home/
Ubuntu/log/access.log;
location / {
root /home/
Ubuntu/www;
index index.html index.htm index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
set $path_info "/";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
root /home/
Ubuntu/www;
access_log off;
expires 30d;
}
location ~ .*\.(js|css|ico)?$ {
root /home/
Ubuntu/www;
access_log off;
expires 1h;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/
Ubuntu/www;
}
fastcgi_param SCRIPT_FILENAME /home/
Ubuntu/www/$real_script_name;
fastcgi_param script_name $real_script_name;
fastcgi_param path_info $path_info;
include /etc/nginx/fastcgi_params;
}
}
10、下载并安装zendoptimizer,其中 zendoptimizer可以网上去搜,下载后用FileZilla上传到网站目录就行
代 码:
tar zvf zendoptimizer.tar.gz //可以直接将zendoptimizer解压上传后略过这一步
cd zendoptimizer
sudo ./install.sh
安 装过程中会问php.ini的目录,填写成:
代码:
/etc/php5/cgi/
还有一步是问是否安装了apache,选择no
注: 安装zendoptimizer后php.ini目录:/usr/local/Zend/etc
11、安装phpmyadmin
代码:
wget http://cdnetworks-kr-2.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.2/phpMyAdmin-3.3.2-all-languages.tar.gz
tar xvf phpMyAdmin-3.3.2-all-languages.tar.gz
mv phpMyAdmin-3.3.2-all-languages /home/Ubuntu/www/phpmyadmin
12、配 置phpmyadmin(本步不做也可以用,www.linuxidc.com但登录phpmyadmin会有一些错误提示)
建立一个名为phpmyadmin的数据库
把 phpmyadmin目录下scripts/create_tables.sql导入
修改config.inc.php配置文件:
代码:
cd /home/Ubuntu/www/phpmyadmin
cp config.sample.inc.php config.inc.php
vi config.inc.php
将其中的
代码:
$cfg['blowfish_secret'] = ''
改为:
代码:
$cfg['blowfish_secret'] = 'web' //其中的“web”可以是任意英文字符
将以下行中的“//”去掉:
代码:
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma_relation';
// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
将
代码:
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'pmapass';
中的 “pma”和“pmapass”改成你mysql的帐户和密码即可。
13、修改上传文件大小(可以看你自己的情况)
代码:
sudo vi /usr/local/Zend/etc/php.ini
upload_max_filesize = 2M改为5M
14、 设定防火墙
代码:
sudo ufw enable
sudo ufw default deny
sudo ufw allow 80
sudo ufw allow 22
15、上传文件、导入mysql数据
文件上传建议用FileZilla,免费的开源ftp软 件,windows和linux都可以用,支持ssh的22端口。
17、网站建立成功!试试吧!
补充:
如果在服务器上开 放共享文件夹,可以安装samba:
代码:
sudo apt-get install samba
同时,开放ufw的137、 139、445端口:
代码:
sudo ufw allow 137
sudo ufw allow 139
sudo ufw allow 445
设置共享代码:
代码:
sudo vi /etc/samba/smb.conf
示例(一个只读共享和一个隐藏 的可读写共享):
代码:
[软件]
Path = /home/Ubuntu/www/software
Public = yes
[share]
Path = /home/Ubuntu/share
Public = yes
Writable = yes
browseable = no