LAMP(Linux+Apache+MySql+PHP)架构师一套强大的网站解决方案。LAMP是多个开源项目的首字母缩写,LAMP网站架构主要应用于动态网站的Wed架构,这种Web框架具有同用,跨平台,高性能,稳定性等特性,是目前企业部署网站的首选平台。同时,我们也需要看到Nginx在国内的应用越来越成熟,相对于Apache而言,Nginx对于静态文件的响应能力要远远高于Apache服务器,所以近几年也兴起了LNMP的架构。但对于负载PHP的网站而言,Apache仍然是目前的首选产品。
首先准备实验环境:
注释:我是用RPM软件包来做的,大家也可以用源码包安装。
虚拟机一台
redhat5.9_64位系统一个
本机IP:192.168.0.2
[root@localhost ~]# ifconfig eth0 192.168.0.2
设置IP的目的是为了下面实验访问的时候方便。
现在我们来安装相关的软件:
[root@localhost ~]# yum -y install php
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# yum -y install mysql
[root@localhost ~]# yum -y install mysql-server
[root@localhost ~]# yum -y install php-mysql
修改HTTP配置文件在行添加“ index.php”:
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.php index.html index.html.var
在修改配置文件php添加这行:
[root@localhost ~]# vim /etc/httpd/conf.d/php.conf
AddType application/x-httpd-php .php
写一个php测试文件:
[root@localhost ~]# vim /var/www/html/index.php
<?php
phpinfo();
?>
然后开开网页输入本机IP地址看看是否支持PHP,出现下面这个就证明支持PHP。
[root@localhost ~]# firefox 192.168.0.2
然后删除测试文件。
[root@localhost ~]# rm -rf /var/www/html/index.php
下载一个软件包 Discuz_X3.0_SC_UTF8 然后解压。记住这个软件包版本不能太高,不让然会有问题的 。这个事下载地址:
“简体 UTF8:http://download.comsenz.com/DiscuzX/3.0/Discuz_X3.0_SC_UTF8.zip”
[root@localhost Desktop]# unzip Discuz_X3.0_SC_UTF8.zip
[root@localhost Desktop]# ll
总计 10372
-rwxrw-rw- 1 root root 10575658 2013-12-19 Discuz_X3.0_SC_UTF8.zip
drwxr-xr-x 2 root root 4096 2013-08-02 readme
drwxr-xr-x 12 root root 4096 2013-08-02 upload
drwxr-xr-x 4 root root 4096 2013-08-02 utility
[root@localhost Desktop]# cd upload/
[root@localhost upload]# cp -rf * /var/www/html/
[root@localhost upload]# cd /var/www/html/
[root@localhost html]# chmod 777 -R uc_client/ uc_server/ config/ data/
[root@localhost html]# /etc/init.d/mysqld restart
停止 mysqld: [确定]
初始化 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:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/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 /usr ; /usr/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 /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[确定]
启动 mysqld: [确定]
[root@localhost html]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database bbs;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on bbs.* to bbsuser@'localhost' identified by '111' ;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
如果出现这个错误的时候“mysql_connect() 不支持 请检查 mysql 模块是否正确加载”
我们要加三行才可以:
[root@localhost html]# vim /etc/php.ini
extension=msql.so
extension=mysqli.so
extension=pdo_mysql.so
现在重启所有服务并且加入开机启动:
[root@localhost ~]# /etc/init.d/httpd restart
[root@localhost ~]# /etc/init.d/mysqld restart
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig mysqld on
现在就可以再图形里面来做了:
注释:下面图例我们要设一些参数:
数据库名 : bbs
数据库用户名: bbsuser
数据库密码 : 111
设置admin论坛管理员密码:
管理员账号 : admin
管理员密码 : 111
重复密码 : 111
出现这个是因为没有联网,大家看到这个不要以为是错了,出现这个是正常的。
现在我们在测试一下我们做的论坛,我们在网页里输入本机的IP地址。
实验到此结束,如果想在多台系统上来实验的话,我们可以加上DNS来做,这样的话,我们就可更好的验证了。这样也是锻炼我们做综合实验了。
本文出自 “Dragon” 博客,转载请与作者联系!