LAMP环境--两层架构的安装和配置

wKiom1Qf2YDhj5TtAADq4OKvCLE580.jpg

环境说明

    路由器上设置nat转换

    Lamp环境所使用的系统为 Red Hat Enterprise Linux 5.8 x86_64 内核版本 2.6.18-308.el5

    Lamp的向外提供的主机名为 www.fangyu.com

    因为是测试平台没有使用DNS,使用本地的/etc/hosts文件

所需软件包

    httpd-2.2.29.tar.bz2

    mysql-5.5.28-linux2.6-x86_64.tar.gz

    Discuz_X2.5_SC_GBK.zip   # 安装一个论坛开测试安装是否成功

    php-5.3.29.tar.bz2

安装httpd服务器

     [root@station1 ~]# tar xf httpd-2.2.29.tar.bz2 

    [root@station1 ~]# cd httpd-2.2.29

    [root@station1 httpd-2.2.29]# ./configure --prefix=/usr/local/apache \

    > --sysconfdir=/etc/httpd \

    > --enable-so \

    > --enable-rewirte \

    > --enable-ssl \

     > --enable-modules=most \

    > --enable-mods-shared=most \

    > --with-mpm=prefork

     [root@station1 httpd-2.2.29]# make && make install

    [root@station1 httpd-2.2.29]# 

    [root@station1 httpd-2.2.29]# vi /etc/profile.d/httpd.sh

    [root@station1 httpd-2.2.29]# . /etc/profile.d/httpd.sh

    [root@station1 httpd-2.2.29]# 

    [root@station1 httpd-2.2.29]# apachectl start

    [root@station1 httpd-2.2.29]# netstat -tnlp | grep :80

    tcp        0      0 :::80                       :::*                        LISTEN      1031/httpd          

    [root@station1 httpd-2.2.29]# 


安装php

    [root@station1 ~]# tar xf php-5.3.29.tar.bz2 

    [root@station1 ~]# cd php-5.3.29

    [root@station1 php-5.3.29]# ./configure --prefix=/usr/local/php \

    > --with-openssl \

    > --enable-mbstring \

    > --with-freetype-dir \

    > --with-jpeg-dir \

    > --with-png-dir \

    > --with-zlib \

    > --with-libxml-dir=/usr \

    > --enable-xml \

    > --enable-sockets \

    > --with-apxs2=/usr/local/apache/bin/apxs \

    > --with-mcrypt \

    > --with-config-file-path=/etc \

    > --with-config-file-scan-dir=/etc/php.d \

    > --with-bz2 \

    > --with-mysql=mysqlnd  \

    > --with-mysqli=mysqlnd \

    > --with-pdo-mysql=mysqlnd

[root@station1 php-5.3.29]# make && make install

[root@station1 php-5.3.29]# 

[root@station1 php-5.3.29]# cp php.ini-production /etc/php.ini

[root@station1 php-5.3.29]# 





# httpd和php结合

# 修改httpd.conf配置文件,加入一行文本

[root@station1 httpd]# vi httpd.conf

    AddType application/x-httpd-php .php

    AddType application/x-httpd-php-source .phps

    < IfModule dir_module >

        DirectoryIndex index.php index.html

    < /IfModule >

[root@station1 httpd]# 

[root@station1 php-5.3.29]# apachectl stop

[root@station1 php-5.3.29]# apachectl start

[root@station1 php-5.3.29]# 

3.7 另一台主机安装Mysql数据库


[root@station2 ~]# tar xf mysql-5.5.28-linux2.6-x86_64.tar.gz -C /usr/local/

[root@station2 ~]# cd /usr/local/

[root@station2 local]# ln -s mysql-5.5.28-linux2.6-x86_64 mysql

[root@station2 local]# 

[root@station2 local]# groupadd -r mysql

[root@station2 local]# useradd -r mysql -g mysql 

[root@station2 local]# 

[root@station2 local]# chown -R mysql:mysql mysql/*

[root@station2 mysql]# scripts/mysql_install_db --user=mysql

Installing MySQL system tables...

OK

Filling help tables...

OK


To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system


PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:


./bin/mysqladmin -u root password 'new-password'

./bin/mysqladmin -u root -h station2.example.com password 'new-password'


Alternatively you can run:

./bin/mysql_secure_installation


which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.


See the manual for more instructions.


You can start the MySQL daemon with:

cd . ; ./bin/mysqld_safe &


You can test the MySQL daemon with mysql-test-run.pl

cd ./mysql-test ; perl mysql-test-run.pl


Please report any problems with the ./bin/mysqlbug script!


[root@station2 mysql]# 

[root@station2 mysql]# cp support-files/my-large.cnf /etc/my.cnf

[root@station2 mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[root@station2 mysql]# 

[root@station2 ~]# vi /etc/profile.d/mysql.sh

[root@station2 ~]# . /etc/profile.d/mysql.sh

[root@station2 ~]# vi /etc/ld.so.conf.d/mysql.conf

[root@station2 ~]# ldconfig 

[root@station2 ~]#

[root@station2 ~]# ln -s /usr/local/mysql/include/ /usr/include/mysql

[root@station2 ~]# 

[root@station2 ~]# /etc/init.d/mysqld start

Starting MySQL....................                         [  OK  ]

[root@station2 ~]# 

[root@station2 ~]# mysql


# 创建远程连接用户

mysql> grant all on *.* to 'root'@'%' identified by 'fangyu421'; 

Query OK, 0 rows affected (2.85 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.73 sec)


mysql> \q

[root@station2 ~]#

# 安装论坛

# 整体测试

wKioL1QgANOBSco7AAKStn4y2zY042.jpg

你可能感兴趣的:(lamp,两层架构)