LAMP指的Linux(操作系统)、ApacheHTTP 服务器,MySQL(有时也指MariaDB,数据库软件) 和PHP(有时也是指Perl或Python) 的第一个字母,一般用来建立web 服务器。
安装mysql这里我们用的是mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz的绿色软件包
解压mysql绿色软件包
[[email protected] lamp]# tar -zxvf mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz -C /usr/local
[[email protected] lamp]# groupadd mysql
[[email protected] lamp]# useradd -r -g mysql mysql
[[email protected] lamp]# cd /usr/local
[[email protected] src]# cd mysql
[[email protected] mysql]# chown -R mysql:mysql .
[[email protected] mysql]# ./scripts/mysql_install_db
[[email protected] mysql]# scripts/mysql_install_db --user=mysql
[[email protected] mysql]# chown -R root .
[[email protected] mysql]# chown -R mysql data
[[email protected] mysql]# bin/mysqld_safe --user=mysql
[[email protected] mysql]# cp my.cnf /etc
生成启动脚本
[[email protected] mysql]# cp support-files/mysqld_multi.server /etc/init.d/mysqld
[[email protected] mysql]# chmod a+x /etc/init.d/mysqld
重启mysql服务
[[email protected] mysql]# service mysqld start
给mysql设置管理账号和密码
[[email protected] mysql]# mysqladmin -u root -p password ‘111‘
安装Apache,这里我们用的是httpd-2.4.9.tar.bz2,安装Apache需要先安装apr和apr-util
安装apr到/usr/local/apr
解压apr文件包
[[email protected] lamp]# tar -jxvf apr-1.5.1.tar.bz2 -C /usr/local/src
进入解压后的apr目录
[[email protected] lamp]# /usr/local/src/apr-1.5.1/
安装apr到/usr/local/apr
[[email protected] apr-1.5.1/]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.5.1/]# make && make install
安装apr-util到/usr/local/apr-util
[[email protected] lamp]# tar -jxvf apr-util-1.5.3.tar.bz2 -C /usr/local/src
[[email protected] lamp]# /usr/local/src/apr-util-1.5.3/
[[email protected] apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin
[[email protected] apr-util-1.5.3]# make &&make install
安装http到/usr/local/apache
[[email protected] lamp]# tar -jxvf httpd-2.4.9.tar.bz2 -C /usr/local/src
[[email protected] lamp]# cd /usr/local/src/httpd-2.4.9
[[email protected] /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
[[email protected] /httpd-2.4.9]# make && make install
编写启动脚本文件
[[email protected] /httpd-2.4.9]# touch /etc/init.d/httpd
[[email protected] /httpd-2.4.9]# chmod a+x /etc/init.d/httpd
[[email protected] /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
6 start () {
7 if [ -e $lockfile ]; then
8 echo -e -n "\033[31m the httpd server is started \033[0m"
9 else
10 echo -e -n "\033[32m the httpd server is starting...\033[0m"
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 httpd server 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协议
[[email protected] /httpd-2.4.9]# service httpd restart
测试Apache,在浏览器输入你的apache 服务器地址
安装php
[[email protected] lamp]# tar -jxvf php-5.5.8.tar.bz2 -C /usr/local/src
[[email protected] lamp]# cd /usr/local/src php-5.5.8
[[email protected] 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必须加这个
[[email protected] php-5.5.8]# make && make install
[[email protected] php-5.5.8]# mkdir -pv /etc/php /etc/php5.d
[[email protected] php-5.5.8]# cp .libs/libphp5.so /usr/local/apache/modules/libphp5.so
[[email protected] php-5.5.8]# cp .libs/libphp5.lai /usr/local/apache/modules/libphp5.la
在httpd.conf 加入 AddType application/x-httpd-php .php
[[email protected] php-5.5.8]# echo "AddType application/x-httpd-php .php" >>/etc/httpd/httpd.conf
编写一个php主页放到web服务器
[[email protected] php-5.5.8]# vim ../../apache/htdocs/index.php
重启httpd服务
[[email protected] php-5.5.8]# service httpd restart
打开浏览器进入http://你的web服务器的IP地址/index.php
centos下lamp源码安装,布布扣,bubuko.com