一、lamp编译
linux+apache+mysql+php
通过appchae能够找到php来解析php脚本,通过php来操作数据库
1、安装gcc编译器
linux下源代码C语言如何编译
查看内存 free
查看硬盘 fdisk -l
查看挂载情况 df -h
编译过程:生成配置文件、编译、安装
在软件安装包里 .h文件是C语言的函数库
以安装appache httpd为例:进入到软件包中,使用: ./configure --prefix=/usr/local/httpd2_name 定义配置文件-安装路径、
make 开始编译
make install 开始安装
2、安装appache软件包
检查系统是否已经安装了lamp环境
Rpm -qa|grep httpd
Rpm -qa|grep mysql
Rpm -qa|grep php
卸载已经卸载的httpd/mysql/php
yum remove htpd
yum remove mysql
yum remove php
源代码的包删除时直接删除安装目录
3、lamp 安装
密码:zdov
安装
libxml2-2.6.30
tar -xvzf libxml2-2.6.30.tar
cd libxml2-2.6.30
./configure --prefix=/usr/local/libxml/
make
make install
完成安装
libmcrypt-2.5.8
tar -xvzf libmcrypt-2.5.8.tar
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt/
make
make install
完成安装
如遇报错:error: C++ compiler cannot create executables
原因分析:组件没有安装完全
解决措施:yum install gcc gcc-c++ gcc-g77
注意:我的yum源是
name=rhl-medi
baseurl=file:/// #挂载了光盘 提取密码:x7vlenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release安装libledl 在libmcrypt源码目录中
cd libmcrypt-2.5.8/libltdl
./configure --enable-ltdl-install
make
make install
安装zlib-1.2.3
cd zlib-1.2.3
./configure
make
make install
安装libpng
cd libpng-1.2.31/
./configure --prefix=/usr/local/libpng/
make
make install
会报错:make[1]: *** [libpng12.la] Error 1
问题:操作系统
解决措施:
cd zlib-1.2.3 //进入zlib目录
CFLAGS="-O3 -fPIC" ./configure make make install 再出来,安装libpng
安装jpeg6
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man/man1
cd /jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
如果报错:./libtool --mode=compile gcc -O2 -I. -c ./jcapimin.c *** [jcapimin.lo] Error 127
问题:libtool 工具包过时
解决措施:新解压libtool工具包,源码安装
unzip libtool242.zip
cd libtool
./configure
make
make install
cd jpeg-6b/
cp /usr/local/share/libtool/config/config.sub . cp /usr/local/share/libtool/config/config.guess .
再次执行安装jpeg6 ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static make make install
7、安装freetype
cd freetype-2.3.5/
./configure --prefix=/usr/local/freetype/
make
make install
8、安装autoconf
cd /autoconf/
./configure
make
make install
9、安装GD
mkdir /usr/local/gd2
cd gd-2.0.35
vi gd_png.c
写入:
用 #include "/usr/local/libpng/include/png.h" 替换掉 #include "png.h"
./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/ --with-png=/usr/local/libpng/
make
make install
三、接下来安装appache(http)
tar -xvf httpd-2.2.9.tar.gz
cd /httpd-2.2.9
./configure --prefix=/usr/local/appache2/ --sysconfdir=/usr/local/appache2/etc/ --with-included-apr --enable-dav --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared
make
make install
vi /etc/rc.d/rc.local
添加:/usr/local/appache2/bin/apachectl start 开机启动httpd服务
/usr/local/appache2/etc 存放配置文件
/usr/local/appache2/htdocs存放网站根目录
四、安装mysql源码安装
1、安装neurses
yum -y install ncurses*
2、编译安装
tar -xvf mysql-5.5.20.tar.gz
cd /mysql-5.5.20
创建用户组:
- groupadd mysql //所以在这里我们要建一个msyql的用户和组
- useradd -g mysql mysql -s /usr/sbin/nologin
- mkdir /usr/local/mysql //创建目录
- mkdir /usr/local/mysql/data //数据仓库目录
执行安装命令:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=103306
注意:一行写完,若换行 需加 ‘\’
make
make install
- //安装mysql默认的数据库
- /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
- cp support-files/my-medium.cnf /usr/local/mysql/my.cnf //copy配置文件
- chown -R mysql:mysql /usr/local/mysql //更改权限
- nano /usr/local/mysql/my.cnf //加上以下内容
- 在[mysqld下] 加上以下内容
- basedir = /usr/local/mysql
- datadir = /usr/local/mysql/data
- log-error = /usr/local/mysql/mysql_error.log
- pid-file = /usr/local/mysql/mysql.pid
- user = mysql
- tmpdir = /tmp
启动mysql my.cnf配置文件
- cd /usr/local/mysql/support-files/
- cp ./mysql.server /etc/init.d/mysql5
- /etc/init.d/mysql5 start
- 修改密码:/usr/local/mysql/bin/mysqladmin -uroot password sn123456
- 测试登录 /usr/local/mysql/bin/mysql -u root -psn123456 test #p后边无间隙的
以下两句没什么用
Setfacl -m u:mysql:rwx -R /usr/local/mysql 这只只要以后加到mysql用户组中的用户都对该目录由所有权
Setfacl -m d:u:mysql:rwx -R /usr/local/mysql
六、安装PHP
1、安装libtool-Itdl软件包
进入 media 下的 Package 下
rpm -ivh libtool-ltdl-*
yum -install libtool-Itdl*
cd php-5.3.22/
./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/appache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
make
make install
cp /tmp/mysource/yianzhuang/php-5.3.22/php.ini-development /usr/local/php/etc/php.ini
七、修改Apache 支持PHP扩展库
1、修改http.conf
vi /usr/local/appache2/etc/httpd.conf
AddType application/x-httpd-php .php .phps
2、mv phpMyAdmin.zip /usr/local/appache2/htdocs/
3、 cd /usr/local/appache2/htdocs/
mv index.html test.php bak/
4、unzip phpMyAdmin.zip
5、mv phpMyAdmin phpmyadmin
6、rm -rf phpMyAdmin.zip
修改启动首页:
vi /usr/local/appache2/etc/httpd.conf
找到
修改为:
DirectoryIndex index.php index.html
八、编译安装PDO——mysql模块
1、cd PDO_MYSQL-1.0.2/
2、PDO_MYSQL-1.0.2]# /usr/local/php/bin/phpize
这个结果还是需要的
3、vi /usr/local/php/etc/php.ini
找到 extension_dir
添加:extension_dir = "/usr/local/php//lib/php/extensions/no-debug-non-zts-20090626/"
extension=pdo_mysql.so
九、安装phpmyadmin进行mysql管理
unzip phpMyAdmin-4.0.10.20-all-languages.rar
mv phpMyAdmin-4.0.10.20-all-languages /usr/local/appache2/htdocs/phpmyadmin
cd /usr/local/appache2/htdocs/phpmyadmin/libraries
vi config.default.php
找到:
$cfg['Servers'][$i]['host'] = '192.168.153.2';#修改为mysql安装服务器地址
$cfg['Servers'][$i]['port'] = '13306'; #修改为修改后的mysql端口进行修改,保存
在浏览器输入:http://192.168.153.2:10080/phpmyadmin
可以登录密码访问