gaojinguan 发表于 2015-8-19 09:45:33

LAMP的编译日志,

  在CentOS5.2上,编译LAMP的,两年前测试通过的,现在留印
  
  ### 在记事本中 ,不要打开 自动换行,否则一些命令 无法正常运行
###把源文件考到/src/目录下,然后进入/src
/////////////////////////////////////////////////////////////////////
  cd /src
tar zxvf autoconf-2.61.tar.gz   
tar zxvf libxml2-2.6.30.tar.gz
tar zxvf freetype-2.3.5.tar.gz
tar zxvf mysql-5.1.67.tar.gz
tar zxvf gd-2.0.35.tar.gz
tar zxvf httpd-2.2.9.tar.gz
tar zxvf php-5.2.6.tar.gz
tar zxvf jpegsrc.v6b.tar.gz
tar zxvf phpMyAdmin-3.0.0-rc1-all-languages.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
tar zxvf ZendOptimizer-3.2.6-linux-glibc21-i386.tar.gz
tar zxvf libpng-1.2.31.tar.gz
tar zxvf zlib-1.2.3.tar.gz
tar zxvf ncurses-5.6.tar.gz
rm -rf *.gz
  
  cd /src/libxml2-2.6.30
./configure --prefix=/usr/local/libxml2
make && make install
  cd /src/libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install
  cd /src/zlib-1.2.3
./configure
make && make install
  cd /src/libpng-1.2.31
./configure --prefix=/usr/local/libpng
make && make install
  
cd /src/jpeg-6b
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man/man1
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make && make install
  
cd /src/freetype-2.3.5
./configure --prefix=/usr/local/freetype
make && make install
  
cd /src/autoconf-2.61
./configure
make && make install
  
cd /src/gd-2.0.35
./configure --prefix=/usr/local/gd2/--with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/libpng/--with-freetype=/usr/local/freetype/   
  
vi gd_png.c
  
  
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
###
### (上面的make未成功,修改完gd_png.c后,再做一次)
### vi gd_png.c
### 修改 #include "png.h" 为 #include "/usr/local/libpng/include/png.h" 即可。系统默认找不到
### 注意下一行,可能不成功!!进入安装目录检查,如不成,再做一次./configure
###
////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
./configure --prefix=/usr/local/gd2/ --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/
  make && make install
  cd /src/httpd-2.2.9
./configure--prefix=/usr/local/apache2--sysconfdir=/etc/httpd--with-z=/usr/local/zlib/--with-included-apr--enable-so--enable-deflate=shared--enable-expires=shared--enable-rewrite=shared--enable-static-support   
make && make install
  
cd /src/ncurses-5.6
./configure
make && make install
  cd /src/mysql-5.1.67
groupadd mysql
useradd -g mysql mysql
./configure--prefix=/usr/local/mysql   --with-extra-charsets=all
make && make install
cp /src/mysql-5.1.67/support-files/my-medium.cnf /etc/my.cnf
  
/usr/local/mysql/bin/mysql_install_db --user=mysql
  cd /src/php-5.2.6
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql/--with-libxml-dir=/usr/local/libxml2/--with-png-dir=/usr/local/libpng/--with-jpeg-dir=/usr/local/jpeg6/--with-freetype-dir=/usr/local/freetype/--with-gd=/usr/local/gd2/--with-zlib-dir=/usr/local/zlib/--with-mcrypt=/usr/local/libmcrypt/--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-soap--enable-mbstring=all    --enable-sockets   
  make && make install
  cp /src/php-5.2.6/php.ini-dist /usr/local/php/etc/php.ini
  vi /etc/httpd/httpd.conf
  
  
///////////////////////////////////////////////////////////////////////////////////////////
###
### vi /etc/httpd/httpd.conf
###
### 在<IfModule mime_module> 节点 加入
### Addtype application/x-httpd-php .php
### 让它支持php为后缀的文件
###
### 在<Directory "/usr/local/apache2/htdocs">节点
### 将 Options Indexes FollowSymLinks
### 修改为   Options -Indexes FollowSymLinks
### 从Indexs前加上减号。这样即可关闭目录浏览。
### 在紧靠它的下面
### 将AllowOverride None
### 修改为 AllowOverride All
### 这样支持伪静态
###
### 在<IfModule dir_module>节点
### 将 DirectoryIndex index.html
### 修改为DirectoryIndex index.html index.php
### 加上index.php。加上了默认索引页。
###
###
////////////////////////////////////////////////////////////////////////////////////////////
  cd /src/ZendOptimizer-3.2.6-linux-glibc21-i386
