用yum快速搭建LAMP平台

实验环境:

[root@nmserver- html]# cat  /etc/redhat-release
CentOS release 7.3. (AltArch)
[root@nmserver- html]# uname -a
Linux nmserver-.test.com 3.10.-.el7.centos.plus.i686 # SMP Wed Jan :: UTC i686 i686 i386 GNU/Linux

1、安装apache

  1.1 安装apache

[root@nmserver- ~]# yum install httpd httpd-devel

  1.2 启动apache服务

[root@nmserver- ~]# systemctl start  httpd

  1.3 设置httpd服务开机启动

[root@nmserver- ~]# systemctl enable  httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

  1.4 查看服务状态

[root@nmserver- ~]# 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 五 -- :: CST; 6min ago
Docs: man:httpd()
man:apachectl()
Main PID: (httpd)
Status: "Total requests: 11; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
└─ /usr/sbin/httpd -DFOREGROUND 7月 :: nmserver-.test.com systemd[]: Starting The Apache HTTP Server...
7月 :: nmserver-.test.com httpd[]: AH00558: httpd: Could not reliably determine the server's fully q...ssage
7月 :: nmserver-.test.com systemd[]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

  1.5 防火墙设置开启80端口

[root@nmserver- ~]# firewall-cmd --permanent --zone=public  --add-service=http
success
[root@nmserver- ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@nmserver- ~]# firewall-cmd --reload
success

  1.6确认80端口监听中

[root@nmserver- ~]# 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:ssh 0.0.0.0:* LISTEN /sshd
tcp localhost:smtp 0.0.0.0:* LISTEN /master
tcp6 [::]:ssh [::]:* LISTEN /sshd
tcp6 localhost:smtp [::]:* LISTEN /master
tcp6 [::]:http [::]:* LISTEN /httpd
udp localhost: 0.0.0.0:* /chronyd
udp6 localhost: [::]:* /chronyd

  1.8 查服务器IP

[root@nmserver- ~]# ip addr
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN qlen
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
valid_lft forever preferred_lft forever
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :0c:::bc:cf brd ff:ff:ff:ff:ff:ff
inet 192.168.8.9/ brd 192.168.8.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe56:bccf/ scope link
valid_lft forever preferred_lft forever
: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu qdisc noqueue state DOWN qlen
link/ether ea::d5:c7:: brd ff:ff:ff:ff:ff:ff

  1.9 浏览器登陆

2、安装mysql

  2.1安装mysql

[root@nmserver- ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel
root@nmserver- ~]# rpm -qa |grep maria
mariadb-libs-5.5.-.el7.i686
mariadb-5.5.-.el7.i686
mariadb-server-5.5.-.el7.i686
mariadb-devel-5.5.-.el7.i686

  2.2 开启mysql服务,并设置开机启动,检查mysql状态

