LAMP架设过程

 一、编译安装mysql

[root@bogon ~]# rpm -qa|grep mysql
[root@bogon ~]#rpm -qa|grep mysql|xargs rpm -e --nodeps   //xargs 将前面的 rpm 的结果交给了 xargs 后面的 rpm 命令
[root@bogon ~]# tar zxvf mysql-5[1].1.48.tar.gz –C /usr/src
[root@bogon mysql-5.1.48]# ./configure --prefix=/usr/local/mysql --localstatedir=/data/mysql_db --with-extra-charsets=gb2312,gbk --with-unix-socket-path=/tmp/mysql.sock--enable-thread-safe-client
//--prefix=/usr/local/mysql mysql 安装的目标目录
//--localstatedir=/var/lib/mysql 数据库存放的路径
//--enable-thread-safe-client // 以线程方式编译客户端
checking for termcap functions library... configure: error: No curses/termcap library found
解决方法:编译时加上ncurses库的路径即可解决
./configure --with-named-curses-libs=/usr/lib/libncursesw.so.5
 
[root@bogon mysql-5.1.48]#./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql/ --with-extra-charsets=gb2312,gbk --with-unix-socket-path=/tmp/mysql.sock--enable-thread-safe-client --with-named-curses-libs=/usr/lib/libncursesw.so.5
[root@bogon mysql-5.1.48]# Vi /usr/src/mysql-5.1.48/INSTALL-SOURCE // 安装方法介绍
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .       //*  设置当前目录为 root 用户
shell> chown -R mysql var   //*  设置数据库目录 var mysql 用户
shell> bin/mysqld_safe --user=mysql
 
[root@bogon mysql-5.1.48]# groupadd mysql
[root@bogon mysql-5.1.48]# useradd -g mysql mysql
[root@localhost mysql-5.1.48]#cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql-5.1.48]#chown -R root:mysql /usr/local/mysql // 设定 root 能访问 /usr/local/mysql
[root@localhost mysql-5.1.48]#chown -R mysql /data/mysql_db
[root@localhost mysql-5.1.48]# scripts/mysql_install_db
[root@localhost mysql-5.1.48]# /usr/local/mysql/bin/mysql_install_db  --user=mysql
// 初始化数据库 , 上面两句实验同一功能
[root@localhost mysql-5.1.48]# /usr/local/mysql/bin/mysqld_safe &
[root@localhost mysql-5.1.48]# /usr/local/mysql/bin/mysqladmin -u root password '1'
[root@localhost mysql-5.1.48]# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf  
[root@localhost mysql-5.1.48]# ldconfig –v
// 配置库文件搜索路径
[root@localhost mysql-5.1.48]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile 
 [root@localhost ~]# cp /usr/src/mysql-5.1.48/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# cd /etc/init.d 
[root@localhost init.d]# chmod +x mysqld
[root@localhost init.d]# service mysqld start
// 如果报错,注意及时查看 /usr/local/mysql/var/ 下的日志文件
开机启动
[root@localhost ~]#cp /mysql-5.0.21/support files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost ~]#chmod 755 /etc/rc.d/init.d/mysqld
[root@localhost ~]#chkconfig --add mysqld
[root@localhost ~]#chkconfig --level 345 mysqld on
 
二、编译安装Apache 服务器
[root@localhost httpd-2.2.16]#./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-so--enable-cgi --with-ssl=/usr/local/ssl --enable-suexec --with-suexec-caller=daemon --with-suexec-doroot=/var/www
[root@localhost httpd-2.2.16]#echo "/usr/local/apache2/bin/apachectl start ">>/etc/rc.local
configure: error: xml2-config not found. Please check your libxml2 installation
解决方法:安装libxml2-2.6.24.tar.bz2
[root@localhost libxml2-2.6.24]# ./configure --prefix=/usr/local/libxml2
./configure --prefix=/usr/local/php5 --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --with-libxml-dir=/usr/local/libxml2
[root@localhost libxml2-2.6.24]# Make && Make install
[root@localhost ~]# /usr/local/apache2/bin/apachectl start
httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
解决方法http://frankiehuang.javaeye.com/blog/420353
[root@localhost ~]# setenforce 0
[root@localhost ~]# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/modules/libphp5.so
 
 
三、编译安装php
[root@localhost php-5.2.14]# ./configure --prefix=/usr/local/php5 --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5
//--enable-mbstring:  PHP 支持 mbstring 扩展 ,phpmyadmin 要求使用 mbstring 扩展
//--with-apx2:  编译共享的  Apache 2.0  模块。 FILE  是可选的  Apache apxs  工具的路径,默认指向  apxs
// --with-config-file:  设置  php.ini  的搜索路径。默认为  PREFIX/lib
[root@localhost php-5.2.14]# cp php.ini-dist /usr/local/lib/php.ini
[root@ localhost php-5.2.14]# vi /usr/local/apache2/conf/httpd.conf
DirectoryIndex index.html index.php index.cgi
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
 
httpd: Syntax error on line 54 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: libmysqlclient.so.15: cannot open shared object file: No such file or directory
解决方法:安装mysql-5.0.22-2.1.i386.rpm即可
 
 
#2002 - 服务器没有响应 (or the local MySQL server's socket is not correctly configured)
#2002 - 服务器没有响应 (or the local MySQL server's socket is not correctly configured)
解决方法:将host值改为localhost或者127.0.0.1或者是真实IP,如我写的192.168.1。108S
将socket的值写成具体路径的sock,如/tmp/mysql.sock
 
四、awstats 日志分析工具的配置
[root@localhost ~]# cp -r /root/awstats-6.95 /usr/local/awstats
[root@localhost ~]# cd /usr/local/awstats/tools
[root@localhost tools]# ./awstats_configure.pl
[root@localhost tools]#vi /etc/awstats/awstats.www.abc.com.conf
LogFile="/usr/local/apache2/log/access_log"
[root@localhost tools]# mkdir /var/lib/awstats
[root@localhost tools]# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update-config=www.abc.com     // 创建数据库存放目录,并更新数据库
## 编辑 httpd.conf 配置文件,在 awstats 的目录区域设置,添加认证授权设置
[root@localhost tools]# vi /usr/local/apache2/conf/httpd.conf
<Directory "/usr/local/awstats/wwwroot">S
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "AWSTATS"
    AuthType Basic
    AuthUserFile "/usr/local/awstats/wwwroot/.htpasswd"
    require valid-user
</Directory>
[root@localhost tools]#/usr/local/apache2/bin/apachectl restart
[root@localhost wwwroot]# pwd
/usr/local/awstats/wwwroot
[root@localhost wwwroot]# /usr/local/apache2/bin/htpasswd -c .htpasswd fang
New password:
Re-type new password:
Adding password for user fang
[root@localhost wwwroot]# cd /usr/local/apache2/bin
[root@localhost bin]# ./htpasswd -c /usr/local/awstats/wwwroot/.htpasswd fang
// 以上语句创建存储认证用户账号及口令的文件
phpmyadmin 的安装
[root@localhost ~]#  cd /usr/local/apache2/htdocs/phpmyadmin
[root@localhost ~]# cp config.smaple.inc.php config.inc.php  
[root@localhost ~]#vi config.inc.php
$cfg['blowfish_secret'] = '1';  /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
 
文章参考 http://kk5234.blog.51cto.com/1006247/388509
对于phmyadmin提示 无法载入 mcrypt 扩展,<br />请检查PHP配置可参考
http://kk5234.blog.51cto.com/1006247/390082

 

你可能感兴趣的:(职场,LDAP,休闲)