santaclaus 发表于 2015-8-20 12:08:06

CentOS LAMP搭建

  一、安装MySQL
# useradd mysql -s /sbin/nologin
#tar zxvf mysql-5.0.90.tar.gz
#cd mysql-5.0.90
#./configure --prefix=/usr/local/mysql localstatedir=/usr/local/mysql/date --enable-local-infile --with-charset-gbk --with-extra-charsets=all --with-low-memory --with-mysqld-user=mysql --enable-thread-safe-client
# make && make install      //编译+安装
# cp support-files/my-large.cnf /etc/my.cnf
# /usr/local/mysql/bin/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql    //初始化MySQL
# chown -R root /usr/local/mysql
# chown -R mysql /usr/local/mysql/date
# chgrp -R mysql /usr/local/mysql
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
#/usr/local/mysql/bin/mysqladmin -uroot password 123456 //设置MySQL的管理员密码
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
安装mysql-devel:
#rpm -ivh MySQL-devel-5.0.90-1.i386.rpm
安装 zlib libpng jpeg freetype fontconfig gd
yum install zlib libpng jpegsrc jpegsrc-devel freetype freetype-devel fontconfig fontconfig-devel gd-devel
二、安装Apache
#tar jxvf httpd-2.2.13.tar.bz2
#cd httpd-2.2.13
#./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl --with-ssl=/usr/bin/openssl --with-zlib --enable-mods-shared=all --enable-track-vars --with-mysql=/usr/local/mysql
#make && make install
#/usr/local/apache/bin/apachectl start   //启动Apache
#echo "/usr/local/apache/bin/apachectl start" >>/etc/rc.local   //加入开机启动
三、安装PHP
#tar jxvf php-5.2.13.tar.bz2
#cd php-5.2.13
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-fastcgi --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir --enable-sockets --with-pdo-mysql=/usr/local/mysql
#make && make install
# ln -s /usr/local/php/bin/* /usr/local/bin/
# cp php.ini-dist /usr/local/php/php.ini
建立php测试页面:
vi /usr/local/apache/htdocs/index.php
<?php
phpinfo();
?>
整合apache和php
#vi /usr/local/apache/conf/httpd.conf
①    确认PHP模块是否添加进来,只要我们在前面安装Apache时允许Apache动态加载模块次模块就会自动添加进来,配置文件中没有此项请手工添加,约在53行
LoadModule php5_module      modules/libphp5.so
②    添加对 PHP文件的支持,在310行下面添加如下内容(AddType application/x-gzip .gz .tgz下面)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
③    修改默认主页167行
DirectoryIndex index.php index.html
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start

访问phpinfo测试页面进行测试!
页: [1]
查看完整版本: CentOS LAMP搭建