搭建LAMP的两种方式

Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。

随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。

目前LAMP架构是大多数中小企业最青睐的PHP架构选择,也是众多Linux SA喜欢选择的一套架构。接下来介绍下两种安装LAMP的两种方式。

一、yum安装

1、安装lamp,并启动相关服务

[[email protected] ~]#yum -y install httpd httpd-devel  mysql mysql-server mysql-libs php php-devel 
这一条命令LAMP环境即可安装成功,只需要重启apache、mysql服务即可
[[email protected] ~]# /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  ]
[[email protected] ~]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[[email protected] ~]# chkconfig mysqld on
[[email protected] ~]# chkconfig httpd on
[[email protected] ~]#

2、验证安装是否成功

测试是否支持php环境

[[email protected] ~]# cd /var/www/html/
[[email protected] html]# ls
[[email protected] html]# vim phpinfo.php
[[email protected] html]# cat phpinfo.php
<?php
phpinfo();
?>

3、安装Discuz

[[email protected] ~]# ls
Discuz_X3.2_SC_UTF8.zip
[[email protected] ~]# unzip -q -d /var/www/html/ Discuz_X3.2_SC_UTF8.zip 
[[email protected] ~]# ls /var/www/html/
phpinfo.php  readme  upload  utility
[[email protected] ~]# cd /var/www/html/
[[email protected] html]# mv upload/* ./;rm -rf readme utility

点同意

设置相关目录权限

[[email protected] html]# pwd
/var/www/html
[[email protected] html]# chmod -R o+w config/ data/ uc_*

此时目录已可写,但是出现mysql链接不支持

