LAMP(Linux+Apache+MySql+PHP)架构师一套强大的网站解决方案。LAMP是多个开源项目的首字母缩写,LAMP网站架构主要应用于动态网站的Wed架构,这种Web框架具备同用,跨平台,高性能,稳定性等特性,是目前企业部署网站的首选平台。同时,咱们也须要看到Nginx在国内的应用愈来愈成熟,相对于Apache而言,Nginx对于静态文件的响应能力要远远高于Apache服务器,因此近几年也兴起了LNMP的架构。但对于负载PHP的网站而言,Apache仍然是目前的首选产品。
php
首先准备实验环境:
html
注释:我是用RPM软件包来作的,你们也能够用源码包安装。mysql
虚拟机一台web
redhat5.9_64位系统一个 sql
本机IP:192.168.0.2数据库
[root@localhost ~]# ifconfig eth0 192.168.0.2vim
设置IP的目的是为了下面实验访问的时候方便。服务器
如今咱们来安装相关的软件:架构
[root@localhost ~]# yum -y install php app
[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来作,这样的话,咱们就可更好的验证了。这样也是锻炼咱们作综合实验了。