课程大纲:
1. 下载discuz!
mkdir /date/www
cd /data/www
wget http://download.comsenz.com/DiscuzX/3.0/Discuz_X3.0_SC_UTF8.zip
unzip Discuz_X3.0_SC_UTF8.zip
mv upload/* .
2.配置php-fpm
> /usr/local/php/etc/php-fpm.conf //“>” 这个符号为重定向的意思,单独用它,可以把一个文本文档快速清空
useradd -s /sbin/nologin php-ops
vim /usr/local/php/etc/php-fpm.conf //把之前的内容清空,然后写入如下配置:
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
#listen = /tmp/www.sock
listen = 127.0.0.1:9000
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
slowlog = /path/to/slow.log
request_slowlog_timeout = 1
open_basedir
php_admin_value[open_basedir]=/usr/local/nginx/html:/tmp/ //(多个存放目录用冒号分割)
[ops]
#listen = /tmp/ops.sock
listen = 127.0.0.1:9001
user = php-ops
group = php-ops
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
slowlog = /path/to/slow.log
request_slowlog_timeout = 1
php_admin_value[open_basedir]=/date/www:/tmp //(多个存放目录用冒号分割)
3.配置nginx
> /usr/local/nginx/conf/nginx.conf //“>” 这个符号为重定向的意思,单独用它,可以把一个文本文档快速清空
vim /usr/local/nginx/conf/nginx.conf //把之前的内容清空,然后写入如下配置:
user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 6000;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 3526;
server_names_hash_max_size 4096;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
'$host "$request_uri" $status'
'"$http_referer" "$http_user_agent"';
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 8 4k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm application/xml;
include vhosts/*.conf;
}
mkdir /usr/local/nginx/conf/vhosts
vim /usr/local/nginx/conf/vhosts/default.conf
server
{
listen 8080 default_server;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$ {
include fastcgi_params;
#fastcgi_pass unix:/tmp/www.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
vim /usr/local/nginx/conf/vhosts/chinaops.conf
server
{
listen 80 default_server;
server_name chinaops.com;
index index.html index.htm index.php;
root /date/www;
location ~ \.php$ {
include fastcgi_params;
#fastcgi_pass unix:/tmp/ops.sock;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /date/www$fastcgi_script_name;
}
}
3. 配置mysql,给Discuz!增加一个账户
给mysql root账户设置密码,然后命令行进入mysql,创建新的库,并创建一个新的帐号对该库有所有权限:
> create database discuz;
> grant all on discuz.* to 'aming'@'localhost' identified by '123456aminglinux';
> quit
4. 安装Discuz!
先绑定hosts
192.168.0.106 www.chinaops.com
浏览器输入:
www.chinaops.com
根据提示,修改对应目录的权限
cd /data/www
ps aux | grep php=fpm
chinaops 监听用户为php-ops localhost监听用户为php-fpm
chown php-ops:php-ops data uc_server/data uc_client/data config // 让这几个目录支持nginx运行帐号可写
5慢执行日志
放在/usr/local/php/etc/php-fpm.conf
slowlog = /path/to/slow.log
request_slowlog_timeout = 1
6域名池设置多个所在目录
open_basedir
php_admin_value[open_basedir]=/data/www/:/tmp/
7 用户认正(例如admin.php)
首先需要安装apache (参看lamp中apache的编译安装,或者直接yum install httpd)
编译安装出错,configure: error: /bin/sh build/config.sub --with-pcre failed
configure: WARNING: cache variable ac_cv_build contains a newline 没办法只能进行yum install httpd
vim /usr/local/nginx/conf/vhosts/chinaops.conf
location /abc/ {
auth_basic "lnmp auth";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
}
location ~ .*admin\.php$ {
auth_basic "lnmp auth";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
include fastcgi_params;
#fastcgi_pass unix:/tmp/ops.sock;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /date/www$fastcgi_script_name;
}
请将PHP解析部分加到后面,否则讲不解析直接下载该文件