Centos7.2(1151)使用Yum搭建LAMP+phpMyAdmin

一、实验环境

操作系统 IP地址 相关软件包
Centos7.2_x64 10.0.0.10 http、php、mariadb
Windows10_enterprise 10.0.0.2 Google浏览器

二、服务搭建

2.安装Apache

2.1.安装Apache

[[email protected] ~]# yum -y install httpd httpd-devel

2.2.启动Apache服务

[[email protected] ~]# systemctl start httpd

2.3.设置开机自启

[[email protected] ~]# systemctl enable httpd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

2.4.查看服务状态

[[email protected] ~]# systemctl status httpd

● httpd.service - The Apache HTTP Server

Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)

Active: active (running) since 三 2017-11-01 20:32:28 CST; 1h 20min ago

Docs: man:httpd(8)

man:apachectl(8)

Main PID: 3909 (httpd)

Status: "Total requests: 56; Current requests/sec: 0; Current traffic:   0 B/sec"

CGroup: /system.slice/httpd.service

├─3909 /usr/sbin/httpd -DFOREGROUND

├─3911 /usr/sbin/httpd -DFOREGROUND

├─3912 /usr/sbin/httpd -DFOREGROUND

├─3913 /usr/sbin/httpd -DFOREGROUND

├─3914 /usr/sbin/httpd -DFOREGROUND

├─3915 /usr/sbin/httpd -DFOREGROUND

├─3928 /usr/sbin/httpd -DFOREGROUND

├─3932 /usr/sbin/httpd -DFOREGROUND

├─3933 /usr/sbin/httpd -DFOREGROUND

├─3934 /usr/sbin/httpd -DFOREGROUND

└─3935 /usr/sbin/httpd -DFOREGROUND

11月 01 20:32:28 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...

11月 01 20:32:28 localhost.localdomain httpd[3909]: AH00558: httpd: Could not reliably determine the server‘s fully qualifie...ssage

11月 01 20:32:28 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

Hint: Some lines were ellipsized, use -l to show in full.

2.5.防火墙允许80端口通过

[[email protected] ~]# firewall-cmd --permanent --zone=public  --add-service=http

success

[[email protected] ~]# firewall-cmd --permanent --zone=public  --add-service=https

success

[[email protected] ~]# firewall-cmd --reload

success

2.6.确定80端口监听中

[[email protected] ~]# netstat -tulp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 0.0.0.0:mysql           0.0.0.0:*               LISTEN      2292/mysqld

tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      721/sshd

tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN      1321/master

tcp6       0      0 [::]:http               [::]:*                  LISTEN      3909/httpd

tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      721/sshd

tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      1321/master

2.7.Windows10中打开浏览器访问:http://10.0.0.10/

#注:出现如上内容证明Apache服务已经可以正常访问了

三、安装Mariadb

3.1.安装mariadb

[[email protected] ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel -y

3.2.开启mysql服务,并设置卡机启动,检查mysql状态

[[email protected] ~]# systemctl start mariadb.service

[[email protected] ~]# systemctl enable mariadb.service

[[email protected] ~]# systemctl status mariadb.service

● mariadb.service - MariaDB database server

Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)

Active: active (running) since 三 2017-11-01 19:32:49 CST; 3h 38min ago

Main PID: 2130 (mysqld_safe)

CGroup: /system.slice/mariadb.service

├─2130 /bin/sh /usr/bin/mysqld_safe --basedir=/usr

└─2292 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/va...

11月 01 19:32:47 localhost.localdomain mariadb-prepare-db-dir[2051]: MySQL manual for more instructions.

11月 01 19:32:47 localhost.localdomain mariadb-prepare-db-dir[2051]: Please report any problems at http://mariadb.org/jira

11月 01 19:32:47 localhost.localdomain mariadb-prepare-db-dir[2051]: The latest information about MariaDB is available at htt...rg/.

11月 01 19:32:47 localhost.localdomain mariadb-prepare-db-dir[2051]: You can find additional information about the MySQL part at:

11月 01 19:32:47 localhost.localdomain mariadb-prepare-db-dir[2051]: http://dev.mysql.com

