标签:lamp 搭建
环境:linux、httpd-2.2、mysql-5.5、php-5.3
1、源码包编译安装需要的包:
[root@VM_158_68_centoshttpd-2.2.17]# yum -y install gcc gcc-c++ make zlib-devel
2、检查系统有没有装httpd rpm包:
[root@VM_158_68_centos ~]# rpm -qa|grep httpd
[root@VM_158_68_centos ~]#
3、源码编译安装apache:
....下载httpd源码包:
....解压、配置、编译、安装:
[root@VM_158_68_centos~]# tar xf httpd-2.2.17.tar.gz -C /usr/src
[root@VM_158_68_centos ~]# cd /usr/src/httpd-2.2.17/
[root@VM_158_68_centoshttpd-2.2.17]# ./configure --prefix=/usr/local/httpd --enable-cgi --enable-so--enable-charset-lite --enable-deflate--enable-expires --enable-rewrite
[root@VM_158_68_centos httpd-2.2.17]# make && make install
4、查看有没有安装成功:
[root@VM_158_68_centos httpd-2.2.17]# ls /usr/local/httpd/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
5、创建软连接、并查看:
[root@VM_158_68_centoshttpd-2.2.17]# ln -s /usr/local/httpd/bin/* /usr/local/bin/
[root@VM_158_68_centos httpd-2.2.17]# ll /usr/local/bin
6、建立配置文件
[root@VM_158_68_centos httpd-2.2.17]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@VM_158_68_centoshttpd-2.2.17]# chmod +x /etc/init.d/httpd
[root@VM_158_68_centos httpd-2.2.17]# sed -i -e ‘1a#chkconfig: 35 85 21‘ /etc/init.d/httpd
[root@VM_158_68_centos httpd-2.2.17]# chkconfig --add httpd
[root@VM_158_68_centos httpd-2.2.17]# chkconfig --list httpd
7、启动http服务
[root@VM_158_68_centoshttpd-2.2.17]# service httpd start
8、查看是否开启80端口
[root@VM_158_68_centoshttpd-2.2.17]# netstat -atnpl|grep httpd
9、编译安装cmake
[root@VM_158_68_centos~]# tar xf cmake-2.8.6.tar.gz -C /usr/src
[root@VM_158_68_centos~]# cd /usr/src/cmake-2.8.6/
[root@VM_158_68_centos~]# ./configure && make && make install
10、编译安装MySQL
.......先安装ncurses-devel 库:[root@VM_158_68_centos~]# yum -y install ncurses-devel
[root@VM_158_68_centos ~]#useradd -M -s /sbin/nologin mysql
[root@VM_158_68_centos ~]# tar xf mysql-5.5.22.tar.gz -C /usr/src/
[root@VM_158_68_centos ~]#cd /usr/src/mysql-5.5.22/
[root@VM_158_68_centos mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc
[root@VM_158_68_centos mysql-5.5.22]#make && make install
......更改属主属组:
[root@VM_158_68_centosmysql-5.5.22]# chown -R mysql:mysql /usr/local/mysql/
.....创建配置文件:
[root@VM_158_68_centosmysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf
.....初始化数据库:
[root@VM_158_68_centosmysql-5.5.22]# /usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/ \
> --datadir=/usr/local/mysql/data --user=mysql
[root@VM_158_68_centosmysql-5.5.22]# ls /usr/local/mysql/data/
[root@VM_158_68_centosmysql-5.5.22]# ln -s /usr/local/mysql/bin/* /usr/local/bin
.....添加为系统:
[root@VM_158_68_centos mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld
[root@VM_158_68_centosmysql-5.5.22]# chmod +x /etc/init.d/mysqld
[root@VM_158_68_centosmysql-5.5.22]# chkconfig --add mysqld
[root@VM_158_68_centosmysql-5.5.22]# chkconfig --list mysqld
.....启动数据库:
[root@VM_158_68_centosmysql-5.5.22]# /etc/init.d/mysqld start
[root@VM_158_68_centosmysql-5.5.22]# netstat -atnpl|grep mysqld
.....登录数据库:
[root@VM_158_68_centosmysql-5.5.22]# mysql -u root
....创建数据库账户和密码:
[root@VM_158_68_centosmysql-5.5.22]# mysqladmin -u root password ‘123123‘
.....验证登录:
[root@VM_158_68_centosmysql-5.5.22]# mysql -uroot -p‘123123‘
11、编译安装php(mcrypt加密、支持gif、png、gd、jpeg类型文件、):
[root@VM_158_68_centos libmcrypt-2.5.8]# yum -y install libxml2-devel
[root@VM_158_68_centos ~]# tar xflibmcrypt-2.5.8.tar.gz -C /usr/src
[root@VM_158_68_centos ~]# cd/usr/src/libmcrypt-2.5.8
[root@VM_158_68_centos libmcrypt-2.5.8]#./configure && make && make install
[root@VM_158_68_centoslibmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt* /usr/lib
......mhash安装:
[root@VM_158_68_centos ~]# tar xfmhash-0.9.9.9.tar.gz -C /usr/src
[root@VM_158_68_centos ~]# cd/usr/src/mhash-0.9.9.9/
[root@VM_158_68_centos mhash-0.9.9.9]#./configure && make &&make install
[root@VM_158_68_centos mhash-0.9.9.9]#ln -s /usr/local/lib/libmhash.* /usr/lib
Mcrypt安装:
[root@VM_158_68_centos ~]# tar xfmcrypt-2.6.8.tar.gz -C /usr/src/
[root@VM_158_68_centos ~]# cd /usr/src/mcrypt-2.6.8/
[root@VM_158_68_centos libmcrypt-2.5.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
[root@VM_158_68_centos mcrypt-2.6.8]#./configure && make && make install
[root@VM_158_68_centos ~]# tar xf php-5.3.28.tar.gz -C /usr/src
[root@VM_158_68_centos ~]# cd /usr/src/php-5.3.28/
[root@VM_158_68_centos php-5.3.28]# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/httpd/bin/apxs --with-mcrypt --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring --with-gd --with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/png/
[root@VM_158_68_centos php-5.3.28]#make && make install
[root@VM_158_68_centos php-5.3.28]# cpphp.ini-development /usr/local/php5/php.ini
[root@VM_158_68_centos php-5.3.28]# awk‘/^short_open_tag/{print NR,$0}‘ /usr/local/php5/php.ini
[root@VM_158_68_centos php-5.3.28]# sed-i ‘226 s/Off/On/‘ /usr/local/php5/php.ini
[root@VM_158_68_centos php-5.3.28]# awk‘ /default_charset/{print NR,$0}‘ /usr/local/php5/php.ini
[root@VM_158_68_centos php-5.3.28]# sed -i -e ‘784 s/;// ; s/iso-8859-1/utf-8/‘ /usr/local/php5/php.ini
php优化模块:
[root@VM_158_68_centos ~]# tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz –C /usr/src
[root@VM_158_68_centos~]#cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/
[root@VM_158_68_centos php-5.3.x]# cpZendGuardLoader.so /usr/local/php5/lib/php/
[root@VM_158_68_centos php-5.3.x]# echo -e ‘zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1‘ >> /usr/local/php5/php.ini
修改Apache配置文件让支持php。
[root@VM_158_68_centos ~]# awk ‘/LoadModule php5_module/{print NR,$0}‘ /usr/local/httpd/conf/httpd.conf
[root@VM_158_68_centos ~]# sed -i ‘53aAddType application/x-httpd-php .php‘ /usr/local/httpd/conf/httpd.conf
[root@VM_158_68_centos ~]# awk ‘/DirectoryIndex/{print NR,$0}‘ /usr/local/httpd/conf/httpd.conf
[root@VM_158_68_centos ~]# sed -i ‘168s/$/ index.php/‘ /usr/local/httpd/conf/httpd.conf
[root@VM_158_68_centos ~]# httpd –t
[root@VM_158_68_centos ~]#/etc/init.d/httpd restart
LAMP架构搭建完成:
Php源码包下载链接:
安装png、jpeg报错的解决方法:
http://ixdba.blog.51cto.com/2895551/526435/
安装gd报错解决方法(打开连接最下面是)
http://blog.csdn.net/avilifans/article/details/16821017
本文出自 “13271352” 博客,请务必保留此出处http://13281352.blog.51cto.com/13271352/1967292
标签:lamp 搭建
原文地址:http://13281352.blog.51cto.com/13271352/1967292