设为首页 收藏本站
查看: 1430|回复: 0

搭建LAMP的两种方式

[复制链接]
累计签到:2 天
连续签到:1 天
发表于 2015-4-13 09:46:18 | 显示全部楼层 |阅读模式
Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。
    随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。
目前LAMP架构是大多数中小企业最青睐的PHP架构选择,也是众多Linux SA喜欢选择的一套架构。接下来介绍下两种安装LAMP的两种方式。
一、yum安装
1、安装lamp,并启动相关服务
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[iyunv@jacken ~]#yum -y install httpd httpd-devel  mysql mysql-server mysql-libs php php-devel
这一条命令LAMP环境即可安装成功,只需要重启apache、mysql服务即可
[iyunv@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  ]
[iyunv@jacken ~]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[iyunv@jacken ~]# chkconfig mysqld on
[iyunv@jacken ~]# chkconfig httpd on
[iyunv@jacken ~]#



2、验证安装是否成功
wKioL1UovumDgcy-AAZ8QD0cCSs955.jpg 测试是否支持php环境
1
2
3
4
5
6
7
[iyunv@jacken ~]# cd /var/www/html/
[iyunv@jacken html]# ls
[iyunv@jacken html]# vim phpinfo.php
[iyunv@jacken html]# cat phpinfo.php
phpinfo();
?>



wKiom1Uovf2yxtKnAAVdNoiSNtk314.jpg
3、安装Discuz
1
2
3
4
5
6
7
[iyunv@jacken ~]# ls
Discuz_X3.2_SC_UTF8.zip
[iyunv@jacken ~]# unzip -q -d /var/www/html/ Discuz_X3.2_SC_UTF8.zip
[iyunv@jacken ~]# ls /var/www/html/
phpinfo.php  readme  upload  utility
[iyunv@jacken ~]# cd /var/www/html/
[iyunv@jacken html]# mv upload/* ./;rm -rf readme utility



wKioL1Uov9GiFJ47AARtmO-IJSo417.jpg

点同意
wKiom1Uovq6C5ccZAAIbdJhpExM046.jpg

设置相关目录权限
1
2
3
[iyunv@jacken html]# pwd
/var/www/html
[iyunv@jacken html]# chmod -R o+w config/ data/ uc_*



此时目录已可写,但是出现mysql链接不支持
wKioL1UowFGQuUqGAAGZRBT8QRo081.jpg
1
2
3
4
[iyunv@jacken upload]# yum -y install php-mysql
[iyunv@jacken upload]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]



wKioL1UowLKDLTqCAAH0ANajBQc863.jpg
下一步
wKiom1Uov4PgBn9KAAJyCaLpkP4478.jpg
创建discuz数据库,设置root密码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
[iyunv@jacken]#



