Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。
随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。
目前LAMP架构是大多数中小企业最青睐的PHP架构选择,也是众多Linux SA喜欢选择的一套架构。接下来介绍下两种安装LAMP的两种方式。
一、yum安装
1、安装lamp,并启动相关服务
[root@jacken ~]#yum -y install httpd httpd-devel mysql mysql-server mysql-libs php php-devel 这一条命令LAMP环境即可安装成功,只需要重启apache、mysql服务即可 [root@jacken ~]# /etc/init.d/mysqld start Initializing MySQL database: 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 jacken 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 /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ] [root@jacken ~]# /etc/init.d/httpd start Starting httpd: [ OK ] [root@jacken ~]# chkconfig mysqld on [root@jacken ~]# chkconfig httpd on [root@jacken ~]#
2、验证安装是否成功
[root@jacken ~]# cd /var/www/html/ [root@jacken html]# ls [root@jacken html]# vim phpinfo.php [root@jacken html]# cat phpinfo.php <?php phpinfo(); ?>
3、安装Discuz
[root@jacken ~]# ls Discuz_X3.2_SC_UTF8.zip [root@jacken ~]# unzip -q -d /var/www/html/ Discuz_X3.2_SC_UTF8.zip [root@jacken ~]# ls /var/www/html/ phpinfo.php readme upload utility [root@jacken ~]# cd /var/www/html/ [root@jacken html]# mv upload/* ./;rm -rf readme utility
点同意
设置相关目录权限
[root@jacken html]# pwd /var/www/html [root@jacken html]# chmod -R o+w config/ data/ uc_*
此时目录已可写,但是出现mysql链接不支持
[root@jacken upload]# yum -y install php-mysql [root@jacken upload]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
下一步
创建discuz数据库,设置root密码
mysql> create database discuz; Query OK, 1 row affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set password=password(‘hello‘) where user=‘root‘; Query OK, 0 rows affected (0.00 sec) Rows matched: 3 Changed: 0 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> exit; Bye [root@jacken]#
至此,LAMP基本搭建完毕。
进入论坛管理中心,会提示删除安装页
[root@jacken ~]# cd /var/www/html/upload/install/ [root@jacken install]# mv index.php index.php.bak [root@jacken install]#
LAMP安装完毕。
二、源码安装
下载相应的软件包
Apache http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.27.tar.gz
Mysql http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.63.tar.gz
Php http://mirrors.sohu.com/php/php-5.3.28.tar.bz2
Discuz http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
[root@jacken ~]# cd /softwares/ [root@jacken softwares]# ls Discuz_X3.2_SC_UTF8.zip httpd-2.2.27.tar.gz mysql-5.1.63.tar.gz php-5.3.28.tar.bz2 [root@jacken softwares]#
安装环境包
[root@jacken softwares]# yum -y install apr-devel apr-util-devel [root@jacken ~]# yum -y install gcc
1、安装Apache
[root@jacken ~]# cd /softwares/ [root@jacken softwares]# ls Discuz_X3.2_SC_UTF8.zip httpd-2.2.27.tar.gz mysql-5.1.63.tar.gz php-5.3.28.tar.bz2 [root@jacken softwares]# tar -zxf httpd-2.2.27.tar.gz [root@jacken softwares]# cd httpd-2.2.27 [root@jacken httpd-2.2.27]#./configure --prefix=/usr/local/apache --enable-so --enable-rewrite&&make&&make install
2、安装Mysql
[root@jacken ~]# cd /softwares/ [root@jacken softwares]# ls Discuz_X3.2_SC_UTF8.zip httpd-2.2.27 httpd-2.2.27.tar.gz mysql-5.1.63.tar.gz php-5.3.28.tar.bz2 [root@jacken softwares]# tar -zxf mysql-5.1.63.tar.gz [root@jacken softwares]# cd mysql-5.1.63 [root@jacken mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install
报错
[root@jacken mysql-5.1.63]# yum –y install ncurses-devel [root@jacken mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install
报错
[root@jacken mysql-5.1.63]# yum -y install gcc-c++ [root@jacken mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install [root@jacken mysql-5.1.63]# echo $? 0
配置Mysql服务为系统服务
[root@jacken ~]# cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf [root@jacken ~]# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld [root@jacken ~]# chkconfig --add mysqld [root@jacken ~]# chkconfig --level 345 mysqld on [root@jacken ~]# cd /usr/local/mysql/ [root@jacken mysql]# useradd mysql [root@jacken mysql]# chown -R mysql.mysql /usr/local/mysql [root@jacken mysql]# /usr/local/mysql/bin/mysql_install_db --user=mysql [root@jacken mysql]# chown -R mysql var [root@jacken mysql]# ll -d var drwx------. 4 mysql root 4096 Mar 31 09:54 var [root@jacken mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql& [1] 16857 [root@jacken mysql]# 150331 09:56:02 mysqld_safe Logging to ‘/usr/local/mysql/var/jacken.err‘. 150331 09:56:02 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var [root@jacken mysql]#
3、安装Php
[root@jacken ~]# cd /softwares/ [root@jacken softwares]# ls Discuz_X3.2_SC_UTF8.zip httpd-2.2.27 httpd-2.2.27.tar.gz mysql-5.1.63 mysql-5.1.63.tar.gz php-5.3.28.tar.bz2 [root@jacken softwares]# tar -jxf php-5.3.28.tar.bz2 [root@jacken softwares]# cd php-5.3.28 [root@jacken php-5.3.28]# ./configure > --prefix=/usr/local/php5 > --with-config-file-path=/usr/local/php/etc > --with-apxs2=/usr/local/apache/bin/apxs > --with-mysql=/usr/local/mysql/
报错
[root@jacken php-5.3.28]# yum -y install libxml2 libxml2-devel [root@jacken php-5.3.28]# ./configure > --prefix=/usr/local/php5 > --with-config-file-path=/usr/local/php/etc > --with-apxs2=/usr/local/apache/bin/apxs > --with-mysql=/usr/local/mysql/
[root@jacken php-5.3.28]#make && make install [root@jacken php-5.3.28]# echo $? 0 [root@jacken php-5.3.28]#
安装成功
4、整合Apache+Php
整合apache+php环境,修改httpd.conf配置文件,然后加入如下语句:
LoadModule php5_module modules/libphp5.so (默认可能已存在)
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html (把index.php加入index.html之前)
然后在/usr/local/apache/htdocs目录下创建index.php测试页面,
[root@jacken htdocs]# ls index.html index.php [root@jacken htdocs]# cat index.php <?php phpinfo(); ?> [root@jacken htdocs]# pwd /usr/local/apache/htdocs [root@jacken htdocs]#
5、安装discuz论坛
[root@jacken ~]# cd /softwares/ [root@jacken softwares]# ls Discuz_X3.2_SC_UTF8.zip httpd-2.2.27.tar.gz mysql-5.1.63.tar.gz php-5.3.28.tar.bz2 httpd-2.2.27 mysql-5.1.63 php-5.3.28 [root@jacken softwares]# [root@jacken softwares]# unzip Discuz_X3.2_SC_UTF8.zip -d /usr/local/apache/htdocs/ [root@jacken softwares]# cd /usr/local/apache/htdocs/ [root@jacken htdocs]# ls index.html index.php readme upload utility [root@jacken htdocs]# mv upload/* . mv: overwrite `./index.php‘? y [root@jacken htdocs]# ls admin.php config data home.php member.php readme sta api connect.php favicon.ico index.html misc.php robots.txt tem api.php cp.php forum.php index.php plugin.php search.php uc_ archiver crossdomain.xml group.php install portal.php source uc_ [root@jacken htdocs]# chmod -R o+w data/ config/ uc_server/ uc_client/ [root@jacken htdocs]#
然后访问IP安装discuz论坛,如下图,选择“我同意”
进入如下界面,数据库安装,如果不存在则需要新建数据库并授权。
数据库创建及授权命令如下:
点击下一步
安装完成,点击访问
管理员登录
自此LAMP环境整合并搭建成功,通过IP直接访问即可
本文出自 “一步步踏入Linux世界” 博客,转载请与作者联系!
原文地址:http://linuxnote.blog.51cto.com/9876511/1631251