用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. Consider defining a bean of type 'package' in your configuration [Spring-Boot]

    https://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-config ...

  2. http://blog.csdn.net/hhhccckkk/article/details/9313999

    http://blog.csdn.net/hhhccckkk/article/details/9313999

  3. struts2 实现文件下载方法汇总

    http://pengranxiang.iteye.com/blog/259401 一.通过struts2提供的下载机制下载文件: 项目名为 struts2hello ,所使用的开发环境是MyEcli ...

  4. Angularjs实例应用

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  5. [HP-UNIX]bdf命令总结

    (1)bdf命令的效果 lijiaman$[/home/oracle]bdf Filesystem kbytes used avail %used Mounted on /dev/vg00/lvol3 ...

  6. Java实现批量修改文件名,重命名

    平时下载的文件.视频很多都会有网址前缀,比如一些编程的教学视频,被人共享出来后,所有视频都加上一串长长的网址,看到就烦,所以一般会重命名后看,舒服很多,好了,不多说,直接上代码: 以下代码演示使用递归 ...

  7. JS继续学习记录(一)

    JS继续学习记录(一) 总感觉自己的js code写的还算可以,但是又深知好像只知道一些皮毛,所以打算仔细记录一下js晋级学习过程,日日往复 先记录一下自己目前对js的了解吧(20180828) js ...

  8. ATX 浅谈自动化测试工具 python-uiautomator2

    1.简介 python-uiautomator2是一个自动化测试开源工具,仅支持Android平台的原生应用测试. 2.支持平台及语言 python-uiautomator2封装了谷歌自带的uiaut ...

  9. Mac系统配置php环境

    [写在前面——叨叨叨] -_-#急着配环境的同志们可以绕道.最近学校的实验室里接了一个小项目——考勤刷卡系统,利用RFID在硬件层获取学生卡的ID,通过wifi传输至服务器,进行考勤信息存储,手机端获 ...

  10. 如何在linux系统内用openssl 生成 过期的证书

    需求:验证过期的证书在系统中不能使用. 问题:如何生成过期的证书呢? 解决方法:1.调整系统时间 2.生成证书 3.验证证书startdate 和 enddate 是否符合你的预期 1.调整系统时间 ...