11月 01 19:32:47 localhost.localdomain mariadb-prepare-db-dir[2051]: Consider joining MariaDB‘s strong and vibrant community:

11月 01 19:32:47 localhost.localdomain mariadb-prepare-db-dir[2051]: https://mariadb.org/get-involved/

11月 01 19:32:47 localhost.localdomain mysqld_safe[2130]: 171101 19:32:47 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log‘.

11月 01 19:32:47 localhost.localdomain mysqld_safe[2130]: 171101 19:32:47 mysqld_safe Starting mysqld daemon with databases ...mysql

11月 01 19:32:49 localhost.localdomain systemd[1]: Started MariaDB database server.

Hint: Some lines were ellipsized, use -l to show in full.

[[email protected] ~]# netstat -tulp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 0.0.0.0:mysql           0.0.0.0:*               LISTEN      2292/mysqld

tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      721/sshd

tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN      1321/master

tcp6       0      0 [::]:http               [::]:*                  LISTEN      3909/httpd

tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      721/sshd

tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      1321/master

3.3.初始化数据库

[[email protected] ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we‘ll need the current

password for the root user.  If you‘ve just installed MariaDB, 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):

OK, successfully used password, moving on...

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

root user without the proper authorisation.

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

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

to log into MariaDB 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] y

... 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] n

... skipping.

By default, MariaDB 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] y

- 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] y

... Success!

Cleaning up...

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

installation should now be secure.

Thanks for using MariaDB!

3.4.登陆数据库测试

[[email protected] ~]# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 37

Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

四、安装PHP

4.1.安装php

[[email protected] ~]# yum -y install php

4.2.安装php与mysql连接组件

[[email protected] ~]# yum install php-mysql

4.3.安装PHP常用模块

[[email protected] ~]# yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath

4.4.测试PHP

命令行中输入:

echo "<?php

phpinfo();

?>" > /var/www/html/test.php

#注:以上内容的意思是将双引号里面的内容打印到/var/www/html/test.php,这个test.php就是我们创建的PHP测试页,也可以使用vim创建该文件并添加内容。

4.5.重启Apahce服务

[[email protected] ~]# systemctl restart httpd.service

4.6.浏览器测试PHP

浏览器中输入:http://10.0.0.10/test.php

五、安装phpMyAdmin

5.1.安装epel源

[[email protected] ~]# yum install -y epel-release