[root@nmserver- ~]# systemctl start  mariadb
[root@nmserver- ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@nmserver- ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since 六 -- :: CST; 21s ago
Main PID: (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─ /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─ /usr/libexec/mysqld --basedir=/usr --datadir=/v... 7月 :: nmserver-.test.com mariadb-prepare-db-dir[]: ...
7月 :: nmserver-.test.com mariadb-prepare-db-dir[]: ...
7月 :: nmserver-.test.com mariadb-prepare-db-dir[]: ...
7月 :: nmserver-.test.com mariadb-prepare-db-dir[]: ...
7月 :: nmserver-.test.com mariadb-prepare-db-dir[]: ...
7月 :: nmserver-.test.com mariadb-prepare-db-dir[]: ...
7月 :: nmserver-.test.com mariadb-prepare-db-dir[]: ...
7月 :: nmserver-.test.com mysqld_safe[]: ...
7月 :: nmserver-.test.com mysqld_safe[]: ...
7月 :: nmserver-.test.com systemd[]: Started MariaDB ...
[root@nmserver- ~]# 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:ssh 0.0.0.0:* LISTEN /sshd
tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 9760/mysqld
tcp6 [::]:ssh [::]:* LISTEN /sshd
tcp6 [::]:http [::]:* LISTEN /httpd
udp localhost: 0.0.0.0:* /chronyd
udp6 localhost: [::]:* /chronyd

  2.3 数据库安全设置

[root@nmserver- ~]# 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!

  2.4 登陆数据库测试

[root@nmserver- ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 5.5.-MariaDB MariaDB Server Copyright (c) , , 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 |
+--------------------+
rows in set (0.02 sec) MariaDB [(none)]>

3、安装PHP

  3.1 安装php

[root@nmserver- ~]# yum -y install php
[root@nmserver- ~]# rpm -ql php
/etc/httpd/conf.d/php.conf
/etc/httpd/conf.modules.d/-php.conf
/usr/lib/httpd/modules/libphp5.so
/usr/share/httpd/icons/php.gif
/var/lib/php/session

  3.2 将php与mysql关联起来

[root@nmserver- ~]# yum install php-mysql
[root@nmserver- ~]# rpm -ql php-mysql
/etc/php.d/mysql.ini
/etc/php.d/mysqli.ini
/etc/php.d/pdo_mysql.ini
/usr/lib/php/modules/mysql.so
/usr/lib/php/modules/mysqli.so
/usr/lib/php/modules/pdo_mysql.so

  3.3 安装常用PHP模块

[root@nmserver- ~]# 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

  3.4 测试PHP

[root@nmserver-7 ~]# cd  /var/www/html/
[root@nmserver-7 html]# ls
[root@nmserver-7 html]# pwd
/var/www/html
[root@nmserver-7 html]# vi info.php <?php
        phpinfo();
?>
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~       
:wq

  3.5重启apache服务器

[root@nmserver- html]# systemctl restart http

  3.6测试PHP

  在自己电脑浏览器输入 192.168.8.9/info.php,你可以看到已经安装的模块;

  

至此,CentOS7下LAMP环境搭建好了!下一步可以安装zabbix了!

centos7用yum搭建LAMP环境的更多相关文章

  1. 利用yum搭建lamp环境并进一步创建博客

    用yum搭建lamp环境 第一.安装apache yum -y install httpd 第二.安装mariadb Yum -y mariadb mariadb-server 第三.安装php Yu ...

  2. 基于CentOS7的服务器搭建(LAMP环境)

    基于CentOS7的服务器环境搭建(LAMP环境) 一.安装MySQL组件 1.由于在CentOS7中,默认yum安装库中不含有mysql,我们可以下载mysql的分支MariaDB,如果必须要下my ...

  3. CentOS 6.6 yum 搭建LAMP环境

    CentOS 查看操作系统版本 [root@oa ~]# cat /etc/redhat-releaseCentOS release 6.6 (Final) 参考linux centos yum安装L ...

  4. yum搭建 Lamp环境

    yum搭建Lamp yum install -y httpd yum install -y nano rpm 安装 Php7 相应的 yum源 rpm -Uvh https://dl.fedorapr ...

  5. centos7.2 yum安装lamp环境

    一.准备工作 1.   下载并安装centos7.2,配置好网络环境,确保centos能上网,可以获取到yum源. centos7.2的下载地址:http://pan.baidu.com/s/1eRT ...

  6. centos7 yum搭建lamp环境

    =============================================== 2018/1/14_第1次修改                       ccb_warlock == ...

  7. yum搭建LAMP环境

    LAMP=Linux+Apache(httpd)+Mysql(mariadb)+PHP Apache HTTP 服务器 2.4 文档:http://httpd.apache.org/docs/2.4/ ...

  8. centos7中yum安装lamp环境

    一.准备工作 1.1 环境 操作系统:centos7(CentOS-7-x86_64-Minimal-1708) 硬件:(这个根据项目运行和配置建议设置,一般我先配个1核1G) 1.2 关闭selin ...

  9. Centos7+Apache2.4+php5.6+mysql5.5搭建Lamp环境——为了wordPress

    最近想搭建个人博客玩玩,挑来挑去发现口碑不错的博客程序是wordpress,简称wp.虽然是学java路线的程序员,但因入行时间太短,至今没有发现较为称手开源的博客程序,如果各位大神有好的推荐,也希望 ...

随机推荐

  1. 从命令行运行Jmeter及jmeter参数说明、Html报告生成

    为什么要命令行执行脚本,主要有以下三点: 1) 图形化界面消耗更多资源,CPU和内存 2) 图形化界面不支持大型的负载测试和性能测试 3) 命令行测试支持持续集成,例如放到Jenkins这样的CI工具 ...

  2. 2018.12.14 Mac的Matlab2018a软件及其安装步骤

    软件百度云链接:https://pan.baidu.com/s/1q3EO5up-1YuAQ4gEi7sTwQ 密码:p6mf MATLAB R2018a for Mac破解说明 1.MATLAB R ...

  3. 2018.12.2 Mac环境下mysql图形化界面的Navicat premium 12 中文版安装与激活

    软件链接: https://pan.baidu.com/s/1ZUNLQ1DW9rQZUzDXQn2rWQ 提取码: 8i78 复制这段内容后打开百度网盘手机App,操作更方便哦 注意最新版 12.0 ...

  4. JavaScript js调用堆栈(一)

    本文主要介绍JavaScript程序内部的执行机制 首先先了解什么是执行上下文 执行上下文就是当前JavaScript代码被解析和执行是所在环境的抽象概念,JavaScript中运行任何的代码都是在执 ...

  5. LINUX日志的错误等级

    LINUX日志的错误等级 - CSDN博客 https://blog.csdn.net/solmyr_biti/article/details/50634533讯息等级 系统将讯息分为七个主要的等级, ...

  6. http返回值含义

    1xx:信息响应类,表示接收到请求并且继续处理2xx:处理成功响应类,表示动作被成功接收.理解和接受 3xx:重定向响应类,为了完成指定的动作,必须接受进一步处理4xx:客户端错误,客户请求包含语法错 ...

  7. SmallMQ发布

    最近一直学习,主要处理java的分布式,MQ,RPC,通信,数据库,缓存等方向. 一般现在的MQ都是企业级的,庞大,功能齐全.最主要是代码量大,对于我们这些小程序员而言,太大,修改困难,修复更加困难, ...

  8. C++求值顺序

    <C++Primer5th>中文版第124页 C++语言没有明确规定大多数二元运算符的求值顺序, 给编译器优化留下了余地. 这种策略实际上是在代码生成效率和程序潜在缺陷之间进行了权衡,这个 ...

  9. javaweb--json--ajax--mysql实现省市区三级联动(附三级联动数据库)

    在web中,实现三级联动很常见,尤其是利用jquery+json.但是从根本上来说jquery并不是最能让人容易理解的,接下来从最基本的javascript开始,实现由javascript+json+ ...

  10. C#判断系统是64位还是32位 支持.net4.0以前的版本

    C#判断系统是64位还是32位的时候引用了一串代码,这个代码是从园子里面其他博文中转载过来的,引入自己的项目中发现无法使用,在引用了相应的命名空间之后还是提示: "未能找到类型或命名空间名称 ...