========================================================================================
PS: 生产环境必须都安装GA版本……很多配置还很不成熟……还需要不断完善和改进……
安装mysql-5.1.36
tar xf mysql-5.1.36.tar.gz -C /usr/src/ ./configure --prefix=/usr/local/mysql --enable-local-infile --with-charset=utf8 --with-extra-charsets=gb2312,gbk,utf8 --with-pthread --with-unix-socket-path=/var/run/mysqld/mysql5.socket --with-mysqld-user=mysql --with-debug --with-big-tables --with-plugins=myisam,myisammrg,heap,innobase,ndbcluster --with-mysqlmanager make && make install
vim my.cnf [mysqld] user=mysql basedir=/usr/local/mysql datadir=/database socket=/var/run/mysqld/mysql5.socket pid-file=/var/run/mysqld/mysql5.pid general-log general-log-file=/var/log/mysqld/mysql5-access.log log-error=/var/log/mysqld/mysql5-error.log port=3306
chown mysql:mysql /var/run/mysqld/ /database/ /var/log/mysqld /usr/local/mysql/ -R /usr/local/mysql/bin/mysql_install_db --datadir=database/ cp /usr/src/mysql-5.1.36/support-files/mysql.server /etc/rc.d/init.d/mysql vim /etc/rc.d/init.d/mysql datadir= basedir= pid_file= conf= servicd mysql start mysql -u root -p
sql>show engines; // no innodb!
==========================================================================================
升级mysql
service mysql stop rsync -av /database /backup/database rsync -av /usr/local/mysql/ /backup/basedir/ rm -rf /database/ rm -rf /usr/local/mysql/ tar xf mysql-5.5.29.tar.gz -C /usr/src/ yum install -y cmake cd /usr/src/mysql-5.5.29/;cmake -LH &> help cmake -DMYSQL_DATADIR:PATH=/database -DWITH_DEBUG:BOOL=ON -DWITH_EXTRA_CHARSETS:STRING=all mkdir /database;chown mysql:mysql /database -R make && make install cd /usr/local/mysql/ mkdir etc cd etc/ vim my.cnf [mysqld] user=mysql basedir=/usr/local/mysql datadir=/database socket=/var/run/mysqld/mysql5.socket pid-file=/var/run/mysqld/mysql5.pid general-log general-log-file=/var/log/mysqld/mysql5-access.log log-error=/var/log/mysqld/mysql5-error.log port=3306 rm -rf /var/log/mysqld/mysql5-access.log rm -rf /var/log/mysqld/mysql5-error.log cp /usr/src/mysql-5.5.29/support-files/mysql.server /etc/rc.d/init.d/mysql5 chmod 755 /etc/rc.d/init.d/mysql5 /usr/src/mysql-5.5.29/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/database/ vim /etc/rc.d/init.d/mysql5 service mysql5 start vim /etc/my.cnf [mysql] socket=/var/run/mysqld/mysql5.socket mysql -u root -p /usr/local/mysql/bin/mysql_upgrade --socket=/var/run/mysqld/mysql5.socket mysql -u root -p sql>show engines; // innodb yes!
====================================================================================
安装apache
libevent \ echo "/usr/local/lib" > /etc/ld.so.conf.d/lamp.conf \ ldconfig yum install -y openssl* nss-devel bzip2-devel libzip-* net-snmp-* //刚开始忘了装 tar xf apr-1.4.6.tar.gz -C /usr/src/ ./configure --disable-ipv6 --enable-threads tar xf libiconv-1.14.tar.gz -C /usr/src/ ./configure --enable-static tar xf apr-iconv-1.2.1.tar.gz -C /usr/src/ ./configure --with-apr=/usr/local/apr/bin/apr-1-config tar xf apr-util-1.5.1.tar.gz -C /usr/src/ cd apr-util-1.5.1/ ln -s /usr/src/apr-iconv-1.2.1/ /usr/src/apr-util-1.5.1/apr-iconv ./configure --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-iconv=./apr-iconv/ --with-openssl=/usr/ \ --with-nss=/usr/ --with-mysql=/usr/local/mysql/ --with-iconv=/usr/local/ tar xf pcre-8.32.tar.gz -C /usr/src/ ./configure --enable-rebuild-chartables --enable-utf8 --enable-newline-is-any --enable-pcregrep-libz --enable-pcregrep-libbz2 (libtool: link: cannot find the library `/usr/src/apr-util-1.5.1/./apr-iconv/lib/libapriconv.la' or unhandled argument `/usr/src/apr-util-1.5.1/./apr-iconv/lib/libapriconv.la')编译apache报错了! ln -s /usr/src/apr-util-1.5.1/./apr-iconv/lib/libapriconv-1.la /usr/src/apr-util-1.5.1/./apr-iconv/lib/libapriconv.la tar xf httpd-2.4.3.tar.gz -C /usr/src/ ./configure --prefix=/usr/local/apache2 \ --enable-modules=all \ --enable-mods-shared=all \ --enable-charset-lite \ --enable-unique-id \ --disable-version \ --with-mpm=prefork \ --enable-http \ --enable-proxy-balancer \ --enable-static-rotatelogs \ --enable-static-htpasswd \ --enable-static-htdigest \ --enable-static-logresolve \ --enable-static-htdbm \ --enable-static-ab \ --enable-static-checkgid \ --enable-static-htcacheclean \ --enable-cgi \ --enable-vhost-alias \ --enable-rewrite \ --enable-so \ --enable-usertrack \ --enable-cgi \ --enable-mime-magic \ --with-apr=/usr/local/apr/bin/apr-1-config \ --with-apr-util=/usr/local/apr/bin/apu-1-config \ --with-pcre=/usr/local \ --with-ssl=/usr ./configure --enable-modules=all --enable-mods-shared=all --enable-file-cache --enable-cache --enable-dumpio --enable-echo --enable-example-hooks --enable-example-ipc --enable-logio --enable-mime-magic --enable-expires --enable-unique-id --enable-proxy --enable-proxy-balancer --enable-proxy-http --enable-proxy-ajp --enable-proxy-connect --enable-ssl --enable-static-ab --enable-http --enable-info --enable-cgi --enable-vhost-alias --enable-so --enable-rewrite --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre=/usr/local/ --with-ssl=/usr/ --with-mpm=prefork make && make install libtool: install: warning: `/usr/src/apr-util-1.5.1/./apr-iconv//lib/libapriconv.la' has not been installed in `/usr/local/apache2/lib' //安装成功了,最后报个小错!呵呵……
------------------------------------------------------------------------------------------------------
conf/httpd.conf
1.zh-CN /usr/local//apache2/conf//httpd.conf \-->Include conf/extra/httpd-languages.conf //取消注释 httpd-languages.conf \-->DefaultLanguage zh-CN \->LanguagePriority zh-CN ...... (Load modules mod_mime and mod_negotiation) 2.vhosts /usr/local//apache2/conf//httpd.conf \-->Include conf/extra/httpd-vhosts.conf httpd-vhosts.conf ------------------> NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin taolr@ln_credbile.cn DocumentRoot "/www" ServerName taolr.ln_credbile.cn ErrorLog "/var/log/httpd/lin-error.log" CustomLog "/var/log/httpd/lin-access.log" common </VirtualHost> ------------------> mkdir /www;chown daemon:daemon /www -R 3.404 /usr/local//apache2/conf//httpd.conf \-->ErrorDocument 404 /404.html 把所有的图片显示为 “/” 下! 4.允许访问 <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Allow from all ///将 Deny改成 Allow </Directory> <Directory /> # AllowOverride none # Require all denied AllowOverride none Require all granted </Directory> 5.索引 写索引页的时候,至少要有简单的结构!否则某些浏览器访问可能会出问题! httpd.conf DirectoryIndex index.html index.php 6.监控 /usr/local//apache2/conf//httpd.conf Include conf/extra/httpd-info.conf httpd-info.conf --------------------------> <Location /server-status> SetHandler server-status # Require host Require ip 192.168.10.0/255.255.255.0 </Location> ExtendedStatus on ///这个需要打开,否则无法监控 CPU! ---------------------------> mkdir /var/log/httpd yum install -y lynx LoadModule slotmem_shm_module modules/mod_slotmem_shm.so LoadModule slotmem_plain_module modules/mod_slotmem_plain.so //一直apache启动不起来,原来是这个模块没添加! httpd -v ///查看了相关的参数,原来我的错如日志在 logs/error-log 查看这儿就能得到了! ///注意,查虚拟主机里面的错误日志是没用的!
==================================================================================
PHP安装前
unzip ft2411.zip yum install -y unzip zip ./configure (wrong) yum install -y dos2unix dos2unix configure cd /usr/src/freetype.2../builds/unix dos2unix * ./configure 转到 freetype目录下,然后 make && make install
---------------------------------------------------
tar xf libpng-1.2.16.tar.gz -C /usr/src/ ./configure --with-pkgconfigdir=/usr/lib64/pkgconfig/ tar xf jpegsrc.v8c.tar.gz -C /usr/src/ ./configure && make && make install 以上三个软件,也即三种图片,为php的库gd而安装的 yum install -y libjpeg-devel freetype-devel libpng-devel //like this!
-----------------------------------------------
yum install -y imake yum install -y libX11-devel yum install -y libXt-devel yum install -y libxcb-devel yum install -y libXext-devel yum install -y libgnomecanvas-devel xmkmf -a make && make install make install.man
-----------------------------------------------
tar xf gd-2.0.36RC1.tar.gz -C /usr/src/ ./configure --with-libiconv-prefix=/usr/local/ --with-png=/usr/local/ --with-freetype=/usr/local/ --with-fontconfig=/usr/ --with-jpeg=/usr/local/ --with-xpm=/usr/local/
==================一些与加密相关的软件包
tar xf libmcrypt-2.5.7.tar.gz -C /usr/src/ ./configure --enable-static tar xf mhash-0.9.9.9.tar.gz -C /usr/src/ ./configure tar xf mcrypt-2.6.8.tar.gz -C /usr/src/ ./configure --with-libiconv-prefix=/usr/local --with-libmcrypt-prefix=/usr/local configure: error: *** libmcrypt was not found ///ldconfig 之后继续! yum install -y libxml2 libcurl-devel
-------------------------------------------------------------------------------
yum reinstall -y openssl openssl-devel cp /usr/local/lib/libpcre.a /usr/libpcre.a cp /usr/local/lib/libpcre.so /usr/libpcre.so cp /usr/local/lib/libpcre.* /usr/local/lib64/ cp /usr/local/lib/libgd.* /usr/local/lib64/
在编译PHP5.2以上版本,经常会看到如下错误,常常以为是PHP的./configure后边什么参数没有写对,很让人费解
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... no
configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore!其实这跟PHP没有关系
那是因为我在编译APACHE的时候,使用--with-mpm模块,所以就必须在编译MYSQL的时候加上 --enable-thread-safe-client.
这是PHP5.2的一个改进,在PHP5.2.0之前的版本都不需要MYSQL启用安全线程。关于--enable-thread-safe-client项的官方介绍如下:如何生成线程式客户端客户端库总是线程安全的。最大的问题在于从套接字读取的net.c中的子程序并不是中断安全的。或许你可能希望用自己的告警中断对服务器的长时间读取,以此来解决问题。如果为SIGPIPE中断安装了中断处理程序,套接字处理功能应是线程安全的。为了避免连接中断时放弃程序,MySQL将在首次调用mysql_server_init()、mysql_init()或mysql_connect()时屏蔽SIGPIPE。如果你打算使用自己的SIGPIPE处理程序,首先应调用mysql_server_init(),然后安装你的处理程序.
//// ---------> 这可如何是好呀!
yum install php-mysql.x86_64 mysql-devel.x86_64 //OK个屁!
-------------------------------------------------------------------------------------
cp -rp /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so ///不行 [root@mysql new]# ln -s /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib64/libmysqlclient.so [root@mysql new]# rm -rf /usr/lib/libmysqlclient.so [root@mysql new]# ln -s /usr/lib64/libmysqlclient.so /usr/lib/libmysqlclient.so ///依然不行 [root@mysql lib]# ln -s /usr/lib64/mysql/libmysqlclient.so.16.0.0 ./libmysqlclient.so
===================================================================================================
编译PHP
./configure --with-apxs2=/usr/local/apache2/bin/apxs --disable-ipv6 --with-libxml-dir=/usr --with-openssl=/usr --with-pcre-regex=/usr/local --with-zlib=/usr --with-bz2=/usr --enable-calendar --with-curl=/usr --with-pcre-dir=/usr/local --enable-ftp --with-openssl-dir=/usr --with-gd=/usr/local --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-zlib-dir=/usr/local --with-xpm-dir=/usr --with-freetype-dir=/usr/local --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash=/usr/local --enable-mbstring --with-mcrypt=/usr/local --with-mysql --with-mysql-sock=/var/run/mysqld/mysql5.socket --with-mysqli=/usr/local/mysql/bin/mysql_config --with-snmp=/usr/ --enable-sockets --enable-zip --with-libdir=/lib64 -------->之前 这儿写错了一个单词 mysql-->myql
=========== --with-mysql --with-libdir=/lib64 ///for 64bit
-----------------------------------------------------------------------
转载部分
64位Linux上编译php时mysql报错一例 2012年06月04日 ? Linux, 操作系统 ? 共 293字 ? 暂无评论 在64位Linux上编译php时,一般需要加入mysql支持,请务必记住加入--with-libdir=/lib64 参数,以保证configure正确发现mysql。 典型的编译语句如下: ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-libdir=/lib64 如果你没加该参数,将会出现以下错误: configure: error: Cannot find libmysqlclient under /usr. Note that the MySQL client library is not bundled anymore!
-----------------------------------------------------------------------------
+--------------------------------------------------------------------------------------------------------+
| *** WARNING *** |
| |
| You have built PHP for Apache's current non-threaded MPM. |
| If you change Apache to use a threaded MPM you must reconfigure |
| PHP with --enable-maintainer-zts |
+--------------------------------------------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------------------------------------------+
//make clean 之后,添加了 --enable-maintainer-zts 还是报这样的警告,重新来一次还是一样的!先忽略了!
make 照样报错!
php5.4.11 安装出现 error: ‘struct gdIOCtx’ has no member named ‘data’
ext/gd/gd_ctx.c:67:8: error: ‘struct gdIOCtx’ has no member named ‘data’
解决方法:这个错误算是php5.4的bug?下面对应的两篇文章有对应的说明:
https://bugs.php.net/bug.php?id=55224
https://bugs.php.net/bug.php?id=60108
个人采用的方法:
vi <gd_dir>/include/gd_io.h /// /usr/local/include/gd_io.h
gdIOCtx结构中增加void *data;
make clean后重新./configure
==========================================================================================
./configure --with-apxs2=/usr/local/apache2/bin/apxs --disable-ipv6 --with-libxml-dir=/usr --with-openssl=/usr --with-pcre-regex=/usr/local --with-zlib=/usr --with-bz2=/usr --enable-calendar --with-curl=/usr --with-pcre-dir=/usr/local --enable-ftp --with-openssl-dir=/usr --with-gd=/usr/local --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-zlib-dir=/usr/local --with-xpm-dir=/usr --with-freetype-dir=/usr/local --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash=/usr/local --enable-mbstring --with-mcrypt=/usr/local --with-mysql --with-mysql-sock=/var/run/mysqld/mysql5.socket --with-mysqli=/usr/local/mysql/bin/mysql_config --with-snmp=/usr/ --enable-sockets --enable-zip --with-libdir=/lib64 --enable-maintainer-zts make && make install
====================================================================经过上面的倒腾,game over!!!
===============后来在32位机器上又编译一次. --with-mysql=/usr/loca/mysql 这个!我记着了!
===============再一次编译, 我甚至放弃了 openssl装了又卸, 卸了又装---
===============LAMP的高效配置很重要, 对我来说还是效率太低了! Coding!
PHP安装完成之后
cp /usr/src/php-5.4.11/php.ini-production /usr/local/lib/php.ini -----------------php.ini 1. session session.save_path = "/tmp/session" // mkdir /tmp/session ;chown daemon:daemon /tmp/session 2. support mysql mysql.default_socket = /var/run/mysqld/mysql5.socket //php4的语法(面向过程) mysqli.default_socket = /var/run/mysqld/mysql5.socket //php5的语法(面向对象) 3. upload file limit upload_max_filesize = 4M //修改论坛上传附件的大小限制!默认2M --------------/usr/local/apache2/conf/httpd.conf LoadModule php5_module modules/libphp5.so ///确认php是否安装成功! AddType application/x-httpd-php .php .phtml //add them! AddType application/x-httpd-php-source .phps
vim /www/index.php
<?php
phpinfo();
?>
service apache2 restart
===============================================================================
PHP扩展包安装
见笔者之前的博文 PHP补丁
LAMP架构完成
=============================================先简单测试phpwind论坛和wordpress博客!
分别解压到 /www
chown daemon:daemon /www -R
然后建库,授权!
mysql>create database bbs;
mysql>grant all on bbs.* to 'tao'@'10.10.24.%' identified by '123'; ///wrong
[mysql>revoke all on bbs.* from 'tao'@'10.10.24.%';]
mysql>grant all on bbs.* to 'tao'@'192.168.10.%' identified by '123';
//因为浏览器虽然在10.10.24.79这儿,但是它连接数据库还是在 192.168.10.112
mysql>show grants for 'tao'@'192.168.10.%';
//可以这样查看赋的权!
create database wordpress; grant all on wordpress.* to 'wordpress'@'10.10.24.%' identified by 'wordpress'; //wrong,改成192.168.10.% revoke all on wordpress.* from 'wordpress'@'10.10.24.%'; //Then flush privileges and commit!] flush privileges;
vim /www/wordpress/wp-config.php
修改好对应的数据库名以及用户和密码之类的信息!【God, 原来我的密码写错了 wordpress-->wordress】
------------------->各种报错,说连不上数据库!然后在 wp-config.php 中添加如下两行,之后看日志处理!
define('WP_ALLOW_REPAIR', true);
define('WP_DEBUG', 'true');
-----------------------------------
-------------------------------------------------
然后修改apache配置文件,添加两台虚拟主机!
还是先基于端口做虚拟主机吧,不基于IP和域名,想到基于域名符合生产环境的要求,
就搭台简单的DNS服务器,也不做智能的分离解析,主从和反向也先不做了,貌似反向解析应该做,
到时候还需要完成windows上邮件系统的搭建,反向解析有必要搭建好!
然后完成基于域名的虚拟主机!
!=====================================DNS===================================
yum install -y bind* caching-nameserver* ///貌似caching-nameserver这个包集成到了bind...包中!
yum install -y ntpdate* //我看时间不对,查看到这儿没有ntp服务器,就用一下微软的呗
ntpdate time.windows.com //简单的时间同步,保证实验的顺利进行!
cp /usr/share/doc/bind-9.8.2/sample/etc/named.conf /var/named/chroot/etc/
cp /usr/share/doc/bind-9.8.2/sample/var/named/named.ca /var/named/chroot/var/named/
cp /usr/share/doc/bind-9.8.2/sample/var/named/named.localhost /var/named/chroot/var/named/
--------->named.conf
options { listen-on port 53 { any; }; direcotry "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { any; }; }; logging { channel default_debugs { file "data/named.run"; severity dynamic; }; zone "." IN { type hint; file "named.ca"; }; zone "ln_credbile.cn" IN { type master; file "ln_credbile.cn.zone"; allow-update { none; }; };
-----------------------
chown named:named named.conf
mv named.localhost ln_credbile.cn.zone
----------------->ln_credbile.cn.zone
$TTL 86400 @ IN SOA taolr.ln_credbile.cn. taolr.ln_credbile.cn ( 20130203 ; serial 3H ; refresh 15M ; retry 1W ; expire 1D ) ; minimum IN NS taolr.ln_credbile.cn. taolr IN A 192.168.10.112 bbs IN A 192.168.10.112 wordpress IN A 192.168.10.112
---------------------------------------
chown named:named named.ca ln_credbile.cn.zone
------------------------先小修改一下主机名
vim /etc/hosts
192.168.10.112 taolr.ln_credbile.cn
vim /etc/sysconfig/network
HOSTNAME=taolr.ln_credbile.cn
hostname 192.168.10.112 //没法重启系统,就先临时生效呗
----------------------------------
named-checkconf named.conf
named-checkzone ln_credbile.cn ln_credbile.cn.zone
……
rndc: neither /etc/rndc.conf nor /etc/rndc.key was found
注意的一个点,CentOS下的DNS和红帽下有一点不同!
centos 6.3下DNS服务器配置问题
service named start
Generating /etc/rndc.key:
运行下面的命令导入key
rndc-confgen -r /dev/urandom -a
service named start ///did it!
=============================================================================
vitualhost配置
/usr/local/apache2/bin/htpasswd -c /usr/local/apache2/conf/.htpasswd user1
/usr/local/apache2/bin/htpasswd /usr/local/apache2/conf/.htpasswd user2
/usr/local/apache2/bin/htpasswd /usr/local/apache2/conf/.htpasswd user3
------->passwd:taolinran
----------------->httpd-vhosts.conf
//NameVirtualHost 192.168.100.30
//启动基于域名的虚拟Web服务器!后面没有 “:80”,端口,后面的就都不要加了!
//如果加了,后面的就都要加上!
<virtualhost>
……
</virtualhost>
<VirtualHost 192.168.10.112> ServerAdmin taolr@ln_credbile.cn DocumentRoot "/www/bbs" ServerName bbs.ln_credbile.cn ErrorLog "/var/log/httpd/bbs-error.log" CustomLog "/var/log/httpd/bbs-access.log" combined <Directory "/www/bbs"> Options Indexes AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost 192.168.10.112> ServerAdmin taolr@ln_credbile.cn DocumentRoot "/www/wordpress" ServerName wordpress.ln_credbile.cn ErrorLog "/var/log/httpd/bbs-error.log" CustomLog "/var/log/httpd/bbs-access.log" combined <Directory "/www/wordpress"> Options Indexes AllowOverride None Order allow,deny AuthName "wordpress" AuthType Basic AuthUserFile /usr/local/apache2/conf/.htpasswd Require valid-user Allow from all </Directory> </VirtualHost>