....... mysql 初始化报错,发现网上有哥们已经解决了这个问题,实在是强大,原因是my.cnf中有一行: thread_concurrency = 8
thread_concurrency这个变量,意思是并发的线程数,并且根据给的解释是该参数取值为服务器逻辑CPU数量×2,而如果每颗物理CPU又支持H.T超线程,所以实际取值为4 × 2 = 8。而我这个机器是ADM闪龙3000 单核的CPU,并不符合它的要求,所以它提示“unknown variable ‘thread_concurrency=8′”是个未知变量。对my.cnf做一些修改,把’thread_concurrency=8′注释掉 重新初始化OK [root@mgmserver mysql]# bin/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
...........
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql var
[root@localhost mysql]# chgrp -R mysql .
[root@mgmserver mysql]# cp share/mysql/mysql.server /etc/init.d/mysqld
[root@mgmserver mysql]# chkconfig --add mysqld
[root@mgmserver mysql]# cd /etc/init.d/
[root@mgmserver init.d]# chmod +x mysqld
[root@mgmserver init.d]# chkconfig --list mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@mgmserver init.d]# service mysqld start
Starting MySQL [确定]
[root@mgmserver init.d]# cp /usr/local/mysql/bin/* /sbin/
[root@mgmserver init.d]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection> Server version: 5.5.3-m3-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
[root@mgmserver init.d]# mysqladmin -u root -h localhost password 'mysql'
[root@mgmserver init.d]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@mgmserver init.d]#
[root@mgmserver init.d]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection> Server version: 5.5.3-m3-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; (3)、编译安装pHP (fastcgi模式)
[root@mgmserver tar_packet]# tar -zxvf php-5.2.14.tar.gz -C ../install_packet/
[root@mgmserver php-5.2.14]# pwd
/home/install_packet/php-5.2.14
[root@localhost install_packet]# gzip -cd php-5.2.14-fpm-0.5.14.diff.gz |patch -d php-5.2.14 -p1
[root@mgmserver php-5.2.14]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash -enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
[root@mgmserver php-5.2.14]# make ZEND_EXTRA_LIBS='-liconv'
[root@mgmserver php-5.2.14]# make install
[root@mgmserver php-5.2.14]# cp php.ini-dist /usr/local/php/etc/php.ini (4)、安装PHP扩展
[root@mgmserver tar_packet]# tar -zxvf memcache-2.2.5.tgz -C ../install_packet/
[root@mgmserver memcache-2.2.5]# /usr/local/php/bin/phpize
[root@mgmserver memcache-2.2.5]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@mgmserver memcache-2.2.5]# make
[root@mgmserver memcache-2.2.5]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
[root@mgmserver tar_packet]# tar -jxvf eaccelerator-0.9.6.1.tar.bz2 -C ../install_packet/
[root@mgmserver install_packet]# cd eaccelerator-0.9.6.1/
[root@mgmserver eaccelerator-0.9.6.1]# /usr/local/php/bin/phpize
[root@mgmserver eaccelerator-0.9.6.1]# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
[root@mgmserver eaccelerator-0.9.6.1]# make
[root@mgmserver eaccelerator-0.9.6.1]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
[root@mgmserver tar_packet]# tar -zxvf PDO_MYSQL-1.0.2.tgz -C ../install_packet/
[root@mgmserver install_packet]# cd PDO_MYSQL-1.0.2/
[root@mgmserver PDO_MYSQL-1.0.2]# /usr/local/php/bin/phpize
[root@mgmserver PDO_MYSQL-1.0.2]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-
mysql=/usr/local/mysql
[root@mgmserver PDO_MYSQL-1.0.2]# make
[root@mgmserver PDO_MYSQL-1.0.2]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613
[root@mgmserver tar_packet]# tar -zxvf ImageMagick.tar.gz -C ../install_packet/
[root@mgmserver ImageMagick-6.5.1-2]# ./configure
[root@mgmserver ImageMagick-6.5.1-2]# make
[root@mgmserver ImageMagick-6.5.1-2]# make install
[root@mgmserver tar_packet]# tar -zxvf imagick-2.3.0.tgz -C ../install_packet/
[root@mgmserver install_packet]# cd imagick-2.3.0/
[root@mgmserver imagick-2.3.0]# /usr/local/php/bin/phpize
[root@mgmserver imagick-2.3.0]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@mgmserver imagick-2.3.0]# make
[root@mgmserver imagick-2.3.0]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/ (5)、修改php.ini文件
找到491行的extension_dir = "./"
修改为 extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613" 指定模块所在的位置;
在这行后面加上
493 extension = "imagick.so"
494 extension = " memcache.so"
495 extension = "pdo_mysql.so"
在 101行处
修改 output_buffering = Off为 output_buffering = On
把523 处的注释去掉, cgi.fix_pathinfo=0 防止nginx文件类型错误解析漏洞 6、配置php加速eaccelerator
创建缓存文件夹;
[root@mgmserver local]# mkdir eaccelerator_cache
在php.ini配置文件末尾加上如下:
1290 [eaccelerator]
1291 extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
1292 eaccelerator.shm_size="32"
1293 eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
1294 eaccelerator.enable="1"
1295 eaccelerator.optimizer="1"
1296 eaccelerator.check_mtime="1"
1297 eaccelerator.debug="0"
1298 eaccelerator.filter=""
1299 eaccelerator.shm_max="0"
1300 eaccelerator.shm_ttl="3600"
1301 eaccelerator.shm_prune_period="360"
1302 eaccelerator.shm_only="0"
1303 eaccelerator.compress="1"
1304 eaccelerator.compress_level="9" (7)、悲剧了,空余的机器被拿去用了,只好换个机器,创建www 用户和组,及两个虚拟主机域名目录www.nginx.com与web.nginx.com
[root@mgmserver ~]# groupadd www
[root@mgmserver ~]# useradd -g www www
[root@nginx ~]# mkdir -p /web/htdocs/www.nginx.com
[root@nginx ~]# chown -R www:www /web/htdocs/www.nginx.com
[root@nginx ~]# mkdir -p /web/htdocs/web.nginx.com
[root@nginx ~]# chown -R www:www /web/htdocs/web.nginx.com/
8、修改php-fpm配置文件,黄色标记的是修改值
1
2
3
4 All> 5
6
7
8 Pid file
9 /usr/local/php/logs/php-fpm.pid
10
11 Error log file
12 /usr/local/php/logs/php-fpm.log
13
14 Log level
15 notice
16
17 When this amount of php processes exited with SIGSEGV or SIGBUS ...
18 10
19
20 ... in a less than this interval of time, a graceful restart will be initiated.
21 Useful to work around accidental curruptions in accelerator's shared memory.
22 1m
23
24 Time limit on waiting child's reaction on signals from master
25 5s
26
27 Set to 'no' to debug fpm
28 yes
29
30
31
32
33
34
35
36 Name of pool. Used in logs and stats.
37 default
38
39 Address to accept fastcgi requests on.
40 Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
41 127.0.0.1:9000
42
43
44
45 Set listen(2) backlog
46 -1
47
48 Set permissions for unix socket, if one used.
49 In Linux read/write permissions must be set in order to allow connections from web server.
50 Many BSD-derrived systems allow connections regardless of permissions.
51
52
53 0666
54
55
56 Additional php.ini defines, specific to this pool of workers.
57
58
59
60
61
62 Unix user of processes
63
64
65 Unix group of processes
66
67
68 Process manager settings
69
70
71 Sets style of controling worker process count.
72 Valid values are 'static' and 'apache-like'
73 static
74
75 Sets the limit on the number of simultaneous requests that will be served.
76 Equivalent to Apache MaxClients directive.
77 Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
78 Used with any pm_style.
79 64(如果机器内存小于3G,可以设置64个进程)
80
81 Settings group for 'apache-like' pm style
82
83
84 Sets the number of server processes created on startup.
85 Used only when 'apache-like' pm_style is selected
86 20
87
88 Sets the desired minimum number of> 89 Used only when 'apache-like' pm_style is selected
90 5
91
92 Sets the desired maximum number of> 93 Used only when 'apache-like' pm_style is selected
94 35
95
96
97
98
99
100 The timeout (in seconds) for serving a single request after which the worker process will be terminated
101 Should be used when 'max_execution_time' ini option does not stop script execution for some reason
102 '0s' means 'off'
103 0s
104
105 The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
106 '0s' means 'off'
107 0s
108
109 The log file for slow requests
110 logs/slow.log
111
112 Set open file desc rlimit
113 65535
114
115 Set max core> 116 0
117
118 Chroot to this directory at the start, absolute path
119
120
121 Chdir to this directory at the start, absolute path
122
123
124 Redirect workers' stdout and stderr into main error log.
125 If not set, they will be redirected to /dev/null, according to FastCGI specs
126 yes
127
128 How much requests each process should execute before respawn.
129 Useful to work around memory leaks in 3rd party libraries.
130 For endless request processing please specify 0
131 Equivalent to PHP_FCGI_MAX_REQUESTS
132 500
133
134 Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
135 Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
136 Makes sense only with AF_INET listening socket.
137 127.0.0.1
138
139 Pass environment variables like LD_LIBRARY_PATH
140 All $VARIABLEs are taken from current environment
141
142 $HOSTNAME
143 /usr/local/bin:/usr/bin:/bin
144 /tmp
145 /tmp
146 /tmp
147 $OSTYPE
148 $MACHTYPE
149 2
150
151
152
153
154
155
156 (9)、启动php-cgi进程,监听127.0.0.1的9000端口,进程数为64
把配置文件的63行和66行修改如下:
62 Unix user of processes
63 www
64
65 Unix group of processes
66 www
切记要把63行和66行的注释符号去掉不然在启动时会出错的!
[ERROR] fpm_unix_conf_wp(), line 124: please specify user and group other than root, pool 'default'
[root@nginx ~]# /usr/local/php/sbin/php-fpm start
Starting php_fpm . done
[root@nginx nginx]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN 2630/hpiod
tcp 0 0 0.0.0.0:833 0.0.0.0:* LISTEN 2347/rpc.statd
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 5285/php-cgi
........ 3、安装nginx (1)、安装nginx及所需要的pcre库
[root@nginx pcre-8.10]# ./configure
[root@nginx pcre-8.10]# make
[root@nginx pcre-8.10]# make install
[root@nginx install_packet]# cd nginx-0.8.48/
[root@nginx nginx-0.8.48]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
[root@nginx nginx-0.8.48]#make
[root@nginx nginx-0.8.48]#make install (2)、创建nginx的日志文件
[root@nginx /]# mkdir -p web/nginxlogs
[root@nginx /]# chmod +w web/nginxlogs/
[root@nginx /]# chown -R www:www web/nginxlogs/ (3)、修改nginx的配置文件如下:
1
2 user www www;
3 worker_processes 1;
4 error_log /web/nginxlogs/error.log crit;
5 pid /usr/local/nginx/nginx.pid;
6 worker_rlimit_nofile 65535;
7 events {
8 use epoll;
9 worker_connections 1024;
10 }
11
12
13 http {
14 include mime.types;
15 default_type application/octet-stream;
16
17 server_names_hash_bucket_size 128;
18 client_header_buffer_size 32k;
19 large_client_header_buffers 4 32k;
20 client_max_body_size 8m;
21
22
23 sendfile on;
24 tcp_nopush on;
25
26 #keepalive_timeout 0;
27 keepalive_timeout 60;
28 tcp_nodelay on;
29
30 fastcgi_connect_timeout 300;
31 fastcgi_send_timeout 300;
32 fastcgi_read_timeout 300;
33 fastcgi_buffer_size 64k;
34 fastcgi_buffers 4 64k;
35 fastcgi_busy_buffers_size 128k;
36 fastcgi_temp_file_write_size 128k;
37
38 gzip on;
39 gzip_min_length 1k;
40 gzip_buffers 4 16k;
41 gzip_http_version 1.0;
42 gzip_comp_level 2;
43 gzip_types text/plain application/x-javascript text/css application/xml;
44 gzip_vary on;
45
46 server {
47 listen 80;
48 server_name www.nginx.com;
49 root /web/htdocs/www.nginx.com;
50 index index.html index.htm index.php;
51
52 location ~.*\.(php|php5)?$ {
53 fastcgi_pass 127.0.0.1:9000;
54 fastcgi_index index.php;
55 include fastcgi.conf;
56 }
57
58 location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$
59 {
60 expires 30d;
61 }
62 location ~.*\.(js|css)$
63 {
64 expires 1h;
65 }
66 log_format wwwaccess '$remote_addr - $remote_user [$time_local] "$request" '
67 '$status $body_bytes_sent "$http_referer" '
68 '"$http_user_agent" $http_x_forwarded_for';
69 access_log /web/nginxlogs/wwwaccess.log wwwaccess;
70 }
71
72
73 server {
74 listen 80;
75 server_name web.nginx.com;
76 root /web/htdocs/web.nginx.com;
77 index index.html index.htm index.php;
78 location ~.*\.(php|php5)?$
79 {
80 fastcgi_pass 127.0.0.1:9000;
81 fastcgi_index index.php;
82 include fastcgi.conf;
83 }
84 log_format webaccess '$remote_addr - $remote_user [$time_local] "$request"'
85 '$status $body_bytes_sent "$http_referer"'
86 '"$http_user_agent" $http_x_forwarded_for';
87 access_log /web/nginxlogs/webaccess.log webaccess;
88 }
89 } (4)、保持conf/下fastcgi.conf配置文件不变就可以了 (5)、启动nginx
[root@nginx nginx]#/usr/
[root@nginx nginx]# /usr/local/nginx/sbin/nginx (6)、开机启动nginx 与php
[root@nginx nginxlogs]# vi /etc/rc.local
ulimit -SHn 65535
/usr/local/php/sbin/php-fpm start
/usr/local/nginx/sbin/nginx
(7)修改文件中先检查配置文件是否正确,然后在启动
[root@nginx nginxlogs]# /usr/local/nginx/sbin/nginx -t
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@nginx nginxlogs]# kill -HUP `cat /usr/local/nginx/nginx.pid`
或者
[root@nginx nginxlogs]# /usr/loca/nginx/sbin/nginx -s> 4、测试
在www.nginx.com的文档目录中
[root@nginx www.nginx.com]# vi index.php/