LAMP

  LAMP架构

实现一个论坛!
phpwind
discus 
手动编译源代码包实现LAMP
关闭系统默认的apache 80 ,mysql 3306
httpd
[root@localhost mysql]# tar fvxj httpd-2.2.11.tar.bz2
CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
加不加这个参数看你的心情!
[root@localhost httpd-2.2.11]# ./configure --with-mpm=prefork --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atormics --enable-mods-shared=most --enable-so
make
make install
默认安装的位置
/usr/local/apache2
启动
[root@localhost conf]# /usr/local/apache2/bin/apachectl -k start
[root@localhost conf]# netstat -ant | grep 80
tcp         0      0 :::80                       :::*                        LISTEN     
[root@localhost conf]# /usr/local/apache2/bin/apachectl -k stop
[root@localhost conf]# netstat -ant | grep 80[root@localhost conf]# /usr/local/apache2/bin/apachectl -k restart
httpd not running, trying to start
[root@localhost conf]# netstat -ant | grep 80tcp         0      0 :::80                       :::*                        LISTEN     
[root@localhost conf]# 
自定义apache启动脚本beat!
#!/bin/bash
APACHE=/usr/local/apache2/bin/apachectl
start() {
        $APACHE -k start
}
stop() {
        $APACHE -k stop
}
restart() {
        $APACHE -k restart
}
case $1 in
start)
        start;;
stop)
        stop;;
restart)
        restart;;
*)
        echo "start|stop|restart"
        ;;
 
esac
 
 
chmod +x /etc/init.d/apache
编译mysql
unset CFLAGS
[root@localhost nginx]# CFLAGS="-O6 -mpentiumpro -fomit-frame-pointer"
[root@localhost nginx]# CXXFLAGS="-O6 mpentiumpro -fomit-rame-pointer -felide-constructors -fno-exceptions -fno-rtti"
[root@localhost nginx]#
专为奔腾系列准备的,可以提高10%
 
系统中,如果没有安装过mysql,就不会有mysql这个用户,所以需要你自己创建
groupadd mysql
useradd -g mysql mysql
yum install gcc gcc-c++ ncurses-devel libtool openssl-devel -y
 
[root@localhost mysql-5.5.3-m3]# ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase --enable-static --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static
 
--enable-static --with-client-ldflags=all-static --with-mysqld-ldflags=all-static
把服务器端和client都使用静态编译(能够提高13%)
--enable-assembler (使用汇编x86的操作符)
--with-embedded-server (编译成embedded mysql library(libmysqld.a))
--with-big-tables 默认的myisam( row 2^32)大表以后可以支持(2 ^32) ^2
--with-extra-charsets=complex 支持多种语言
--enable-thread-safe-client
--with-readline
--enable-local-infile
--with-plugins=innobase 支持innodb 引擎 
编辑
vim /etc/ld.so.conf
将mysql的lib文件加载到系统变量中
[root@localhost mysql]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/mysql/lib/mysql
看到以下信息就ok!
[root@localhost mysql]# ldconfig -v | grep mysql
/usr/lib/mysql:
        libmysqlclient_r.so.15 -> libmysqlclient_r.so.15.0.0
        libmysqlclient.so.15 -> libmysqlclient.so.15.0.0
/usr/local/mysql/lib/mysql:
        libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
        libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
如果为了方便,不妨把系统默认安装的干掉!
 
