用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. System.Chare的成员

    实现效果: 知识运用: System.Char的静态方法 (判断一个给定的字符是否为数字 字母 标点符号或其他) 实现效果: static void CharFunctionality() { Con ...

  2. SpringMVC学习记录一——入门介绍和入门程序

    1       springmvc框架 1.1      什么是springmvc springmvc是spring框架的一个模块,springmvc和spring无需通过中间整合层进行整合. spr ...

  3. 【luogu P2385 青铜莲花池】 题解

    题目链接:https://www.luogu.org/problemnew/show/P2385 莲花池什么的最漂亮啦! 最近刷了两天搜索= =我搜索一直是弱菜 直接套bfs #include < ...

  4. Redis的安装+哨兵模式+集群

    Redis安装(基于2.8版本) 哨兵(Sentinel集群)模式: 集群(基于3.0+)

  5. artTemplate 根据key循环对象

    artTemplate 根据key循环对象var dataObj={ data:{ a:{ name:'卡卡', age:10 }, b:{ name:'卡卡', age:10 }, c:{ name ...

  6. 如何使用 SSL 证书配置端口

    创建使用自承载的 Windows Communication Foundation (WCF) 服务时WSHttpBinding类,使用传输安全,还必须使用 X.509 证书配置端口. 如果不是在创建 ...

  7. Xcode 新建js文件

    Xcode 新建js文件

  8. iOS之报错“Cannot create __weak reference in file using manual reference counting”解决办法

    解决的办法:在Build Settings--------->Aplle LLVM8.0 - Language - Objectibe-C------------->Weak Refere ...

  9. 使用poi读取excel文件 Cannot get a text value from a numeric cell

    我这样转换得到一个excel文本域的值 Cell cell = row.getCell(c); cell.setCellType(Cell.CELL_TYPE_STRING); String park ...

  10. CF1042C Array Product(贪心,模拟)

    题目描述 You are given an array aa consisting of nn integers. You can perform the following operations w ...