關閉SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #註釋掉
#SELINUXTYPE=targeted #註釋掉
SELINUX=disabled #增長
:wq! #保存退出
setenforce 0 #使配置當即生效
mysql 5.5.28安裝
安裝路徑:/usr/local/mysql
數據庫路徑:/usr/local/mysql/data/
mysql從5.5版本開始,再也不使用./configure編譯,而是使用cmake編譯器,具體的cmake編譯參數能夠參考mysql官網文檔
http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
添加MYSQL用戶和組
[root@localhost tools]#groupadd mysql
[root@localhost tools]#useradd mysql -g mysql -s /sbin/nologin
[root@localhost tools]#yum install cmake make -y
[root@localhost tools]#yum -y install gcc gcc-c++ autoconf bison automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* #安裝依賴包
[root@localhost tools]# cd mysql-5.5.28-linux2.6-i686
配置編譯參數
[root@localhost tools]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data/ \
-DMYSQL_TCP_PORT=3306
[root@localhost tools]#CMake Error: The source directory "/root/tools/mysql-5.5.28-linux2.6-x86_64" does not appear to contain CMakeLists.txt.
編譯安裝時出現上述錯誤,GOOGLE了一下,發現是下載的包有問題,從新到http://downloads.mysql.com/archives/community/下載源碼,版本選5.5.28,
Select Platform:這裏選擇Source Code,而後在底部找到Generic Linux (Architecture Independent), Compressed TAR Archive(mysql-5.5.28.tar.gz)選下載
[root@localhost tools]#make && make install
[root@localhost tools]#cd /usr/local
[root@localhost tools]#chown mysql.mysql -R mysql #設置MYSQL目錄權限
[root@localhost tools]#cd mysql
[root@localhost tools]#cp support-files/my-medium.cnf /etc/my.cnf #複製配置文件
[root@localhost tools]#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
[root@localhost tools]#cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost tools]#chkconfig mysqld on #設置開機啓動
[root@localhost tools]#service mysqld start #啓動mysql服務
[root@localhost tools]#/usr/local/mysql/bin/mysqladmin -u root password '123456789' #設置mysql root用戶密碼
刪除root密碼爲空的記錄
[root@localhost tools]#/usr/local/mysql/bin/mysql -u root -p #輸入剛纔設置的密碼
mysql> use mysql;
mysql> delete from user where password='';
mysql> flush privileges; #更新權限
mysql> grant all privileges on *.* to root@'%' identified by "root"; #容許ROOT用戶遠程登錄
mysql> flush privileges;
mysql> quit
php-5.3.28安裝
安裝依賴包
[root@localhost tools]#yum -y install 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
[root@localhost tools]#yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel
#Nginx
[root@localhost tools]#yum -y install pcre-devel
#下載PHP庫文件
wget http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget http://nchc.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.tar.bz2
#Nginx
wget http://nginx.org/download/nginx-1.5.10.tar.gz
#Nginx(pcre)
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
解壓下載的庫文件夾
[root@localhost tools]#cd libiconv-1.14
[root@localhost tools]#./configure --prefix=/usr/local
[root@localhost tools]#make && make install
[root@localhost tools]#cd ../
[root@localhost tools]#cd libmcrypt-2.5.8
[root@localhost tools]#./configure
[root@localhost tools]#make && make install
[root@localhost tools]#/sbin/ldconfig #使全部的庫文件都被緩存到ld.so.cache中,避免編譯過程當中報錯找不到庫文件
[root@localhost tools]#cd ../
[root@localhost tools]#cd libltdl
[root@localhost tools]#./configure --enable-ltdl-install
[root@localhost tools]#make && make install
[root@localhost tools]#cd ../../
[root@localhost tools]#cd mhash-0.9.9.9
[root@localhost tools]#./configure
[root@localhost tools]#make && make install
[root@localhost tools]#cd ../
[root@localhost tools]#ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
[root@localhost tools]#ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
[root@localhost tools]#ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
[root@localhost tools]#ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
[root@localhost tools]#ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
[root@localhost tools]#ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
[root@localhost tools]#ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
[root@localhost tools]#ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
[root@localhost tools]#ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
[root@localhost tools]#ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
[root@localhost tools]#ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/
[root@localhost tools]#ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[root@localhost tools]#cd mcrypt-2.6.8
[root@localhost tools]#/sbin/ldconfig
[root@localhost tools]#./configure
[root@localhost tools]#make && make install
[root@localhost tools]#cd ../
[root@localhost tools]#cd php-5.3.28
[root@localhost tools]#./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-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --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(後面的參數在5.5以上版本無效:--enable-discard-path --enable-safe-mode --with-curlwrappers --enable-fastcgi --enable-force-cgi-redirect)
[root@localhost tools]#make && make installjavascript
若是make的時侯出現下面的錯誤:
/root/tools/php/php-5.3.28/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open'
/root/tools/php/php-5.3.28/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv'
/root/tools/php/php-5.3.28/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] 錯誤 1
有make的時侯加上下面一句:
[root@localhost tools]#make ZEND_EXTRA_LIBS='-liconv'
[root@localhost tools]#make install
[root@localhost tools]#
[root@localhost tools]#cp php.ini-production /usr/local/php/etc/php.ini
[root@localhost tools]#ln -s /usr/local/php/etc/php.ini /etc/php.ini
[root@localhost tools]#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost tools]# chmod a+x /etc/init.d/php-fpm
[root@localhost tools]#chkconfig php-fpm on
[root@localhost tools]#cd /usr/local/php/etc/
[root@localhost tools]#cp php-fpm.conf.default php-fpm.conf
[root@localhost tools]#vi php-fpm.conf
把;pid = run/php-fpm.pid前面的分號去掉=>pid = run/php-fpm.pid
user = nobody 改成user = www
group = nobody 改成group = www
保存退出
[root@localhost tools]#cd /root/tool
[root@localhost tools]#tar -xjvf eaccelerator-0.9.6.1.tar.bz2
[root@localhost tools]#cd eaccelerator-0.9.6.1
[root@localhost tools]#/usr/local/php/bin/phpize
[root@localhost tools]#./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
[root@localhost tools]# make && make install
[root@localhost tools]#mkdir /tmp/eaccelerator
[root@localhost tools]#chmod 0777 /tmp/eaccelerator
[root@localhost tools]#vi /etc/php.ini
修改;extension_dir = "./" 爲extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"
在結尾處添加
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
:x保存退出
重啓PHP
[root@localhost tools]#/etc/rc.d/init.d/php-fpm restart
安裝NGINX 1.2.9
[root@localhost tools]# cd pcre-8.34
[root@localhost tools]# ./configure
[root@localhost tools]# make && make install
[root@localhost tools]# cd ..
[root@localhost tools]# cd nginx-1.2.9
[root@localhost tools]# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre
[root@localhost tools]# make && make install
[root@localhost tools]# ulimit -SHn 65535
[root@localhost tools]# ln -s /usr/local/lib/libpcre.so.1 /lib #解決啓動時找不到libpcre.so.1這個模塊的問題
[root@localhost tools]# vi /usr/local/nginx/conf/nginx.conf
#nginx配置文件內容
user www www;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
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"';
access_log logs/access.log ;
charset utf-8;
server_names_hash_bucket_size 128;#服務器名字的hash表大小
client_header_buffer_size 32k;#設置客戶端的請求頭的header buffer的大小
large_client_header_buffers 4 64k;#用來指定客戶端請求中較大的消息頭緩存的最大數量和大小
client_max_body_size 8m;#設置容許客戶端請求的最大的單個文件的字節數
sendfile on;#開啓高效文件傳輸模式
tcp_nopush on;#防止網絡阻塞
tcp_nodelay on; #防止網絡阻塞
keepalive_timeout 60; #長鏈接超時時間,單位是秒
#FastCGI相關參數是爲了改善網站的性能:減小資源佔用,提升訪問速度。下面參數看字面意思都能理解。
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模塊設置
gzip on; #開啓gzip壓縮輸出
gzip_min_length 1k; #最小壓縮文件大小
gzip_buffers 4 16k; #壓縮緩衝區
#gzip_http_version 1.0; #壓縮版本(默認1.1,前端若是是squid2.5請使用1.0)
gzip_comp_level 2; #壓縮等級
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server {
listen 80;
server_name www.test.com test.com 192.168.1.33;
root /home/web/test;
#charset utf-8;
access_log logs/test.access.log ;
index index.php index.html index.htm;
location / {
root /home/web/test;
index index.php index.html index.htm;
}
#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;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
}
[root@localhost tools]#service iptables stop #關閉防火牆,否則訪問不到網站目錄
安裝memcache,imagemagick php擴展
wget wget http://monkey.org/~provos/libevent-2.0.12-stable.tar.gz
wget http://www.memcached.org/files/memcached-1.4.17.tar.gz
wget http://pecl.php.net/get/memcache-3.0.8.tgz
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-3.1.2.tgz
[root@localhost tools]# cd libevent-2.0.12-stable
[root@localhost tools]# ./configure
[root@localhost tools]# make && make install
[root@localhost tools]# cd ..
[root@localhost tools]# cd memcached-1.4.17
[root@localhost tools]# ./configure
[root@localhost tools]# make && make install
[root@localhost tools]# cd ..
[root@localhost tools]# ldconfig /usr/local/lib
[root@localhost tools]# /usr/local/bin/memcached -d -m 128 -l 192.168.1.33 -p 11211 -u www #d daemon 以守護程序(daemon)方式運行 memcached -l監聽地址 -m內存
[root@localhost tools]# cd memcache-3.0.8 #安裝PHP擴展
[root@localhost tools]# /usr/local/php/bin/phpize
[root@localhost tools]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@localhost tools]# make && make install
[root@localhost tools]# cd ..
安裝imagemagick,linux下的圖片處理程序和PDO PHP擴展
[root@localhost tools]# cd ImageMagick-6.8.9-0
[root@localhost tools]# ./configure
[root@localhost tools]# make && make install
[root@localhost tools]# cd ..
[root@localhost tools]# cd imagick-3.1.2 #安裝PHP下的擴展
[root@localhost tools]# /usr/local/php/bin/phpize
[root@localhost tools]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@localhost tools]# make && make install
[root@localhost tools]#cd ..
[root@localhost tools]#cd php-5.3.28/ext/pdo_mysql
[root@localhost tools]#/usr/local/php/bin/phpize
[root@localhost tools]#./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/
[root@localhost tools]#make && make install
[root@localhost tools]# vi /etc/php.ini
添加extension=memcache.so
extension=imagick.so
extension=pdo_mysql.sophp