httpd mysql php_LAMP环境httpd+mysql+php

一、安装编译工具和依赖包

[root@www src]# yum -y install gc gcc-c++ pcre-devel ncurses-devel openssl-devel libpng-devel libtool libxslt-devel libxml2-devel libXpm-devel curl-devel

二、安装PHP和MySQL所需要的软件

1、安装cmake

[root@www cmake-2.8.10.2]# ./bootstrap

[root@www cmake-2.8.10.2]# make && make

2、安装freetype

[root@www freetype-2.4.0]# ./configure --prefix=/usr/local/freetype

[root@www freetype-2.4.0]# make

3、安装libmcrypt

[root@www libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt

[root@www libmcrypt-2.5.8]# make

4、安装libiconv

[root@www libiconv-1.14]# ./configure --prefix=/usr/local/libiconv

[root@www libiconv-1.14]# make install

5、安装jpeg-6b

[root@www src]# cd jpeg-6b/

[root@www jpeg-6b]# mkdir /usr/local/jpeg6

[root@www jpeg-6b]# mkdir /usr/local/jpeg6/bin

[root@www jpeg-6b]# mkdir /usr/local/jpeg6/lib

[root@www jpeg-6b]# mkdir /usr/local/jpeg6/include

[root@www jpeg-6b]# mkdir /usr/local/jpeg6/man/man1 -p

[root@www jpeg-6b]# cp /usr/share/libtool/config/config.sub .

cp: overwrite `./config.sub'? y

[root@www jpeg-6b]# cp /usr/share/libtool/config/config.guess .

cp: overwrite `./config.guess'? y

[root@www jpeg-6b]# ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static

[root@www jpeg-6b]# make

6、安装gd2

[root@www libgd-2.1.1]# ./configure --prefix=/usr/local/libgd2 --with-zlib --with-jpeg=/usr/local/jpeg6 --with-png --with-freetype=/usr/local/freetype

三、安装mysql

1、创建mysql用户

[root@www mysql-5.6.27]# groupadd mysql

[root@www mysql-5.6.27]# useradd -r -g mysql mysql

2、编译安装mysql

[root@www mysql-5.6.27]# cmake . \

> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

> -DMYSQL_DATADIR=/var/lib/mysql \

> -DSYSCONFDIR=/etc \

> -DWITH_INNOBASE_STORAGE_ENGINE=1 \

> -DWITH_MYISAM_STORAGE_ENGINE=1 \

> -DWITH_MEMORY_STORAGE_ENGINE=1 \

> -DWITH_READLINE=1 \

> -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.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

-- Configuring done

-- Generating done

CMake Warning:

Manually-specified variables were not used by the project:

WITH_MEMORY_STORAGE_ENGINE

WITH_READLINE

-- Build files have been written to: /usr/local/src/mysql-5.6.27

[root@www mysql-5.6.27]# gmake

[root@www mysql-5.6.27]# gmake install

3、修改/usr/local/mysql文件权限

[root@www mysql-5.6.27]# chown -R mysql:mysql /usr/local/mysql

[root@www mysql-5.6.27]# ll -d /usr/local/mysql

drwxr-xr-x 13 mysql mysql 4096 Dec 14 12:08 /usr/local/mysql

4、创建数据库存储目录

[root@www mysql-5.6.27]# mkdir /var/lib/mysql

[root@www mysql-5.6.27]# chown mysql. /var/lib/mysql

5、安装系统数据库

[root@www scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/var/lib/mysql --no-defaults --user=mysql

[root@www scripts]# ls /var/lib/mysql/

ibdata1  ib_logfile0  ib_logfile1  mysql  performance_schema  test

6、复制配置文件

[root@www scripts]# cd /usr/local/mysql/support-files/

[root@www support-files]# ls

binary-configure  magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server

[root@www support-files]# cp my-default.cnf /etc/my.cnf

cp: overwrite `/etc/my.cnf'? y

[root@www support-files]# vim /etc/my.cnf    //修改配置

basedir = /usr/local/mysql

datadir = /var/lib/mysql

port = 3306

# server_id = .....

socket = /var/lib/mysql/mysql.sock

7、添加启动脚本并设置开机启动

[root@www support-files]# cp mysql.server /etc/rc.d/init.d/mysqld

[root@www support-files]# chmod +x /etc/rc.d/init.d/mysqld

[root@www support-files]# service mysqld start

Starting MySQL.. SUCCESS!

[root@www support-files]# chkconfig --add mysqld

[root@www support-files]# chkconfig mysqld on

8、登录mysql

[root@www support-files]# /usr/local/mysql/bin/mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.27 Source distribution

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

9、设置mysql环境变量

[root@www www]# vim /etc/profile.d/path.sh

#!/bin/bash

export PATH=$PATH:/usr/local/mysql/bin

[root@www www]# source /etc/profile.d/path.sh

[root@www www]# which mysqld

/usr/local/mysql/bin/mysqld

四、安装apache2

1、安装apr和apr-util

[root@www apr-1.5.2]# ./configure --prefix=/usr/local/apr

[root@www apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

2、编译安装apache2

[root@www httpd-2.2.31]# ./configure \

--prefix=/usr/local/apache2 \

--sysconfdir=/etc/httpd \

--with-included-apr \

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util \

--enable-so \

--enable-deflate=shared \

--enable-expires=shared \

--enable-rewrite=shared \

--with-pcre \

--enable-mem-cache \

--enable-cache \

--enable-static-support \

--with-z

[root@www httpd-2.2.31]# make

[root@www httpd-2.2.31]# make install

make[1]: Leaving directory `/usr/local/src/httpd-2.2.31'

[root@www httpd-2.2.31]# echo $?

0

[root@www ~]# ls /usr/local/apache2/

bin  build  cgi-bin  error  htdocs  icons  include  lib  logs  man  manual  modules

[root@www httpd-2.2.31]# /usr/local/apache2/bin/apachectl start

(98)Address already in use: make_sock: could not bind to address [::]:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs

[root@www httpd-2.2.31]# netstat -tnlp | grep 80

tcp        0      0 :::80                       :::*                        LISTEN      2112/httpd

[root@www ~]# rm -rf /usr/local/apache2

[root@www src]# rm -rf httpd-2.2.31

[root@www src]# rm -rf /etc/httpd

reboot

[root@www ~]# netstat -tnlp | grep 80

[root@www httpd-2.2.31]# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --with-included-apr --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre --enable-mem-cache --enable-cache --enable-static-support --with-z

[root@www httpd-2.2.31]# /usr/local/apache2/bin/apachectl start

[root@www httpd-2.2.31]# netstat -tnlp | grep 80

tcp        0      0 :::80                       :::*                        LISTEN      50223/httpd

[root@www httpd-2.2.31]# /usr/local/apache2/bin/apachectl -t

Syntax OK

3、创建启动脚本

[root@www src]# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

五、安装PHP

1、编译安装php

[root@www php-5.6.14]# ./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-gd=/usr/local/libgd2 \

--with-jpeg-dir=/usr/local/jpeg6 \

--with-freetype-dir=/usr/local/freetype \

--with-mcrypt=/usr/local/libmcrypt \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-libxml-dir \

--with-zlib-dir \

--with-png-dir \

--with-iconv-dir=/usr/local/libiconv \

--with-openssl \

--with-curl \

--enable-soap \

--enable-gd-native-ttf \

--enable-mbstring \

--enable-sockets \

--enable-exif \

--disable-ipv6 \

--enable-ftp \

--with-mhash \

--with-pcre-dir=/usr/bin/pcre-config \

--enable-zip \

--with-bz2

报错:

configure: error: Please reinstall the BZip2 distribution

[root@www php-5.6.14]# yum install -y bzip2 bzip2-devel

Wrote PEAR system config file at: /usr/local/php/etc/pear.conf

You may want to add: /usr/local/php/lib/php to your php.ini include_path

/usr/local/src/php-5.6.14/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin

ln -s -f phar.phar /usr/local/php/bin/phar

Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

[root@www php-5.6.14]# echo $?

0

[root@www php-5.6.14]# ls /usr/local/php/

bin  etc  include  lib  php

2、测试php

[root@www php-5.6.14]# ls /usr/local/apache2/htdocs/index.html

/usr/local/apache2/htdocs/index.html

[root@www php-5.6.14]# cat !$

cat /usr/local/apache2/htdocs/index.html

It works!

[root@www php-5.6.14]#

[root@www php-5.6.14]# vim /etc/httpd/httpd.conf  //修改配置

DirectoryIndex index.html index.php

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php .phtml

创建测试页面

[root@www php-5.6.14]# vim /usr/local/apache2/htdocs/index.php

phpinfo();

?>

[root@www php-5.6.14]# cp php.ini-production /usr/local/php/etc/php.ini

重新加载php配置:

[root@www php-5.6.14]# /usr/local/apache2/bin/apachectl graceful

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值