./install.sh
  ////////////////////////////////////////////////////////////
###
### 输入 php.ini的目录
### /usr/local/php/etc/
###
/////////////////////////////////////////////////////////////
  cp -a/src/phpMyAdmin-3.0.0-rc1-all-languages /usr/local/apache2/htdocs/phpmyadmin
cd /usr/local/apache2/htdocs/phpmyadmin/
cp config.sample.inc.php config.inc.php
vi config.inc.php
  /////////////////////////////////////////////////////////////
###
### 加入一个密钥
### $cfg['blowfish_secret'] = ""
### 此处加入密钥
###
//////////////////////////////////////////////////////////////
  
vi /etc/init.d/mysql
  
///////////////////////////////////////////////////////////
###
需粘贴的内容
  
#!/bin/sh
#chkconfig:2345 50 20
#description:TralinHotel Mysql 5.1.64 Server
  case "$1" in
'start')
echo "Starting TralinHotel Mysql Database..."
/usr/local/mysql/bin/mysqld_safe --user=mysql &
;;
esac
  ###
### 存盘后,赋予权限
###
  
  chmod 777 /etc/init.d/mysql
  vi /etc/init.d/apache
  
  
///////////////////////////////////////////
需要粘贴的内容
  #!/bin/sh
#chkconfig:2345 40 10
#description:TralinHotel Apache Http Server
  case "$1" in
'start')
echo "Starting TralinHotel Apache Http Server..."
/usr/local/apache2/bin/apachectl start
;;
'stop')
echo "Stop TralinHotel Apache Http Server..."
/usr/local/apache2/bin/apachectl stop
;;
'restart')
echo "Restart TralinHotel Apache Http Server..."
/usr/local/apache2/bin/apachectl restart
esac
  
//////////////////////////////////////////
存盘后,赋予权限
//////////////////////////////////////////////
chmod 777 /etc/init.d/apache
  chkconfig --add mysql
chkconfig --add apache
  
  
  ///////////////////////////////////////////////
  后续问题
mysql的安全性
mysql的字符集
samba的win共享
  ///////////////////////////////////////////////
  

1.打开mysql的控制台
/usr/local/mysql/bin/mysql
  a.设置安全性
  mysql> select * from mysql.user \G
mysql> delete from mysql.user where host='localhost' and user = '';
mysql> FLUSH PRIVILEGES;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('abc123');
  b.设置字符集
  未修改前 ,在查看 >status; 就可以看到4个latin1
  vi /etc/my.cnf
  在 节
加入
default-character-set = utf8
在节点
加入
character-set-server = utf8
collation-server = utf8_general_ci
  
重启后,输入
  /usr/local/mysql/bin/mysql -u root -p
输入密码后,登陆后台
mysql> status;
查看,对应四个utf8
  
  shell监控
  #######################################################################
shell脚本监控报警
#######################################################################
  service sendmail stop
chkconfig sendmail off
  ##检查
pstree |grep sendmail
  ###安装postfix
  yum -y install postfix*
  ### 安装dovecot
  yum -y install dovecot*
  
  ###配置postfix/etc/postfix/
cd /etc/postfix
  vi main.cf
  #myhostname = host.domain.tld 改为
##服务器主机名
myhostname = mail.g.cn
##服务器域名
mydomian = g.cn
  ##发件人的@的后缀
myorigin =$myhostname
myorigin =$mydomain
  ###监听接口,(将最下的那个注释掉)
inet_interfaces = all
#inet_interfaces =localhost
  ###收邮件的后缀
mydestination = $myhostname,$mydomain
  ###服务器所处网段
mynetworks = 192.168.7.0/24, 127.0.0.0/8
  ###允许邮局转发
relay_domains = $mydestination
  ###启动postfix
service postfix start
pstree | grep master
netstat -tunpl |grep 25
chkconfig postfix on
  ###设置默认的邮件转发服务器 由sendmail制定为postfix
