|
=======================================================================
安装服务器前装相应的扩展
=======================================================================
【适用CentOS操作系统】利用CentOS Linux系统自带的yum命令安装、升级所需的程序库(RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包,进行安装):
sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
=======================================================================
mysql 安装
=======================================================================
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /sinykkdata/webserver/mysql-5.5.16-linux2.6-x86_64.tar.gz
shell> ln -s mysql-5.5.16-linux2.6-x86_64 mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
注意:改变权限时使用的点
一个点(.)代表着当前目录。
二个点(..)代表着上级目录,原理是一样的。
7)启动MySQL服务
# bin/mysqld_safe --user=mysql &
//启动MySQL(The & character tells the operating system to run MySQL in the background;
//it is ignored by MySQL itself.
//如果报错,注意及时查看/usr/local/mysql/var/下的日志文件)
8)设置MySQL启动服务
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld //在自动启动列表里添加mysqld
# chkconfig --level 345 mysqld on
9)修改MySQL密码
# /usr/local/mysql/bin/mysqladmin -u root password 'new-password' //修改密码
// 将localhost替换成你的主机域名,比如:zhaorg.csu.edu.cn
10)登录mysql数据库:
# mysql -u root -p
Enter password: root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18 to server version: 5.0.19-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use mysql;
mysql>delete from user where password=""; //删除用于本机匿名连接的空密码帐号
mysql>flush privileges;
mysql>quit
(或者,也可运行如下命令(Alternatively you can run):
# /usr/local/mysql/bin/mysql_secure_installation
//which will also give you the option of removing the test
//databases and anonymous user created by default. This is
//strongly recommended for production servers.)
11)关闭MySQL服务
# /usr/local/mysql/bin/mysqladmin -u root -p new-password shutdown //关闭MySQL
===============================================================
nginx 安装
===============================================================
#tar zxvf nginx-1.0.8.tar.gz
#cd nginx
#./configure
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events{
use epoll;
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 200m;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name .sinykk.com;
index index.html index.htm index.php;
root /home/wwwroot/;
error_page 404 = /404.php;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
index index.html index.htm index.php;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
expires 30d;
}
}
}
===============================================================
php 安装
===============================================================
下面开始安装5.3.8
tar -zxvf php-5.3.8.tar.gz
cd php-5.3.8
//安装时要记得装MYSQL扩展--with-mysql=/usr/local/mysql --with-jpeg-dir 否者在创建JPEG图片时会错误,ffmpeg-php也会截不了图
./configure --prefix=/usr/local/php --with-configure-file-path=/usr/local/php/etc --with-iconv-dir=/usr/local --enable-fpm --with-mysql=/usr/local/mysql --enable-mbstring --with-mcrypt --with-gd --with-curl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-gd-native-ttf --enable-sockets --enable-zip --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-shared
如果后面MAKE报错时,要考虑是否一些基本的扩展或库未装(一般通过YUM 一键来装)
#make ZEND_EXTRA_LIBS='-liconv' //可以不要
#make
# make install
# cp php.ini-production /usr/local/php/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
接下来,根据需要,编辑 php-fpm.conf 文件中 的若干参数,重要的是监听 IP 地址和端口等,比如 127.0.0.1:9000
pid = run/php-fpm.pid
error_log = log/php-fpm.log
listen = 127.0.0.1:9000
user = www
group = www
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
然后设置 php-fpm 的控制脚本,控制启动和重启、关闭等;
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
# chmod +x /etc/rc.d/init.d/php-fpm
# /sbin/chkconfig -–add php-fpm
# /etc/rc.d/init.d/php-fpm start
也可以如下示例:
php-fpm 关闭:
kill -INT 'cat /usr/local/php/var/run/php-fpm.pid'
php-fpm 重启:
kill -USR2 'cat /usr/local/php/var/run/php-fpm.pid'
查看php-fpm进程数:
ps aux | grep -c php-fpm
到此,安装配置完毕。
===============================================================
memcache配置
===============================================================
libevent-2.0.15-stable.tar.gz
memcache-2.2.6.tgz
memcached-1.4.9.tar.gz
tar vxzf memcache-2.2.6.tgz
cd memcache-2.2.6
/usr/local/php/bin/phpize
./configure –-enable-memcache –-with-php-config=/usr/local/php/bin/php-config –-with-zlib-dir
make
make install
memcached -d -m 10 -u root -l 122.225.117.253 -p 11211 -c 256 -P /tmp/memcached.pid
===============================================================
coreseek(sphinx)配置
===============================================================
tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make
make install
安装按http://www.coreseek.cn/products-install/install_on_bsd_linux/
===============================================================
httpsqs 配置
===============================================================
ulimit -SHn 65535
wget http://httpsqs.googlecode.com/files/libevent-2.0.12-stable.tar.gz
tar zxvf libevent-2.0.12-stable.tar.gz
cd libevent-2.0.12-stable/
./configure --prefix=/usr/local/libevent-2.0.12-stable/
make
make install
cd ../
wget http://httpsqs.googlecode.com/files/tokyocabinet-1.4.47.tar.gz
tar zxvf tokyocabinet-1.4.47.tar.gz
cd tokyocabinet-1.4.47/
./configure --prefix=/usr/local/tokyocabinet-1.4.47/
#注:在32位Linux操作系统上编译Tokyo cabinet,请使用./configure --enable-off64代替./configure,可以使数据库文件突破2GB的限制。
#./configure --enable-off64 --prefix=/usr/local/tokyocabinet-1.4.47/
make
make install
cd ../
wget http://httpsqs.googlecode.com/files/httpsqs-1.7.tar.gz
tar zxvf httpsqs-1.7.tar.gz
cd httpsqs-1.7/
make
make install
cd ../
注意:这个是里面的安装文件夹不能改如 --prefix=/usr/local/libevent-2.0.12-stable/不能改为 --prefix=/usr/local/libevent/
参考:http://blog.s135.com/httpsqs/
请使用命令“killall httpsqs”、“pkill httpsqs”和“kill `cat /tmp/httpsqs.pid`”来停止httpsqs。
注意:请不要使用命令“pkill -9 httpsqs”和“kill -9 httpsqs的进程ID”来结束httpsqs,否则,内存中尚未保存到磁盘的数据将会丢失。
===============================================================
ffmpeg 配置
注:ffmpeg ffmpeg-devel为YUM安装 FFMPEG-PHP 需要修改源码
===============================================================
译安装ffmpeg非常的麻烦,还好我们找到了一个yum源可以方便的安装ffmpeg以及ffmpeg-dev,下面是步骤:
(1)
vi /etc/yum.repos.d/dag.repo
输入:
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
导入Dag的RPM_GPG_KEY,否则提示没有key无法安装
wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
rpm -import RPM-GPG-KEY.dag.txt
安装ffmpeg&ffmpeg-php
yum install ffmpeg ffmpeg-devel
(2)
wget http://ncu.dl.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
tar -xjf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php
#/usr/local/webserver/php/bin/phpize
#./configure --with-php-config=/usr/local/webserver/php/bin/php-config
#make
#make install
######################################################
如果在make 中发现错误提示:make: *** [ffmpeg_frame.lo] Error 1
则:
1 mv ffmpeg_frame.loT ffmpeg_frame.lo
如果有ffmepg-php模块错误提示:php: symbol lookup error: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so: undefined symbol: register_ffmpeg_frame_class
nm /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so|grep register_ffmpeg_frame_class
#输出U register_ffmpeg_frame_class
则修改ffmpeg_frame.c,将3处的PIX_FMT_RGBA32 更改为PIX_FMT_RGB32即可。
#vi ffmpeg_frame.c
#:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32
#:wq!
#./configure --with-php-config=/usr/local/webserver/php/bin/php-config
#make test
#make
#make install
==================================
root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open'
/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv'
/root/php-5.2.12/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] ?.. 1
处理方法:
./configure ............
vi Makefile
找到下面这行:
EXTRA_LIBS = -lcrypt ...
在最后添加-liconv
保存后make通过;make install通过。
|
|
|
|
|
|
|