centos 6.5 LAMP

貌似靠谱(主要centos默认有httpd,是否需要将其remove然后再安装啊,我采用到方法是没有安装,直接用的默认的),大致就是这个样子吧----zz

LAMP is a combination of operating system and
open-source software stack. The acronym LAMP is derived from first letters of
Linux, Apache HTTP Server, MySQL database, and PHP/Perl/Python.

In this tutorial let us see how to setup LAMP
server on RHEL/CentOS/Scientific Linux 6.x. Here x stands for version such as
6.1, 6.2, 6.3, 6.4, 6.5 etc.

My testbox hostname and IP address are
server.unixmen.local and 192.168.1.101/24, respectively.

Install Apache

Apache is an open-source multi-platform web
server. It provides a full range of web server features including CGI, SSL and
virtual domains.

To install Apache, enter the following command
from your terminal:

# yum install httpd -y





1

#
yum install httpd -y

Start the Apache service and let it to start
automatically on every reboot:

# service httpd start
# chkconfig httpd on






1

2

#
service httpd start

# chkconfig httpd on

Allow Apache server default port 80 through your
firewall/router if you want to connect from remote systems. To do that, edit
file /etc/sysconfig/iptables,

# vi /etc/sysconfig/iptables





1

#
vi /etc/sysconfig/iptables

Add the following lines.

[...]
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEP
[...]





1

2

3

[...]

-AINPUT-mstate--state NEW-mtcp-ptcp--dport80-jACCEP

[...]

Restart iptables:

# service iptables restart





1

#
service iptables restart

Test Apache:

Open your web browser and navigate to
http://localhost/ or http://server-ip-address/.

Install MySQL

MySQL is an enterprise class, open source,
world’s second most used database. MySQL is a popular choice of database for use
in web applications, and is a central component of the widely used LAMP open
source web application software stack.

To install MySQL, enter the following
command:

# yum install mysql mysql-server -y





1

#
yum install mysql mysql-server -y

Start the MySQL service and make to start
automatically on every reboot.

# service mysqld start
# chkconfig mysqld on






1

2

#
service mysqld start

# chkconfig mysqld on

Setup MySQL root password

By default, mysql root user doesn’t has
password. To secure mysql, we have to setup mysql root user password.

# mysql_secure_installation





1

#
mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we‘ll need the current
password for the root user. If you‘ve just installed MySQL, and
you haven‘t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): <span style="color: #ff0000;">## Press Enter ##</span>
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] <span style="color: #ff0000;">## Press Enter ##
</span>New password: <span style="color: #ff0000;">## Enter new password ##
</span>Re-enter new password: <span style="color: #ff0000;">## Re-enter new password ##
</span>Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] <span style="color: #ff0000;">## Press Enter ##
</span> ... Success!

Normally, root should only be allowed to connect from ‘localhost‘. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <span style="color: #ff0000;">## Press Enter ##</span>
... Success!
By default, MySQL comes with a database named ‘test‘ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <span style="color: #ff0000;">## Press Enter ##
</span> - Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <span style="color: #ff0000;">## Press Enter ##
</span> ... Success!

Cleaning up...

All done! If you‘ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!





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

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

NOTE:RUNNING ALL PARTS OF THISSCRIPT
ISRECOMMENDED
FORALL
MySQL

SERVERS
INPRODUCTION
USE!  PLEASE READ EACHSTEP CAREFULLY!

Inorder tolog into MySQL tosecure it,we‘ll
need the current

password for the root user.  If
you‘ve just
installed MySQL,and

you
haven‘t set
the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for
none):     <span style="color: #ff0000;">##
Press Enter ##</span>

OK,
successfully used password, moving on...

Setting the root password ensures that nobody can log
into the MySQL

root user without the proper authorisation.

Set root password? [Y/n]     <span
style="color: #ff0000;">## Press Enter ##

</span>New
password:                <span
style="color: #ff0000;">## Enter new password ##

</span>Re-enter new
password:       <span style="color:
#ff0000;">## Re-enter new password ##

