zoukankan      html  css  js  c++  java
  • centos7用yum搭建LAMP环境

    用yum快速搭建LAMP平台

    实验环境:

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

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

    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
    设置成功会出现Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service。

    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 -tulp



    2、安装mysql

    2.1安装mysql

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

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

    [root@nmserver-7 ~]# systemctl start mariadb
    [root@nmserver-7 ~]# systemctl enable mariadb
    设置成功会出现Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
    [root@nmserver-7 ~]# systemctl status mariadb

    [root@nmserver-7 ~]# netstat -tulp

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



    3、安装PHP

    3.1 安装php

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

    3.2 将php与mysql关联起来

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

    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]# vi index.php

    保存退出。

    3.5重启apache服务器

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

    3.6测试PHP

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

  • 相关阅读:
    python3 基础数据类型之列表及其操作方法
    python3 逻辑运算符
    python3 内置函数
    python3 装饰器
    python3 变量作用域
    python3 参数以及函数的传参
    python3 函数基础
    洛谷P3379倍增LCA
    洛谷P3375KMP字符串匹配
    洛谷P2613有理数取余
  • 原文地址:https://www.cnblogs.com/lina520/p/9963206.html
Copyright © 2011-2022 走看看