lamp环境搭建

CentOS 6.3/64位

#! /bin/bash

groupadd mysql

useradd -g mysql mysql

cd /public

tar zxvf mysql-5.0.41.tar.gz

cd /public/mysql-5.0.41

./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data/ --with-extra-charsets=all --with-plugins=innobase,myisam --with-unix-socket-path=/usr/local/mysql/sock/mysql.sock --enable-thread-safe-client --enable-assembler --enable-profiling --without-embedded-server --without-debug --without-bench

make

make install

\cp /public/mysql-5.0.41/support-files/my-medium.cnf /etc/my.cnf

/usr/local/mysql/bin/mysql_install_db --user=mysql

chown -R mysql:mysql /usr/local/mysql

\cp /public/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld

chown root.root /etc/rc.d/init.d/mysqld

chmod 755 /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig --list mysqld

chkconfig --levels 245 mysqld off

yum -y install httpd

chkconfig --level 235 httpd on

/etc/init.d/httpd restart

yum install -y php

/etc/init.d/httpd restart

yum -y install php-mysql php-common php-mbstring php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

/etc/init.d/httpd restart

环境搭建完成以后,在httpd的根目录下面写个php文件,做个简单的环境测试:

<?php
       $host = '192.168.10.22';
       $user = 'smvp';
       $passwd = 'smvp';
       $conn = mysql_connect($host,$user,$passwd);
       if($conn){
               echo 'mysql connect is ok!!!';
       }else{
               echo 'Can\'t to connect mysql server';
       }

?>

PHP+zend php加速配置)

wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz

Linux下为PHP5.3.8配置Zend Guard Loader(图文)(原创)

PHP5.3开始如果要支持ZendGuard加密的PHP代码,必须安装Zend Guard Loader,老的zend optimizer将不被支持。

1.Zend.com下载最新的Linux操作系统系下的Zend Guard Loader:本文用的是x86-64位的,下载的文件为:ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz

2.cp /public/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/lib64/php/modules/

3.上传至Linux服务器并解压缩,注意阅读生成目录下的README文件。全文如下(添加必要的注释).

/etc/php.ini/  内容如下:

zend_extension=/usr/lib64/php/modules/ZendGuardLoader.so

4.重启httpd服务:service httpd restart

5.http://IP/test.php(内容为<?php phpinfo(); ?>),看到如下内容及证明安装成功了

有   with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies 这个行内容,就说明安装成功了

Apache  配置vhost

配置apache  http.conf文件

默认位置  /etc/http/conf/http.conf

304340行处

   AllowOverride None

改为

   AllowOverride all

404行处的 索引添加一个

404 DirectoryIndexindex.php index.html index.html.var

在最下方添加状态信息

<Location /server-status>

    SetHandler server-status

    Order deny,allow

    Deny from all

    Allow from all

</Location>

ExtendedStatus On

在最下方添加

Include conf/vhost/*.conf

指定虚拟目录的位置

这样在多虚拟机的情况下,方便管理

编辑

  vim /etc/httpd/conf/vhost/test.conf

<VirtualHost *:80>

   ServerAdmin [email protected]

   DocumentRoot /var/www/html/

   ServerName www.test.com

   CustomLog "|/usr/sbin/rotatelogs -l /var/log/httpd/test.access_%Y%m%d.log 10 " combined

   ErrorLog "|/usr/sbin/rotatelogs -l /var/log/httpd/test.error_%Y%m%d.log 10 "

</VirtualHost>


你可能感兴趣的:(LAMP环境搭建)