某公司平台部署linx平台完整过程
部署网站平台
安装MySQL
编译安装MySQL-5.1
# ./configure --prefix=/usr/local/mysql--with-charset=utf8 --enable-assembler --with-extra-charsets=all--with-plugins=all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
[client]
port = 10861
socket = /tmp/mysql.sock
[mysqld]
port = 10861
socket = /tmp/mysql.sock
#skip-locking
key_buffer = 384M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size =8M
myisam_sort_buffer_size= 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8
max_connect_errors =2000
max_user_connections =2000
max_error_count = 2000
wait_timeout = 300
max_connections = 2000
skip-federated
log-bin=mysql-bin
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
#safe-updates
[isamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
|
安装MySQL5.6
1
2
3
4
5
6
7
8
9
10
11
12
|
[mysqld]
server_id = 1
port = 3306
socket = /tmp/mysql.sock
datadir = /data/db
skip-name-resolve
max_user_connections = 2000
max_connections = 2000
log-bin = mysql-bin
expire_logs_days = 7
binlog_format = mixed
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
|
安装Apache-2.4.6
安装apr-1.4.6
安装apr-util-1.4.1
安装pcre-8.32
安装httpd-2.4.6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
|
1
2
3
|
CONFFILE=/etc/httpd/httpd.conf
httpd=${HTTPD-/usr/local/apache/bin/httpd}
pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}
|
安装Nginx-1.4.7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#!/bin/sh
# nginx- this script starts and stops the nginx daemon
#chkconfig: - 85 15
#description: Nginx is an HTTP(S) server,HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
#processname: nginx
#config: /etc/nginx/nginx.conf
#config: /etc/sysconfig/nginx
#pidfile: /var/run/nginx.pid
#Source function library.
./etc/rc.d/init.d/functions
#Source networking configuration.
./etc/sysconfig/network
# Checkthat networking is up.
["$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename$nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f/etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs(){
# make required directories
user=`nginx-V 2>&1 | grep "configure arguments:" | sed's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx-V 2>&1 | grep 'configure arguments:'`
foropt in $options; do
if[ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo$opt | cut -d "=" -f 2`
if[ ! -d "$value" ]; then
#echo "creating" $value
mkdir-p $value && chown -R $user $value
fi
fi
done
}
start(){
[-x $nginx ] || exit 5
[-f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo-n $"Starting $prog: "
daemon$nginx -c $NGINX_CONF_FILE
retval=$?
echo
[$retval -eq 0 ] && touch $lockfile
return$retval
}
stop(){
echo-n $"Stopping $prog: "
killproc$prog -QUIT
retval=$?
echo
[$retval -eq 0 ] && rm -f $lockfile
return$retval
}
restart(){
configtest|| return $?
stop
sleep1
start
}
reload(){
configtest|| return $?
echo-n $"Reloading $prog: "
killproc$nginx -HUP
RETVAL=$?
echo
}
force_reload(){
restart
}
configtest(){
$nginx-t -c $NGINX_CONF_FILE
}
rh_status(){
status$prog
}
rh_status_q(){
rh_status>/dev/null 2>&1
}
case"$1" in
start)
rh_status_q&& exit 0
$1
;;
stop)
rh_status_q|| exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q|| exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q|| exit 0
;;
*)
echo$"Usage: $0{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
|
安装PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
|
整合Apache与PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
ServerRoot"/usr/local/apache"
Listen80
LoadModuleauthn_file_module modules/mod_authn_file.so
LoadModuleauthn_core_module modules/mod_authn_core.so
LoadModuleauthz_host_module modules/mod_authz_host.so
LoadModuleauthz_groupfile_module modules/mod_authz_groupfile.so
LoadModuleauthz_user_module modules/mod_authz_user.so
LoadModuleauthz_core_module modules/mod_authz_core.so
LoadModuleaccess_compat_module modules/mod_access_compat.so
LoadModuleauth_basic_module modules/mod_auth_basic.so
LoadModulereqtimeout_module modules/mod_reqtimeout.so
LoadModulefilter_module modules/mod_filter.so
LoadModulemime_module modules/mod_mime.so
LoadModulelog_config_module modules/mod_log_config.so
LoadModuleenv_module modules/mod_env.so
LoadModuleheaders_module modules/mod_headers.so
LoadModulesetenvif_module modules/mod_setenvif.so
LoadModuleversion_module modules/mod_version.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModulempm_event_module modules/mod_mpm_event.so
LoadModuleunixd_module modules/mod_unixd.so
LoadModulestatus_module modules/mod_status.so
LoadModuleautoindex_module modules/mod_autoindex.so
LoadModuledir_module modules/mod_dir.so
LoadModulealias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
<IfModuleunixd_module>
Userwww
Groupwww
</IfModule>
ServerAdminyou@example.com
ServerName127.0.0.1
<Directory/>
AllowOverride none
Require all denied
</Directory>
<Directory"/usr/local/apache/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModuledir_module>
DirectoryIndex index.phpindex.html index.htm
</IfModule>
<Files".ht*">
Require all denied
</Files>
ErrorLog"logs/error_log"
LogLevelwarn
<IfModulelog_config_module>
LogFormat "%h %l %u %t\"%r\" %>s %b \"%{Referer}i\"\"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t\"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t\"%r\" %>s %b \"%{Referer}i\"\"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log"common
</IfModule>
<IfModulealias_module>
ScriptAlias /cgi-bin/"/usr/local/apache/cgi-bin/"
</IfModule>
<IfModulecgid_module>
</IfModule>
<Directory"/usr/local/apache/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModulemime_module>
TypesConfig /etc/httpd/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddTypeapplication/x-httpd-php .php
AddType application/x-httpd-php-source.phps
</IfModule>
Include /etc/httpd/extra/httpd-vhosts.conf
<IfModuleproxy_html_module>
Include/etc/httpd/extra/proxy-html.conf
</IfModule>
<IfModulessl_module>
SSLRandomSeedstartup builtin
SSLRandomSeedconnect builtin
</IfModule>
# vim /etc/httpd/extra/httpd-vhost.conf
<VirtualHost*:80>
DocumentRoot /data/htdocs/xxx_bbs
ServerName bbs.xxx.com
ErrorLog"/data/logs/apache/bbs.xxx.com.error"
SetEnvIf Request_URI "^/ok\.htm$"dontlog
<Directory />
AllowOverride FileInfo
AllowOverride All
Options FollowSymlinks
Require all granted
</Directory>
ProxyRequests off
ProxyPassMatch ^/(.*)\.php$fcgi://127.0.0.1:9000/data/htdocs/xxx/$1.php
</VirtualHost>
# vim /data/htdocs/xxx_bbs/.htaccess
RewriteEngineOn
RewriteBase/
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^article-([0-9]+)-([0-9]+)\.html$portal.php?mod=view&aid=$1&page=$2&%1
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^forum-(\w+)-([0-9]+)\.html$forum.php?mod=forumdisplay&fid=$1&page=$2&%1
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^group-([0-9]+)-([0-9]+)\.html$forum.php?mod=group&fid=$1&page=$2&%1
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^blog-([0-9]+)-([0-9]+)\.html$home.php?mod=space&uid=$1&do=blog&id=$2&%1
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
RewriteCond%{QUERY_STRING} ^(.*)$
RewriteRule^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1
RewriteCond%{http_host} ^xxx.com [NC]
RewriteRule^(.*)$ [L,R=301]
ErrorDocument404 /404.shtml
RewriteCond%{HTTP_REFERER} !^$ [NC]
RewriteCond%{HTTP_REFERER} !baidu.com [NC]
RewriteCond%{HTTP_REFERER} !google.com [NC]
RewriteCond%{HTTP_REFERER} !google.com.hk [NC]
RewriteCond%{HTTP_REFERER} !xxx.com [NC]
RewriteRule.*\.(gif|jpg)$ [R,NC,L]
|
整合Nginx与PHPgame
# vim /etc/nginx/nginx.conf
worker_processes 4;
events{
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr
- $remote_user[$time_local] "$request" '
# '$status
$body_bytes_sent"$http_referer" '
# '"$http_user_agent""$http_x_forwarded_for"';
server_names_hash_bucket_size
128;
client_header_buffer_size
32k;
large_client_header_buffers
4 32k;
client_max_body_size
8m;
sendfile
on;
tcp_nopush on;
keepalive_timeout
60;
tcp_nodelay
on;
fastcgi_connect_timeout
300;
fastcgi_send_timeout
300;
fastcgi_read_timeout
300;
fastcgi_buffer_size
64k;
fastcgi_buffers
4 64k;
fastcgi_busy_buffers_size
128k;
fastcgi_temp_file_write_size
128k;
gzip
on;
gzip_min_length 1k;
gzip_buffers 4
16k;
gzip_http_version
1.0;
gzip_comp_level
2;
gzip_types text/plain
application/x-javascripttext/css application/xml;
gzip_vary
on;
server {
listen 80;
server_name bbs.xxx.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /data/htdocs/xxx_bbs;
index index.html index.htm;
location ~* \.php$ {
root /data/htdocs/xxx_bbs;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
include /etc/nginx/rewrite.conf;
}
error_page 500
502 503 504 /50x.html;
location
= /50x.html {
root html;
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
|
1
2
3
4
5
6
7
8
9
10
11
12
|
rewrite^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$$1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite^([^\.]*)/forum-(\w+)-([0-9]+)\.html$$1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$$1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$$1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3last;
rewrite^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$$1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
rewrite^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e$request_filename) {
return 404;
}
|
欢迎大家访问我的个人网站 萌萌的IT人
评论暂时关闭