Lamp是一组常用于来搭建动态网站或者服务器的软件平台,由linux、apache、mysql、php四个组件组成。
安装开发工具:Development tools、Server Platform Development、Additional Development
源码安装Mysql数据库:下载mysql-5.6.15.tar.gz
- 创建一个mysql用户组和系统帐号
groupadd -r mysql
useradd -r -g mysql mysql
- yum --disablerepo=\* --enablerepo=c6-media remove mysql-libs移除
- 安装cmake ncurses-devel包
- tar -zxvf mysql-5.6.15.tar.gz -C /usr/local
- 进入/usr/local/mysql-5.6.15
6.进行编译
cmake ./ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -
DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -
DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -
DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -
DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
- make && make install
- [[email protected] ~l]#cd /usr/local/mysql 进入目录
chown -R mysql:mysql .更改权限
./scripts/mysql_install_db --user=mysql 进行mysql的初始化安装
chown -R root .
chown -R mysql data/
cp my.cnf /etc拷贝主配置文件
- [[email protected] mysql ]#cd support-files 进入目录
cp -p mysql.server /etc/init.d/mysql
15.[[email protected] support-files]# service mysql restart重启mysql
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
- [[email protected] mysql]# vim /etc/profile增加path变量
/usr/local/mysql/bin
- [[email protected] mysql]# . /etc/profile重新读取
进入数据库
- [[email protected] mysql]# mysqladmin -u root -p password ‘135983‘
- 把数据库加入启动
- echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf库文件输出
22.[[email protected] mysql]# cd /usr/include
- [[email protected] include]# ln -s /usr/local/mysql/include/ mysql头
- [[email protected] include]# vim /etc/man.config 处理手册
增加:MANPATH /usr/local/mysql/man
Mysql安装完毕!
源码安装httpd:下载apr*.tar.gz、apr-util*.tar.gz、httpd*.tar.gz包
- [[email protected] ~]# tar -zxvf apr-1.4.6.tar.gz -C /usr/local/src
- [[email protected] ~]# tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/
- [[email protected] ~]# tar -jxvf httpd-2.4.4.tar.bz2 -C /usr/local/src
- [[email protected] ~]# cd /usr/local/src/
- [[email protected] src]# cd apr-1.4.6/
- [[email protected] apr-1.4.6]# ./configure --prefix=/usr/local/apr
- [[email protected] apr-1.4.6]# make && make install
- [[email protected] apr-1.4.6]# cd ../apr-util-1.5.1/
- [[email protected] apr-util-1.5.1]# ./configure --prefix=/usr/local/apr-utils --with-apr=/usr/local/apr/bin/apr-1-config
- [[email protected] apr-util-1.5.1]# make && make install
- [[email protected] apr-util-1.5.1]# cd ../httpd-2.4.4/
- [[email protected] httpd-2.4.4]# yum --disablerepo=\* --enablerepo=c6-media install pcre-devel opensll-devel
- 编译
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --with-apr=/usr/local/apr/bin/apr-
1-config --with-apr-util=/usr/local/apr-utils/bin/apu-1-config --with-pcre --with-z --enable-mpms-shared=all --enable-proxy --enable-proxy-fcgi
make && make install
- [[email protected] httpd-2.4.4]# cd /usr/local/apache
- [[email protected] apache]# vim /etc/profile 增加path变量
/usr/local/apache/bin
- [[email protected] apache]# . /etc/profile重新读取
- [[email protected] apache]# httpd -k start
19.[[email protected] apache]# vim /etc/man.config增加man手册路径
MANPATH /usr/local/apache/man
20.[[email protected] apache]# cd /usr/include/ 进入目录处理头文件
21.[[email protected] include]# ln -s /usr/local/apache/include apache
22.[[email protected] include]# cd /etc/init.d/
23.[[email protected] init.d]# touch httpd创建控制脚本
24.[[email protected] init.d]# chmod a+x httpd
25.[[email protected] init.d]# vim httpd 编写控制文件脚本
- [[email protected] init.d]# service httpd start
源码安装php:下载php-5.5.8.tar.bz2
把php做成单独的服务器
libjpeg-turbo libjpeg-turbo-devel openjpeg-libs libpng-devel freetype freetype-devel 本地yum安装编译需要的包
1.[[email protected] ~]# tar -jxvf php-5.5.8.tar.bz2 -C /usr/local/src/
2.[[email protected] ~]# cd /usr/local/src/php-5.5.8/
3.在此目录下进行编译
./configure --prefix=/usr/local/php --enable-fpm --enable-sockets --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --enable-xml --with-png-dir --with-gd --with-jpeg-dir --with-zlib --with-freetype-dir --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php5.d
- [[email protected] php-5.5.8]#yum --disablerepo=\* --enablerepo=c6-media install screen 安装screen,防止睡眠中断
5.[[email protected] php-5.5.8]# screen 使用screen
又打开了一个窗口,ctrl+a+d可以离开,screen -ls可以查看
恢复的话 screen -r 编号
- [[email protected] php-5.5.8]# make && make install 安装
- [[email protected] etc]# mkdir /etc/php /etc/php5.d创建文件夹
把php做成单独服务器
- [[email protected] php-5.5.8]# mkdir -pv /etc/php/
- [[email protected] php-5.5.8]# cp php.ini-production /etc/php/php.ini
- [[email protected] php-5.5.8]# cd sapi/fpm 拷贝执行执行脚本
- [[email protected] fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
- [[email protected] fpm]# chmod a+x /etc/init.d/php-fpm执行脚本权限
- [[email protected] fpm]# cd /usr/local/php/etc 进入安装目录
- [[email protected] etc]# cp php-fpm.conf.default php-fpm.conf拷贝成配置文件
- [[email protected] etc]# service php-fpm start 重启php服务
- [[email protected] etc]# chkconfig --add php-fpm 加入启动阵列
- [[email protected] etc]# chkconfig php-fpm on
- [[email protected] etc]# cd /usr/local/src/php-5.5.8/
然后设置反向代理,将访问返回至127.0.0.1 9000端口给php-fpm
vim /etc/httpd/httpd.conf 编辑如下
vim /usr/local/apache/htdocs/index.php如下图
Service httpd restart重启httpd
service iptables stop关闭防火墙
打开pc浏览器输入http://192.168.88.100
说明apache与php已经结合在一起
vim /usr/local/apache/htdocs/index.php如下图
Service httpd restart 重启httpd
Service mysql restart 重启mysql
打开pc浏览器输入http://192.168.88.100
说明通过php已经连接数据库
安装应用:phpwind应用
- [[email protected] ~ ]# unzip phpwind_v9.0_gbk.zip
- [[email protected] ~]# cd phpwind_v9.0_gbk
- [[email protected] phpwind_v9.0_gbk]# mv upload/ /usr/local/apache/htdocs/phpwind
- [[email protected]_v9.0_gbk]#cd/usr/local/apache/htdocs/phpwind
- [[email protected] phpwind]# chmod -R o+w attachment/ conf/ data/ html/ src/ themes/ windid/
访问http://192.168.88.100/phpwind
访问成功!
安装phpMyadmin应用:
- [[email protected] ~]# unzip phpMyAdmin-3.5.8-all-languages.zip
- [[email protected] ~]# mv phpMyAdmin-3.5.8-all-languages /usr/local/apache/htdocs/phpmyadmin
- 访问http://192.168.88.100/phpmyadmin出现下图
输入数据库帐号与密码
登录上去了,如下图
进行压力测试:
[[email protected] ~]# ab -n 1000 -c 500 http://192.168.88.100/phpwind
安装xcache:
- [[email protected] ~]# tar -zxvf xcache-3.1.0.tar.gz /usr/local/src
- [[email protected] ~]#cd /usr/local/src/xcache-3.1.0
- [[email protected] xcache-3.1.0]# /usr/local/php/bin/phpize
- [[email protected] xcache-3.1.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config 编译
- [[email protected] xcache-3.1.0]# make && make install 安装
- [[email protected] xcache-3.1.0]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
进入目录查看下模块
7.[[email protected] no-debug-non-zts-20121212]# ls
opcache.a opcache.so xcache.so
8.[[email protected] no-debug-non-zts-20121212]# cp xcache.so /etc/php5.d/ 把模块移动到php5.d目录下
9.[[email protected] no-debug-non-zts-20121212]# cd/usr/local/src/xcache-3.1.0
10.[[email protected] xcache-3.1.0]# cp xcache.ini /etc/php5.d/
拷贝配置文件
11.[[email protected] xcache-3.1.0]# cd /usr/local/apache/htdocs/
12.[[email protected] htdocs]# vim index.php
service php-fpm restart
访问http://192.168.88.100,进入网页测试下xcache是否加载成功
再进行压力测试!明显增加
[[email protected] ~]# ab -n 1000 -c 500 http://192.168.88.100/phpwind