[[email protected] ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

5.2.安装phpmyadmin并编辑phpmyadmin.conf文件

[[email protected] ~]# yum install -y phpmyadmin

#复制phpmyadmin.conf文件

cp /etc/httpd/conf.d/phpMyAdmin.conf /etc/httpd/conf.d/phpMyAdmin.conf.bak

#编辑/etc/httpd/conf.d/phpMyAdmin.conf文件

# phpMyAdmin - Web based MySQL browser written in php

#

# Allows only localhost by default

#

# But allowing phpMyAdmin to anyone other than localhost should be considered

# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin

Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>

AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>

# Apache 2.4

<RequireAny>

#Require ip 127.0.0.1 #注释掉

#Require ip ::1 #注释掉

Require all granted #新增

</RequireAny>

</IfModule>

<IfModule !mod_authz_core.c>

# Apache 2.2

Order Deny,Allow

Deny from All

#Allow from 127.0.0.1 #注释掉

#Allow from ::1 #注释掉

Allow from All granted #新增

</IfModule>

</Directory>

<Directory /usr/share/phpMyAdmin/setup/>

<IfModule mod_authz_core.c>

# Apache 2.4

<RequireAny>

Require ip 127.0.0.1

Require ip ::1

</RequireAny>

</IfModule>

<IfModule !mod_authz_core.c>

# Apache 2.2

Order Deny,Allow

Deny from All

Allow from 127.0.0.1

Allow from ::1

</IfModule>

</Directory>

# These directories do not require access over HTTP - taken from the original

# phpMyAdmin upstream tarball

#

<Directory /usr/share/phpMyAdmin/libraries/>

Order Deny,Allow

Deny from All

Allow from None

</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>

Order Deny,Allow

Deny from All

Allow from None

</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>

Order Deny,Allow

Deny from All

Allow from None

</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from

# filtering SQL etc.  This may break your mod_security implementation.

#

#<IfModule mod_security.c>

#    <Directory /usr/share/phpMyAdmin/>

#        SecRuleInheritance Off

#    </Directory>

#</IfModule>

5.3.修改完phpmyadmin配置文件后重启Apache。

[[email protected] ~]# systemctl restart httpd

5.4.使用浏览器打开http://10.0.0.10/phpMyAdmin

#用户名密码就是数据库的用户名密码

#输入用户名密码之后进入到首页就可以使用phpmyadmin管理数据库了。

参考文章:http://www.cnblogs.com/me80/p/7218883.html

#注:除去上方链接中的文章以外还参考了网上其他文章,由于浏览器开启了无痕模式找不到链接,没法标注在此,如有侵权请联系我删除。

时间: 2024-11-08 20:52:06

Centos7.2(1151)使用Yum搭建LAMP+phpMyAdmin的相关文章

linux下Yum搭建lamp网站架构

在上节课我用了源代码和免安装软件的两种方式搭建了LAMP架构的网站,今天我们对上一节做个简单的总结: 源代码安装软件是我们Linux下常用的安装方法共分四个步骤: 在上一节我们的数据库就是免安装的.直接解压就可以使用了.是不是很简单,只要我们把前面的命令都掌握了,后面的服务搭建都不是问题. 今天我们讲解用yum搭建lamp网站架构.用yum命令安装软件也是我们Linux下一种常用的,因为他更简单,但是移植性差.好啦开始我们的操作了. 实验环境: 一台单机服务器,操作系统centos6.6.注意服

shell-scripts通过yum搭建LAMP和mysql主从

----------------------- #!/bin/bash #select menu yum install lamp and mysql master_slave #by colink in 2015-04-28,05-13 #version v.c.m.0.3 BACKUP_DIR="/data/backup/`date +%Y%m%d`/" IPADDR=`ifconfig eth0|grep Bcast |awk '{print $2}'|sed 's/addr:/

CentOS7 yum搭建lamp

简易搭建lamp 环境说明: server:CentOS7-192.168.230.202 client: win8.1-192.168.230.59 Apache/2.4.6 php Version 5.4.16 5.5.52-MariaDB yum group install Development Tools #安装开发工具,GCC... yum install httpd mariadb mariadb-server php php-mysql php-gd libjpeg* php-i

Centos7 - ownCloud 私有云盘搭建 (LAMP环境)

1.首先搭建LAMP环境使用YUM安装LAMP环境,具体参数如下:..[[email protected] ~]# yum install httpd php php-mysql mariadb-server mariadb sqlite php-dom php-mbstring php-gd php-pdo.....关闭selinux,清空iptables,firewalld防火墙放行相关服务.....默认安装的PHP是5.4版本,需要升级到5.6版本...升级PHP:1)首先添加PHP5.6

CentOS 6.6 yum 搭建LAMP环境

CentOS 查看操作系统版本 [[email protected] ~]# cat /etc/redhat-releaseCentOS release 6.6 (Final) 参考linux centos yum安装LAMP环境 Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器. 基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软

在CentOS7上通过RPM安装实现LAMP+phpMyAdmin过程全记录

时间:2017年9月20日 一.软件环境: IP:192.168.1.71 Hostname:centos73-2.surmount.net Linux:CentOS Linux release 7.3.1611 (Core) Apache:httpd-2.4.6 Mysql:Ver 15.1 Distrib 5.5.52-MariaDB PHP:初始用ISO光盘yum源安装的版本为php-5.4.16.在后续安装phpMyAdmin-4.7.4时报错,然后按提示升级为php56w-5.6.31

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

yum 搭建LAMP

yum install -y  httpd php php-mysql mysql mysql-server mysql-devel php-gd  libjpeg libjpeg-devel libpng libpng-devel /etc/init.d/httpd start    启动httpd服务 /etc/init.d/mysqld start  启动mysql服务 vim /etc/httpd/conf/httpd.conf   编辑httpd配置文件 找到ServerName Lo

centos6.3利用yum搭建lamp环境

用putty连上服务器后,先更新: [[email protected] /]# yum update 然后安装LAMP环境: [[email protected] /]# yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xml