alternatives --config mta
出现的提升中,输入编号,回车,即设定默认程序
  
###配置dovecot, /etc/dovecot.conf
vi /etc/dovecot.conf
##将这行的注释去掉
protocols = imap imaps pop3 pop3s
  service dovecot restart
chkconfig devocot on
netstat -tunpl | grep 110
  
###写脚本。
### apache 关闭的报警
  
#!/bin/bash
#apache.sh
  nc -w2 localhost 80
if [ $? -ne 0 ]
then
      echo "apache's 80 port is down,please check. from xuyong"|mail 1213179416@qq.com -s "tralin
  apache is down"
  /usr/local/apache2/bin/apachectl start
  fi
  
  
####mysql的脚本
  #!/bin/bash
#mysql.sh
  nc -w2 localhost 3306
if [ $? -ne 0 ]
then
      echo "mysql's 3306 port is down,please check form xuyong"|mail 1213179416@qq.com -s"mysql is
  down"
      /usr/local/mysql/bin/mysqld_safe &
  
fi
  
  ####磁盘的脚本>80%
  
#!/bin/bash
#disk.sh
  num=`df |awk 'NR==3{print int($4)}'`
if [ $num -ge 80 ]
then
      echo "disk space is ${num}%,now > 80% "|mail 1213179416@qq.com -s "disk space > 80% warining!"
fi
  
  ####测试
dd if=/dev/zero of=test.txt bs=1M count=1000
  ###加入计划任务
###每5分钟,执行一次,
  crontab -e
  
*/5 * * * * /disk.sh
*/5 * * * * /mysql.sh
*/5 * * * * /apache.sh
  
crontab -l
查看计划任务
  
#############################################################################################
  清理root邮箱的
  #############################################################################################
  如果是全部清除,可用cp /dev/nulll /var/spool/mail/root
  要删除一封信,则在 mail 的提示符号下,使用命令
  & d〔letter-number〕
  例如,要删除第二封信,可用如下的方式 & d 2
  若欲删除第一封到第三封信,则可下如下的命令 & d 1-3
  若要杀掉全部的信,则可以使用 & d *
  做root转发,因为root不能远程登录收取邮件。所以做了一个别名。比如xuyong@tralinhotel.cn
  vi /etc/aliases ← 编辑aliases,添加如下行到文尾
  root:   xuyong@tralinhotel.cn
  newaliases← 重建aliasesdb
  echo test | mail root← 发送测试邮件给root
  
#############################################################################################\
  改源的,yum
  #############################################################################################
  
REDHAT yum源修改成CENTOS
1,先将原来的YUM源备份
#mv /etc/yum.conf /etc/yum.conf.bak
#cp -a /etc/yum.repos.d /etc/yum.repos.d.bak
#vim /etc/yum.conf

  
  cachedir=/var/cache/yum
  debuglevel=2
  logfile=/var/log/yum.log
  pkgpolicy=newest
  distroverpkg=redhat-release
  tolerant=1
  exactarch=1
  obsoletes=1
  # PUT YOUR REPOS HERE OR IN separate files named file.repo这两行注释可能会报错,到时候删除即可
  # in /etc/yum.repos.d
  
  
#cd /etc/yum.repos.d
  #rm -rf *
  #vim CentOS-Base.repo
  
name=centos-5 - Base
baseurl=http://centos.ustc.edu.cn/centos/5/os/i386/
# the other site: http://centos.candishosting.com.cn/centos/5/os/i386/
# you can find more site in: http://www.centos.org/modules/tinycontent/index.php?id=13
enabled=1
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#released updates

name=CentOS-5 - Updates
baseurl=http://mirror.centos.org/centos/5/updates/i386/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released

name=CentOS-5 - Addons
baseurl=http://mirror.centos.org/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful

name=CentOS-5 - Extras
baseurl=http://mirror.centos.org/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#additional packages that extend functionality of existing packages

name=CentOS-5 - Plus
baseurl=http://mirror.centos.org/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users

name=CentOS-5 - Contrib
baseurl=http://mirror.centos.org/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
#packages in testing

name=CentOS-5 - Testing
baseurl=http://mirror.centos.org/centos/5/testing/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
  
###################################################################################################
页: [1]
查看完整版本: LAMP的编译日志,