rhel6搭建lamp

安装包: httpd-2.2.15.tar.gz

mysql-5.5.20.tar.gz

php-5.5.20.tar.gz

一.httpd安装:

安装依赖包

yum install -y gcc gcc-c++ make ncurses-devel bison openssl-devel zlib-devel cmake

1.tar zxvf httpd-2.2.15.tar.gz

2. cd httpd-2.2.15

3 . .configure --prefix=/usr/local/mysql/ --sysconfdir=/etc --localstatedir=/var/lib/mysql/

将mysql安装到/usr/local/mysql 指定主配置文件目录到/etc目录 指定工作目录是/var/lib/mysql

4.make & make install

二.mysql安装:


1.tar zxf mysql-5.5.20.tar.gz

2.cd mysql-5.5.20

3.编译mysql

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=yes

make & make install

如果要重新编译,需要清除掉旧的对象文件和缓存信息

make clean

rm -f CmakeCache.txt

4.useradd -M -s /sbin/nologin mysql

5.cd /usr/local/mysql

cp support-files/my-large.cnf /etc/my.cnf    #根据你的主机内存复制 mysql 配置文件

chown -R mysql.mysql .
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data
chown -R root .

chown -R mysql data
cp support-files/mysql.server /etc/init.d/mysqld
6.设置开机启动

service mysqld start
chkconfig mysqld on

7.配置环境变量

vi ~/.bash_profile
PATH=$PATH:/usr/local/mysql/bin
source ~/.bash_profile
#使之生效
mysql_secure_installation #按提示完成 mysql 安全设置,生产环境推荐使用
ln -s /usr/local/mysql/lib /usr/local/mysql/lib64 #不然 php 编译的时候找不到 mysql 的库文件
8. ./mysqladmin -u root -p password centrald
给mysql设密码,初始密码为空


三.php编译

1.cd php-5.5.20

./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --enable-sockets --with-mysqli --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql/ --with-jpeg-dir=/usr/lib64/ --with-curl --enable-mbstring=all --with-config-file-path=/usr/local/php5/etc/ --enable-soap --with-gd --with-gettext

make & make install

2.

cd /usr/local/src/php-5.5.20

cp php.ini-development /usr/local/php5/php.ini

3.vim /usr/local/apache/conf/httpd.conf

修改apache的配置文件

在有AddType附近添加AddType application/x-httpd-php .php

4.重启apache程序

cd /usr/local/apache/bin/

./apachectl restart

5.测试支持PHP

cd /usr/local/apache/htdocs/

vi test.php

添加   <? php               phpinfo( );                  ?>

四.虚拟主机的设置

1.vim conf/httpd.conf   修改httpd.conf配置文件

(1)<Directory />  

    Options FollowSymLinks  

    AllowOverride None  

    Order deny,allow // 

    Deny from all  

</Directory>

将之修改为

<Directory />  

    Options Indexes FollowSymLinks  

    AllowOverride None  

</Directory></span>  

(2)Include /etc/httpd24/extra/httpd-vhosts.conf   打开虚拟主机功能,去掉前面的#注释

2. vim conf/extra/httpd-vhosts.conf

(1)搭建基于端口的虚拟主机

Listen 12345   新加一个12345端口

<VirtualHost 192.168.1.11:80>
    DocumentRoot "/usr/local/apache/htdocs"
    ServerName pal.example.com
</VirtualHost>
<VirtualHost 192.168.1.11:12345>
    DocumentRoot "/openfire"
    ServerName openfire.example.com
</VirtualHost>
(2)搭建基于域名的虚拟主机

#在httpd2.2版本定义基于域名的虚拟主机时,需要加入如下,在2.4则不再需要,直接定义即可

<VirtualHost 192.168.1.11:80>


<VirtualHost 192.168.1.11:80>
    DocumentRoot "/usr/local/apache/htdocs"
    ServerName pal.example.com
</VirtualHost>
<VirtualHost 192.168.1.11:80>
    DocumentRoot "/openfire"
    ServerName openfire.example.com
</VirtualHost>














你可能感兴趣的:(源码,mysql,PHP,lamp,httpd,RHEL6)