因为已经有mysql用户了,所以就不用新建!
系统默认的mysql库数据/var/lib/mysql
[root@localhost lib]# pwd
/usr/local/mysql/lib
[root@localhost lib]# ls -ld mysql/
drwxr-xr-x 3 root root 4096 02-28 08:08 mysql/
修改权限
#chown -R mysql.mysql /usr/local/mysql/
建立配置文件
[root@localhost mysql]# pwd
/usr/local/mysql/share/mysql
[root@localhost mysql]# cp my-huge.cnf /etc/my.cnf
改变一下提示符:
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
prompt="\u@\h [\d] \>" 
对数据库进行初始化
修改配置文件,指定datadir
[mysqld]
port             = 3306
socket           = /tmp/mysql.sock
datadir          = /usr/local/mysql/data 
mkdir -pv /usr/local/mysql/data
chown mysql.mysql /usr/local/mysql/data 
执行初始化命令
[root@localhost mysql]# /usr/local/mysql/bin/mysql_install_db --user=mysql
需要注释#thread_concurrency = 4 
接下来需要搞定用谁的问题
使用的时候要注意
如果,service mysqld start ,那就应该用/usr/bin/mysql
如果是我们自己安装的mysql就应该用/usr/local/mysql/bin/mysql 
启动服务
[root@localhost mysql]# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/
[root@localhost mysql]# /etc/init.d/mysql.server start
Starting MySQL.....                                        [确定] 
如果当前系统只有一个你手动安装的mysql
ln -s /usr/local/mysql/bin/* /usr/local/bin
ln -s /usr/local/mysql/libexec/* /usr/local/libexec
ln -s /usr/local/mysql/share/man/man1/* /usr/share/man/man1
ln -s /usr/local/mysql/share/man/man8/* /usr/share/man/man8 
安全清理
[root@localhost mysql]# /usr/local/mysql/bin/mysql_secure_installation
由于冲突,先把系统的那个删除!
按照提示,一一搞定! 
登录看看把! 
安装php
清空之前设置的CFLAGS变量!
#tar fvxz libiconv-1.13.1.tar.gz
#cd libiconv
#./configure --prefix=/usr/local
#make
#make install
tar fvxz libmcrypt-2.5.8.tar.gz
#cd libmcrypt
#./configure
#make
#make install
更新函数库,让你新安装的库起作用
# /sbin/ldconfig
cd 到当前的(libmcrypt下)libltdl
#cd libltdl
#./configure --enable-ltdl-install
#make
#make install
tar fvxz mhash-0.9.9.9.tar.gz
[root@localhost nginx]# tar fvxz mhash-0.9.9.9.tar.gz
[root@localhost nginx]# cd mhash-0.9.9.9
[root@localhost mhash-0.9.9.9]# ./configure
[root@localhost mhash-0.9.9.9]# make
[root@localhost mhash-0.9.9.9]# make install 
建立链接
[root@localhost nginx]# ln -s /usr/local/lib/* /usr/lib/
[root@localhost nginx]# ls /usr/lib/libmcrypt*
/usr/lib/libmcrypt.la /usr/lib/libmcrypt.so.4
/usr/lib/libmcrypt.so /usr/lib/libmcrypt.so.4.4.8
/usr/lib/libmcrypt:
[root@localhost nginx]# ls /usr/lib/libmhash.*
/usr/lib/libmhash.a    /usr/lib/libmhash.so.2
/usr/lib/libmhash.la /usr/lib/libmhash.so.2.0.1
/usr/lib/libmhash.so
[root@localhost nginx]# 
安装mcrypt-2.6.8
[root@localhost mcrypt-2.6.8]# tar fvxz mcrypt-2.6.8.tar.gz
[root@localhost mcrypt-2.6.8]# cd mcrypt-2.6.8[root@localhost mcrypt-2.6.8]# /sbin/ldconfig
[root@localhost mcrypt-2.6.8]# ./configure
[root@localhost mcrypt-2.6.8]# make
[root@localhost mcrypt-2.6.8]# make install
[root@localhost mcrypt-2.6.8]# 
yum install libxml2-devel curl-devel libpng-devel freetype-devel libjpeg-devel -y
安装开发库
tar fvxz php-5.2.14.tar.gz
[root@localhost php-5.2.14]# ./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-apxs2=/usr/local/apache2/bin/apxs --with-iconv-dir=/usr/local/ --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf 
make ZEND_EXTRA_LIBS='-liconv' && make install  
看到这个,你就ok鸟! 
[root@localhost modules]# pwd
/usr/local/apache2/modules
[root@localhost modules]# ls | grep php
libphp5.so
[root@localhost modules]#
 
修改apache的配置文件
 AddType application/x-httpd-php .php
<IfModule dir_module>
   DirectoryIndex index.html index.php
</IfModule> 
cp 配置文件给php
[root@localhost php-5.2.14]# pwd
/usr/local/src/nginx/php-5.2.14
[root@localhost php-5.2.14]# cp php.ini-dist /usr/local/php/etc/php.ini
[root@localhost php-5.2.14]#
注意php不是一个服务,不需要单独启动!
 
重新启动apache
/etc/init.d/apache restart 
vin /var/www/html/index.php
<? phpinfo() ?> 
安装
pdo (php data objects layer)
php是一个脚本语言.
[root@localhost nginx]# tar fvxz PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
[root@localhost PDO_MYSQL-1.0.2]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:          20041225
Zend Module Api No:       20060613
Zend Extension Api No:    220060519
[root@localhost PDO_MYSQL-1.0.2]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/ 
[root@localhost PDO_MYSQL-1.0.2]# make
[root@localhost PDO_MYSQL-1.0.2]# make install
修改php的配置文件
[root@localhost PDO_MYSQL-1.0.2]# vim /usr/local/php/etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613"
extension = "pdo_mysql.so"

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