wKioL1UowX3TE05NAALVRFNfl1A382.jpg
wKioL1UowX6xbkIfAAPUTIaQQE0286.jpg
wKiom1UowDayjQlwAARIrMub5mg239.jpg
wKiom1UowDehJdtIAAQk-ZTcNAg440.jpg
至此,LAMP基本搭建完毕。
进入论坛管理中心,会提示删除安装页
wKioL1UowbuTxJ3eAAFc7_RIYHY348.jpg
1
2
3
[iyunv@jacken ~]# cd /var/www/html/upload/install/
[iyunv@jacken install]# mv index.php index.php.bak
[iyunv@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
1
2
3
4
[iyunv@jacken ~]# cd /softwares/
[iyunv@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
[iyunv@jacken softwares]#



安装环境包
1
2
[iyunv@jacken softwares]# yum -y install apr-devel apr-util-devel
[iyunv@jacken ~]# yum -y install gcc



1、安装Apache
1
2
3
4
5
6
[iyunv@jacken ~]# cd /softwares/
[iyunv@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
[iyunv@jacken softwares]# tar -zxf httpd-2.2.27.tar.gz
[iyunv@jacken softwares]# cd httpd-2.2.27
[iyunv@jacken httpd-2.2.27]#./configure --prefix=/usr/local/apache --enable-so --enable-rewrite&&make&&make install



2、安装Mysql
1
2
3
4
5
6
[iyunv@jacken ~]# cd /softwares/
[iyunv@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
[iyunv@jacken softwares]# tar -zxf mysql-5.1.63.tar.gz
[iyunv@jacken softwares]# cd mysql-5.1.63
[iyunv@jacken mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install



报错
wKioL1UowpDBeXLtAAIp_xcLpm0884.jpg

1
2
[iyunv@jacken mysql-5.1.63]# yum –y  install ncurses-devel
[iyunv@jacken mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install



报错
wKioL1UowsLiaMn-AAMbftpheh8566.jpg
1
2
3
4
[iyunv@jacken mysql-5.1.63]# yum -y install gcc-c++
[iyunv@jacken mysql-5.1.63]# ./configure --prefix=/usr/local/mysql --enable-assembler && make && make install
[iyunv@jacken mysql-5.1.63]# echo $?
0



配置Mysql服务为系统服务
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[iyunv@jacken ~]# cp /usr/local/mysql/share/mysql/my-medium.cnf  /etc/my.cnf
[iyunv@jacken ~]# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
[iyunv@jacken ~]# chkconfig --add mysqld
[iyunv@jacken ~]# chkconfig --level 345 mysqld on
[iyunv@jacken ~]# cd /usr/local/mysql/
[iyunv@jacken mysql]# useradd mysql
[iyunv@jacken mysql]# chown -R mysql.mysql /usr/local/mysql
[iyunv@jacken mysql]# /usr/local/mysql/bin/mysql_install_db --user=mysql
[iyunv@jacken mysql]# chown -R mysql var
[iyunv@jacken mysql]# ll -d var
drwx------. 4 mysql root 4096 Mar 31 09:54 var
[iyunv@jacken mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql&
[1] 16857
[iyunv@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
[iyunv@jacken mysql]#



3、安装Php
1
2
3
4
5
6
7
8
9
10
[iyunv@jacken ~]# cd /softwares/
[iyunv@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
[iyunv@jacken softwares]# tar -jxf php-5.3.28.tar.bz2
[iyunv@jacken softwares]# cd php-5.3.28
[iyunv@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/



报错
wKiom1UowdPhEyFfAAGzywct4b4802.jpg
1
2
3
4
5
6
[iyunv@jacken php-5.3.28]# yum -y install libxml2 libxml2-devel
[iyunv@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/



wKiom1Uowg7S_YDhAALHRxzJSc8021.jpg
1
2
3
4
[iyunv@jacken php-5.3.28]#make && make install
[iyunv@jacken php-5.3.28]# echo $?
0
[iyunv@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测试页面,
1
2
3
4
5
6
7
8
9
[iyunv@jacken htdocs]# ls
index.html  index.php
[iyunv@jacken htdocs]# cat index.php
phpinfo();
?>
[iyunv@jacken htdocs]# pwd
/usr/local/apache/htdocs
[iyunv@jacken htdocs]#



wKiom1UowmGALpMEAALzWaXOqEA767.jpg
5、安装discuz论坛
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[iyunv@jacken ~]# cd /softwares/
[iyunv@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
[iyunv@jacken softwares]#
[iyunv@jacken softwares]# unzip Discuz_X3.2_SC_UTF8.zip  -d /usr/local/apache/htdocs/
[iyunv@jacken softwares]# cd /usr/local/apache/htdocs/
[iyunv@jacken htdocs]# ls
index.html  index.php  readme  upload  utility
[iyunv@jacken htdocs]# mv upload/* .
mv: overwrite `./index.php'? y
[iyunv@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_
[iyunv@jacken htdocs]# chmod -R o+w data/ config/ uc_server/ uc_client/
[iyunv@jacken htdocs]#



然后访问IP安装discuz论坛,如下图,选择“我同意”
wKiom1UowrCDpj1aAASSErtEL9M218.jpg
进入如下界面,数据库安装,如果不存在则需要新建数据库并授权。
wKioL1Uow_6RcWXjAAK1D4ldVJg293.jpg
数据库创建及授权命令如下:
wKioL1UoxF7gUX2DAAF7x2MgQ3s346.jpg
点击下一步
wKioL1UoxF_Qci32AAMko8mjflw548.jpg
安装完成,点击访问
wKioL1UoxNeh5UbIAAQ0mdJ3row638.jpg
管理员登录
wKiom1Uow4zQOQvHAAOR_LroSpQ535.jpg
自此LAMP环境整合并搭建成功,通过IP直接访问即可


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-56555-1-1.html 上篇帖子: 两台LAP和一台NFS+MySQL+DNS实现LAMP负载均衡访问 下篇帖子: LNMP环境的搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表