LAMP指的Linux(操作系统)、ApacheHTTP 服务器,MySQL
解压mysql绿色软件包
[root@host2 lamp]# tar -zxvf mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz-C /usr/local
[root@host2 lamp]# groupadd mysql
[root@host2 lamp]# useradd -r -g mysql mysql
[root@host2 lamp]# cd /usr/local
[root@host2 src]# cd mysql
[root@host2 mysql]# chown -R mysql:mysql .
[root@host2 mysql]# ./scripts/mysql_install_db
[root@host2 mysql]# scripts/mysql_install_db --user=mysql
[root@host2 mysql]# chown -R root .
[root@host2 mysql]# chown -R mysql data
[root@host2 mysql]# bin/mysqld_safe --user=mysql
[root@host2 mysql]# cp my.cnf /etc
生成启动脚本
[root@host2 mysql]# cp support-files/mysqld_multi.server /etc/init.d/mysqld
[root@host2 mysql]# chmod a+x /etc/init.d/mysqld
重启mysql服务
[root@host2 mysql]# service mysqld start
给mysql设置管理账号和密码
[root@host2 mysql]# mysqladmin -u root -p password '111'
安装Apache,这里我们用的是httpd-2.4.9.tar.bz2,安装Apache需要先安装apr和apr-util
安装apr到/usr/local/apr
解压apr文件包
[root@host2 lamp]# tar -jxvf apr-1.5.1.tar.bz2-C /usr/local/src
进入解压后的apr目录
[root@ host2 lamp]# /usr/local/src/apr-1.5.1/
安装apr到/usr/local/apr
[root@ host2 apr-1.5.1/]# ./configure--prefix=/usr/local/apr
[root@ host2 apr-1.5.1/]# make&& make install
安装apr-util到/usr/local/apr-util
[root@ host2 lamp]# tar -jxvf apr-util-1.5.3.tar.bz2-C /usr/local/src
[root@ host2 lamp]# /usr/local/src/apr-util-1.5.3/
[root@ host2 apr-util-1.5.3]# ./configure--prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin
[root@ host2 apr-util-1.5.3]# make&&make install
安装http到/usr/local/apache
[root@ host2 lamp]# tar -jxvf httpd-2.4.9.tar.bz2-C /usr/local/src
[root@ host2 lamp]# cd /usr/local/src/httpd-2.4.9
[root@ host2 /httpd-2.4.9]# ./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
[root@ host2 /httpd-2.4.9]# make &&make install
编写启动脚本文件
[root@ host2 /httpd-2.4.9]# touch/etc/init.d/httpd
[root@ host2 /httpd-2.4.9]# chmod a+x/etc/init.d/httpd
[root@ host2 /httpd-2.4.9]# vim/etc/init.d/httpd
1 #!/bin/bash
2 prog=/usr/local/apache/bin/httpd
3 lockfile=/var/lock/subsys/httpd
4 . /etc/init.d/functions
5 start () {
6 if [-e $lockfile ]; then
7 echo -e -n "\033[31m the httpd server is started \033[0m"
8 else
9 echo -e -n "\033[32m the httpd server isstarting...\033[0m"
10
11 sleep 1
12 $prog -k start &
13 if [ $? ]; then
14 echo -e "\033[32m "[STSRT]" \033[0m" && touch $lockfile>/dev/null
15 else echo -e "\033[31m fail\033[0m"
16 fi
17 fi
18 }
19
20
21 stop () {
22
23 if [ ! -e $lockfile ]; then
24 echo -e "\033[31m the httpd server is stoped \033[0m"
25 else
26 $prog -k stop &
27 if [ $? ]; then
28 echo -e -n "\033[32m "the httpdserver is stopping..."\033[0m" >/dev/null
29 sleep 1
30 echo -e "\033[31m "[STOP]" \033[0m" && rm -rf $lockfile
31 else echo -e "\033[31m "[fail]" \033[0m"
32 fi
33 fi
34 }
35
36
37 status () {
38 if [ -e $lockfile ] ;then
39 echo -e "\033[32m the httpd server is started \033[0m"
40 else echo -e "\033[31m the httpd server is stoped \033[0m"
41 fi
42 }
43
44 case "$1" in
45 start)
46 start
47 ;;
48 stop)
49 stop
50 ;;
51 restart)
52 stop
53 start
54 ;;
55 status)
56 status
57 ;;
58 *)
59 echo -e "\033[31m USAGE: start|stop|restart|status \033[0m"
60 esac
重启HTTP协议
[root@host2 /httpd-2.4.9]# service httpdrestart
测试Apache,在浏览器输apache 192.168.10.10服务器地址
安装php
[root@host2lamp]# tar -jxvf php-5.5.8.tar.bz2-C /usr/local/src
[root@ host2 lamp]# cd /usr/local/src php-5.5.8
[root@ host2 php-5.5.8]# ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc/php \
--with-config-file-scan-dir=/etc/php5.d \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-mbstring=all \
--disable-fileinfo /////内存小于1G必须加这个
[root@ host2 php-5.5.8]# make &&make install
[root@ host2 php-5.5.8]# mkdir -pv/etc/php /etc/php5.d
[root@ host2 php-5.5.8]# cp.libs/libphp5.so /usr/local/apache/modules/libphp5.so
[root@ host2 php-5.5.8]# cp.libs/libphp5.lai /usr/local/apache/modules/libphp5.la
在httpd.conf 加入 AddType application/x-httpd-php .php
[root@ host2 php-5.5.8]# echo"AddType application/x-httpd-php .php" >>/etc/httpd/httpd.conf
编写一个php主页放到web服务器
[root@ host2 php-5.5.8]# vim../../apache/htdocs/index.php
重启httpd服务
[root@ host2 php-5.5.8]# service httpdrestart