</span>Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MySQL installation has an anonymous user,
allowing anyone

to log into MySQL without having to have a user account
created for

them.  This is intended only for testing, and
to make the installation

go a bit smoother.  You should remove them
before moving into a

production environment.

Remove anonymous users? [Y/n]    
<span style="color: #ff0000;">## Press Enter ##

</span> ... Success!

Normally, root should only be allowed to connect from
‘localhost‘.  This

ensures that someone cannot guess at the root password
from the network.

Disallow root login remotely?
[Y/n]     <span style="color: #ff0000;">## Press
Enter ##</span>

... Success!

By default, MySQL comes with a database named
‘test‘ that
anyone can

access.  This is also intended only for
testing, and should be removed

before moving into a production environment.

Remove test database and access to it?
[Y/n]     <span style="color: #ff0000;">## Press
Enter ##

</span> - Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all
changes made so far

will take effect immediately.

Reload privilege tables now?
[Y/n]     <span style="color: #ff0000;">## Press
Enter ##

</span> ... Success!

Cleaning up...

All done!  If you‘ve completed all of the
above steps,your
MySQL

installation should
now be
secure.

Thanks forusing MySQL!

Install PHP

PHP (recursive acronym for PHP: Hypertext
Preprocessor
) is a widely used open-source general purpose scripting
language that is especially suited for web development and can be embedded into
HTML.

Install PHP with following command:

# yum install php -y





1

#
yum install php -y

Test PHP

Create a sample “testphp.php” file in Apache
document root folder and append the lines as shown below:

# vi /var/www/html/testphp.php





1

#
vi /var/www/html/testphp.php

Add the following lines.

<?php
phpinfo();
?>





1

2

3

<?php

phpinfo();

?>

Restart httpd service:

# service httpd restart





1

#
service httpd restart

Navigate to
http://server-ip-address/testphp.php. It will display all the details about php
such as version, build date and commands etc.

If you wanna to get MySQL support in your PHP,
you should install “php-mysql” package. If you want to install all php modules
just you use the command “yum install php*”

[root@server ~]# yum install php-mysql -y





1

[root@server~]#
yum install php-mysql -y

Now open the phptest.php file in your browser
using http://ip-address/testphp.php or http://domain-name/testphp.php. Scroll
down and you will see the mysql module will be presented there.

Install phpMyAdmin

phpMyAdmin is a free open source web interface
tool, used to manage your MySQL databases. By default phpMyAdmin is not found in
CentOS official repositories. So let us install it using EPEL repository.

To install EPEL repository, follow the below
link:

- Install EPEL Repository On RHEL/CentOS/Scientific Linux
6

Now install phpMyAdmin

# yum install phpmyadmin -y





1

#
yum install phpmyadmin -y

Configure phpMyAdmin

Edit the phpmyadmin.conf file.

# vi /etc/httpd/conf.d/phpMyAdmin.conf






1

#
vi /etc/httpd/conf.d/phpMyAdmin.conf

Find and comment the whole /<Directory>
section as shown below:

[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<span style="color: #ff0000;">#&lt;Directory /usr/share/phpMyAdmin/&gt;</span>
<span style="color: #ff0000;"># &lt;IfModule mod_authz_core.c&gt;</span>
<span style="color: #ff0000;"># # Apache 2.4</span>
<span style="color: #ff0000;"># Require local</span>
<span style="color: #ff0000;"># &lt;/IfModule&gt;</span>
<span style="color: #ff0000;"># &lt;IfModule !mod_authz_core.c&gt;</span>
<span style="color: #ff0000;"># # Apache 2.2</span>
<span style="color: #ff0000;"># Order Deny,Allow</span>
<span style="color: #ff0000;"># Deny from All</span>
<span style="color: #ff0000;"># Allow from 127.0.0.1</span>
<span style="color: #ff0000;"># Allow from ::1</span>
<span style="color: #ff0000;"># &lt;/IfModule&gt;</span>
<span style="color: #ff0000;">#&lt;/Directory&gt;
[...]</span>





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

[...]

Alias/phpMyAdmin/usr/share/phpMyAdmin

Alias/phpmyadmin/usr/share/phpMyAdmin

<span style="color:
#ff0000;">#&lt;Directory
/usr/share/phpMyAdmin/&gt;</span>

<span style="color:
#ff0000;">#   &lt;IfModule
mod_authz_core.c&gt;</span>

<span style="color:
#ff0000;">#     # Apache
2.4</span>

<span style="color:
#ff0000;">#     Require
local</span>

<span style="color:
#ff0000;">#  
&lt;/IfModule&gt;</span>

<span style="color:
#ff0000;">#   &lt;IfModule
!mod_authz_core.c&gt;</span>

<span style="color:
#ff0000;">#     # Apache
2.2</span>

<span style="color:
#ff0000;">#     Order
Deny,Allow</span>

<span style="color:
#ff0000;">#     Deny from
All</span>

<span style="color:
#ff0000;">#     Allow from
127.0.0.1</span>

<span style="color:
#ff0000;">#     Allow from
::1</span>

<span style="color:
#ff0000;">#  
&lt;/IfModule&gt;</span>

<span style="color:
#ff0000;">#&lt;/Directory&gt;

[...]</span>

Open “config.inc.php” file and change from
“cookie” to “http” to change the authentication in phpMyAdmin:

# cp /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php
# vi /usr/share/phpMyAdmin/config.inc.php





1

2

#
cp /usr/share/phpMyAdmin/config.sample.inc.php
/usr/share/phpMyAdmin/config.inc.php

# vi /usr/share/phpMyAdmin/config.inc.php

Change cookie to http.

[...]
/* Authentication type */
$cfg[‘Servers‘][$i][‘auth_type‘] = <span style="color: #ff0000;">‘http‘</span>;
[...]






1

2

3

4

[...]

/* Authentication type */

$cfg[‘Servers‘][$i][‘auth_type‘]=<span
style="color:
#ff0000;">‘http‘</span>;

[...]

Restart the Apache service:

# service httpd restart





1

#
service httpd restart

Now you can access the phpmyadmin console by
navigating to http://server-ip-address/phpmyadmin/ from your browser.

Enter your MySQL username and password which you
have given in previous steps. In my case its “root” and “centos”.

Now you will be redirected to the phpmyadmin
dashboard.page as shown below.

Now you will able to manage your MariaDB
databases from phpMyAdmin web interface.

That’s it. Your LAMP server is up and ready to
use.

Cheers!

时间: 2024-10-23 15:58:20

centos 6.5 LAMP的相关文章

CentOS yum 安装LAMP PHP5.4版本

CentOS yum 安装LAMP PHP5.4版本     [字体:大 中 小] Linux系统版本:CentOS 6.5 1.yum安装和源代码编译在使用的时候没啥区别,但是安装的过程就大相径庭了,yum只需要3个命令就可以完成,源代码需要13个包,还得加压编译,步骤很麻烦,而且当做有时候会出错,源代码编译安装大概需要2个小时,好处在于可以自己配置地址等一些参数,yum安装半个小时搞定,一般不会出错,更新也很方便. 2.我的机器是CentOS release 5.9 64为的系统,一般机器都

CentOS下搭建LAMP环境详解

前言:在这里将介绍如何在CentOS下搭建LAMP环境(全部使用源码编译安装),用于web服务器开发. •LAMP: Linux + Apache + PHP + Mysql. •系统: CentOS 6.5,32位. CentOS安装 我选取了32位的CentOS 6.5这个Linux系统,安装过程也很简单,不再过多叙述,只稍微介绍一下我的分区情况: 分区名  大小 /boot  200MB /swap  2GB(不大于物理分区即可) /  20GB /home 剩余空间 Apache编译安装

linux centos yum安装LAMP环境

centos 6.5 1.yum安装和源代码编译在使用的时候没啥区别,但是安装的过程就大相径庭了,yum只需要3个命令就可以完成,源代码需要13个包,还得加压编译,步骤很麻烦,而且当做有时候会出错,源代码编译安装大概需要2个小时,好处在于可以自己配置地址等一些参数,yum安装半个小时搞定,一般不会出错,更新也很方便. 2.我的机器是centos release 5.9 64为的系统,一般机器都带yum命令,并且yum包源都是可以用的,就是说不用你自己下载东西,直接yum -y install 后

centos 一键安装lamp加强版

适用系统: CentOS-5 (32bit/64bit) CentOS-6 (32bit/64bit) 安装了什么: 1.Apache 2.2.20 2.MySQL 5.0.92 3.PHP 5.2.17 4.ZendOptimizer 3.3.9 5.eAccelerator 0.9.6.1 6.phpmyadmin 3.3.4 7.vsftpd 2.3.4 实现了什么功能 1.一键配置LAMP经典环境 2.自动删除apache日志,只保留七天内(具体时间可到/root/sh/apache-l

Centos yum搭建lamp环境

首先安装Apache2 一条命令即可: yum -y install httpd 回车后,yum会提示当前已经安装的httpd版本,并自动更新:如果没有安装,则会自动安装.注意在yum安装过程中输入"Y"以确认安装. Apache安装完成后,手动启动Apache2: /etc/init.d/httpd start 这时,直接在 浏览器中输入服务器的IP地址,即可看到Apache2的默认页面.此时的Apache仅仅能提供HTTP服务,不能执行php.也不能连接MySQL 数据库. 安装M

CentOS快速搭建LAMP环境

LAMP --  Linux Apache MySQL PHP 在CentOS安装的顺序,我一般是Apache -> MySQL -> PHP 第一步.安装并配置Apache 1.使用yum安装 [plain] view plaincopy yum install httpd 2.修改防火墙配置,打开80端口,可以顺便把MySQL的3306端口也打开 [plain] view plaincopy vi /etc/sysconfig/iptables 添加两条记录 [plain] view pl

Centos yum 安装lamp PHP5.4版本号

centos 6.5 1.yum安装和源码编译在使用的时候没啥差别.可是安装的过程就大相径庭了,yum仅仅须要3个命令就能够完毕,源码须要13个包,还得加压编译.步骤非常麻烦,并且当做有时候会出错,源码编译安装大概须要2个小时.优点在于能够自己配置地址等一些參数,yum安装半个小时搞定.一般不会出错.更新也非常方便. 2.我的机器是centos release 5.9 64为的系统.一般机器都带yum命令.而且yum包源都是能够用的,就是说不用你自己下载东西,直接yum -y install 后

Centos系统下Lamp环境的快速搭建(超详细,转)

lamp的搭建对于初学者是一件很头疼的事情,所以借此机会把自己当初快速搭建linux+apche+mysql+php的方法分享大家希望能到你. 工具/原料 虚拟机及Centos操作系统 Linux基本命令的使用 方法/步骤 首先为了搭建一个稳定的lamp的练习环境,确保你的虚拟机可以连网,这里我们使用的yum安装,它可以帮助我们解决软件自己的依赖关系.我还在后面加了postgresql数据库如果不需要的话可以去掉和postgresql的参数.命令如下 yum -y install httpd m

centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)

第一部分LNMP环境搭建 一.编译安装nginx1.10.3 1.准备 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [[email protected] ~]# uname -a Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_6

Centos 7 安装LAMP以及在Apache上安装positiveSSL。

简介 LAMP(linux , Apache, mysql , php)是集成动态网站经常使用的一套开源软件,实际包含linux操作系统,Apache web服务器,mysql(mariadb 分支)数据库,还有处理动态内容的php脚本语言.这里简要介绍一下自己在Centos 7上的安装过程,体验. 关于LAMP 步骤一:安装Apache 首先yum安装httpd:    sudo yum install httpd 然后启动httpd服务:     sudo systemctl start h