zoukankan      html  css  js  c++  java
  • yum安装lamp

    yum快速搭建LAMP平台

     

    实验环境:

    [root@nmserver-7 html]# cat  /etc/redhat-release

    CentOS release 7.3.1611 (AltArch)

    [root@nmserver-7 html]# uname -a

    Linux nmserver-7.test.com 3.10.0-514.el7.centos.plus.i686 #1 SMP Wed Jan 25 12:55:04 UTC 2017 i686 i686 i386 GNU/Linux

    1、安装apache

      1.1 安装apache

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

      1.2 启动apache服务

    [root@nmserver-7 ~]# systemctl start  httpd

      1.3 设置httpd服务开机启动

    [root@nmserver-7 ~]# systemctl enable  httpd

      1.4 查看服务状态

    [root@nmserver-7 ~]# systemctl status httpd

      1.5 防火墙设置开启80端口

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

    success

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

    success

    [root@nmserver-7 ~]# firewall-cmd --reload

    success

      1.6确认80端口监听中

    [root@nmserver-7 ~]# netstat -anpt|grep 80

    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      16861/httpd

      1.8 查服务器IP

    [root@nmserver-7 ~]# ip addr

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1

        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

        inet 127.0.0.1/8 scope host lo

           valid_lft forever preferred_lft forever

        inet6 ::1/128 scope host

           valid_lft forever preferred_lft forever

    2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

        link/ether 00:0c:29:56:bc:cf brd ff:ff:ff:ff:ff:ff

        inet 192.168.8.9/24 brd 192.168.8.255 scope global ens33

           valid_lft forever preferred_lft forever

        inet6 fe80::20c:29ff:fe56:bccf/64 scope link

           valid_lft forever preferred_lft forever

    3: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000

        link/ether ea:89:d5:c7:32:73 brd ff:ff:ff:ff:ff:ff

      1.9 浏览器登陆

     

    2、安装mysql

      2.1安装mysql

    [root@nmserver-7 ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel

    root@nmserver-7 ~]# rpm -qa |grep maria

    mariadb-libs-5.5.52-1.el7.i686

    mariadb-5.5.52-1.el7.i686

    mariadb-server-5.5.52-1.el7.i686

    mariadb-devel-5.5.52-1.el7.i686

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

    [root@nmserver-7 ~]# systemctl start  mariadb

    [root@nmserver-7 ~]# systemctl enable  mariadb

    [root@nmserver-7 ~]# netstat -anpt|grep 3306

    tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      17432/mysqld   

      2.3 数据库安全设置

    [root@nmserver-7 ~]# 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    ##设置MySQL密码

    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-7 ~]# mysql -uroot -p

    Enter password:

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

    Your MariaDB connection id is 11

    Server version: 5.5.52-MariaDB MariaDB Server

    Copyright (c) 2000, 2016, 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.02 sec)

    MariaDB [(none)]>

    3、安装PHP

      3.1 安装php

    [root@nmserver-7 ~]# yum -y install php

    [root@nmserver-7 ~]# rpm -ql php

    /etc/httpd/conf.d/php.conf

    /etc/httpd/conf.modules.d/10-php.conf

    /usr/lib/httpd/modules/libphp5.so

    /usr/share/httpd/icons/php.gif

    /var/lib/php/session

      3.2 phpmysql关联起来

    [root@nmserver-7 ~]# yum install php-mysql

    [root@nmserver-7 ~]# 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-7 ~]# 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();
    ?>

      3.5重启apache服务器

    [root@nmserver-7 html]# systemctl restart httpd

      3.6测试PHP

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

     

  • 相关阅读:
    开发ProxyServer的时候如何在一台PC上调试
    eclipse使用replace命令替换整个project/workspace的某个字符串
    android程序获取WIFI的IP地址和MAC地址
    将web项目deploy到tomcat的方法
    Windows下搭建Android开发环境
    解决:并排的两个div底部对齐
    eclipse调试jsp中的scriptlet代码
    棋盘覆盖(递归分治问题)
    Java中sleep()和wait()的区别
    Random()方法的使用
  • 原文地址:https://www.cnblogs.com/ccshi/p/13151353.html
Copyright © 2011-2022 走看看