[[email protected] upload]# yum -y install php-mysql
[[email protected] 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
[[email protected]]#

至此,LAMP基本搭建完毕。

进入论坛管理中心,会提示删除安装页

[[email protected]ken ~]# cd /var/www/html/upload/install/
[[email protected] install]# mv index.php index.php.bak
[[email protected] 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

[[email protected] ~]# cd /softwares/
[[email protected] 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
[[email protected] softwares]#

安装环境包

[[email protected] softwares]# yum -y install apr-devel apr-util-devel
[[email protected] ~]# yum -y install gcc

1、安装Apache

[[email protected] ~]# cd /softwares/
[[email protected] 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
[[email protected] softwares]# tar -zxf httpd-2.2.27.tar.gz 
[[email protected] softwares]# cd httpd-2.2.27
[[email protected] httpd-2.2.27]#./configure --prefix=/usr/local/apache --enable-so --enable-rewrite&&make&&make install

2、安装Mysql

[[email protected] ~]# cd /softwares/
[[email protected] 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
[[email protected] softwares]# tar -zxf mysql-5.1.63.tar.gz 
[[email protected] softwares]# cd mysql-5.1.63
[[email protected] mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install

报错

[[email protected] mysql-5.1.63]# yum –y  install ncurses-devel
[[email protected] mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install

报错

[[email protected] mysql-5.1.63]# yum -y install gcc-c++
[[email protected] mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install
[[email protected] mysql-5.1.63]# echo $?
0

配置Mysql服务为系统服务

[[email protected] ~]# cp /usr/local/mysql/share/mysql/my-medium.cnf  /etc/my.cnf 
[[email protected] ~]# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
[[email protected] ~]# chkconfig --add mysqld
[[email protected] ~]# chkconfig --level 345 mysqld on
[[email protected] ~]# cd /usr/local/mysql/
[[email protected] mysql]# useradd mysql
[[email protected] mysql]# chown -R mysql.mysql /usr/local/mysql
[[email protected] mysql]# /usr/local/mysql/bin/mysql_install_db --user=mysql
[[email protected] mysql]# chown -R mysql var
[[email protected] mysql]# ll -d var
drwx------. 4 mysql root 4096 Mar 31 09:54 var
[[email protected] mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql&
[1] 16857
[[email protected] 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
[[email protected] mysql]#

3、安装Php

[[email protected] ~]# cd /softwares/
[[email protected] 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
[[email protected] softwares]# tar -jxf php-5.3.28.tar.bz2 
[[email protected] softwares]# cd php-5.3.28
[[email protected] 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/

报错

[[email protected] php-5.3.28]# yum -y install libxml2 libxml2-devel
[[email protected] 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/

[[email protected] php-5.3.28]#make && make install
[[email protected] php-5.3.28]# echo $?
0
[[email protected] 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测试页面,

[[email protected] htdocs]# ls
index.html  index.php
[[email protected] htdocs]# cat index.php 
<?php
phpinfo();
?>
[[email protected] htdocs]# pwd
/usr/local/apache/htdocs
[[email protected] htdocs]#

5、安装discuz论坛

[[email protected] ~]# cd /softwares/
[[email protected] 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
[[email protected] softwares]#
[[email protected] softwares]# unzip Discuz_X3.2_SC_UTF8.zip  -d /usr/local/apache/htdocs/
[[email protected] softwares]# cd /usr/local/apache/htdocs/
[[email protected] htdocs]# ls
index.html  index.php  readme  upload  utility
[[email protected] htdocs]# mv upload/* .
mv: overwrite `./index.php‘? y
[[email protected] 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_
[[email protected] htdocs]# chmod -R o+w data/ config/ uc_server/ uc_client/
[[email protected] htdocs]#

然后访问IP安装discuz论坛,如下图,选择“我同意”

进入如下界面,数据库安装,如果不存在则需要新建数据库并授权。

数据库创建及授权命令如下:

点击下一步

安装完成,点击访问

管理员登录

自此LAMP环境整合并搭建成功,通过IP直接访问即可

时间: 2024-08-27 13:54:53

搭建LAMP的两种方式的相关文章

spring学习一——基本搭建,属性注入的两种方式

今天用spring 3.2.5搭建了基本的环境,spring出的太快了,前段时间才3.2.5,今儿个一瞧已经上了4的版本了,稍后给出spring的jar下载地址,毕竟现在官网上找不到了啊. 废话少说了,spring 3.2.5已经将所有的依赖包都放在了dist的lib下面,并且都有doc包和源码包,很是方便.先导入所需的jar包:core,context,beans,expression 四个jar包,除此之外,还需导入commons-logging. 下一步,新建xml文件,建议名称为 app

OpenCV4Android开发环境搭建两种方式加上图像二值化

1.环境搭建 进行android开发所需要的环境一般为:eclipse + android sdk + ADT,而OpenCV的开发由于需要编写本地代码(C/C++),因此还需要安装以下工具:NDK,Cygwin,CDT.网上都有大量详细的安装讲解,本文只描述下其中关键步骤. 1.1 NDK的安装 (1) NDK下载后解压到固定目录即可,无需安装.本文解压到D盘根目录下,其路径为:D:\android-ndk-r8d: (2) 添加环境变量,将其安装路径添加到系统path变量中,并添加系统变量N

Golang开发环境搭建(Notepad++、LiteIDE两种方式以及martini框架使用)

本文介绍两种Golang的开发环境一种基于notepad++.另一种基于liteide. 1.下载Golang语言的pkg:http://golangtc.com/download 直接点击安装,一路next. 2.程序员必备神器notepad++开发Golang环境很简单 一次点击:插件->Plugin Manger->Show Plugin Manger,安装插件GOnpp,重启notepad++. 新建文件命名为hello.go用notepad++打开,拷贝如下代码: package m

「linux学习」之两种方式yum搭建

方式一本地yum源配置: mkdir /mnt/cdrom/ 将/mnt/cdrom/目录称为 /dev/cdrom 的挂载入口 执行挂载命令 mount /dev/cdrom  /cdrom/mnt/ # mount: /dev/sr0 写保护,将以只读方式挂载 挂载后查看目录文件: ls /mnt/cdrom 挂载成功后使用 rpm -qa | grep rpm 查看所有rpm的包,选取需要的安装 rpm -ivh /mnt/cdrom/Packages/rpm+tab键自动补齐,这里需要注

搭建pytorch神经网络的常用两种方式

'''本节说明搭建pytorch神经网络的常用两种方式 相比快速搭建法 第一种可以个性化设置网络结构''' import torch import torch.nn.functional as F #方式1 用 class 继承了一个 torch 中的神经网络结构, 然后对其进行了修改 class Net(torch.nn.Module): def __init__(self, n_feature, n_hidden, n_output): super(Net, self).__init__()

外网登陆SAP的两种方式

1.用SAP router实现从外网登录SAP服务器(方式一) 自已搭建的局域网结构如下: SAP服务器IP: 192.168.0.2, 路由器中设为DMZ区 在SAP服务器上启用SAP router,即可 SAP router的搭建非常简单: 1.找到SAP的安装目录(例如D:\usr\sap\ECC\DVEBMGS00\exe\),可以看到saprouter.exe文件 2. 用记事本建立一个名为SAPROUTTAB的文件(没有扩展名), 输入 P * * * 后保存 3.打开c:\syst

cmd窗口使用sftp命令非密钥和密钥登录SFTP服务器的两种方式

cmd窗口使用sftp命令非密钥和密钥登录SFTP服务器的两种方式 一.在Windows环境下搭建SFTP服务器可参见http://www.cnblogs.com/Kevin00/p/6341295.html 二.非密钥登录 0.Bitvise SSH Server服务器 1.Win + R 进入cmd窗口. 2.登录命令:sftp -P 28 [email protected] 说明:-P 端口参数 28是端口,默认端口是22   kevin是登录的用户名,127.0.0.1是SFTP服务器的

android/IOS常用图片上传的两种方式

android/IOS常用图片上传的两种方式: 1.上传到服务器的文件服务器(FileServer) 原理:上传到文件服务器的方式是先在服务器端搭建文件服务器,配置好路径(url),该路径是我们待会上传图片的路径,配置成功后便通过http+post的模式上传到文件服务器,同时文件服务器将返回一个图片ID,这个ID就是图片的唯一标识,并将该ID写入数据库保存,当需要下载该图片时只需要将此ID带上即可. 两个核心问题: (1)服务端:配置FileServer,并写处理响应上传图片的代码,这个值得去网

em创建的两种方式

em创建(两种方式1,图形dbca,当然了,前提是先创建一个监听. 2,手工命令安装em)手工命令创建em(确保数据库开启,确保监听正常并且最好是动态监听,确保system表空间够用大概1G左右),我的空间有限只给了800M,如下 select file_name,tablespace_name,bytes/1024/1024 from dba_data_files where tablespace_name like 'SYSTEM';alter database datafile '/u01