按照 openSUSE SDB:LAMP setup安装好了LAMP。运行的大多数命令都是来自与openSUSE SDB:LAMP setup中。

本页面描述如何安装LAMP,这是 Linux Apache MariaDB PHP. 为了这个目的,你需要安装:

  • 一个运行的Apache2 web服务
  • 一个已经配置好的MariaDB数据库服务
  • PHP5和Apahce2一起运行;并且完美
  • phpMyAdmin和一个已经配置好的pmadb数据库

整个安装需要的时间大概是20分钟,但这可能依赖你的网络连接情况。

安装apache2

第一,确保你有root权限和输入以下代码:

zypper in apache2

启动apache2

systemctl start apache2

如果你想重启apache,使用:

systemctl restart apache2

或者你想停止它,使用:

systemctl stop apache2

为了系统重启后自动启动apache服务

systemctl enable apache2

测试安装

为了检查你的apache2服务是否工作,使用你喜欢的文本编辑器在/srv/www/htdocs/文件夹中创建一个文件index.html文件写入以下内容:

<html><body><h1>Welcome to my web site!</h1></body></html>

现在使用你喜欢的浏览器,输入localhost,你应该可以看到一个页面中和大字标题 Welcome to my web site!

启用web服务可以外部访问

在目前的状态,web服务只允许使用localhost访问。如果你想允许它使用一个远程主机名(host)访问,你需要在防火墙中开启http(80)端口。这样做,编辑/etc/sysconfig/SuSEfirewall2文件和修改以下行

FW_CONFIGURATION_EXT=""

FW_CONFIGURATION_EXT="apache2"
在这一行,应该使用空格隔开每个元素,如防火墙开放 apache,mysql,配置就会变为FW_CONFIGURATIONS_EXT="apache2 mysql"

在编辑完之后,你需要重启防火墙使用:

systemctl restart SuSEfirewall2
当然,你可以通过YaST来做这件事,然后选择 安全和用户 --> 防火墙 --> 允许的服务 和添加 Http 服务

安装PHP

安装PHP7

确保你有root权限 -- 看下面,安装php7使用:

zypper in php7 php7-mysql apache2-mod_php7

别忘记启用mod-php通过运行:

a2enmod php7

你已经完成了,php7现在已经安装了。

安装PHP5

如果使用安装PHP5,步骤差不多和上面一样,使用"php5"代替"php7"

zypper in php5 php5-mysql apache2-mod_php5
a2enmod php5

注意你需要选择安装php5还是php7,你不能同时安装它们。

重启web服务器

现在你已经安装好了php,你需要重启你的apache2 web服务器:

systemctl restart apache2

测试安装

为了验证php是已经在运行,在/srv/www/htdocs/文件夹中创建一个index.php文件并写入以下内容:

<?php
phpinfo();
?>

现在,使用你的浏览器浏览localhost,你应该可以看到一个页面包含一个表格显示所有的PHP设置

安装 MariaDB

MariaDB 是一个MySQL的代替品,而且也是使用mysql名称.

安装 Installing MariaDB

确保你有root权限 -- 同上。我们需要安装mariadbmariadb-tools

zypper in mariadb mariadb-tools
mariadb-tools 是MariaDB的管理工具集

启动MariaDB服务

启动MariaDB服务,运行:

systemctl start mysql

如果你想在服务器上面看发布消息,cat /var/log/messages.

cat /var/log/messages

确认这个服务能够在每次启动时自动启动:

systemctl enable mysql

如果你想重启mysql,运行:

systemctl restart mysql

或者你想停止它,运行:

systemctl stop mysql

配置 MariaDB/MySql 服务

和 Leap 42.1

通过配置MariaDB 服务提高安全性,请使用openSUSE提供的脚本mysql_secure_installation.后面的描述全过程

root # 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):

这里尽管按回车(Enter)键.

root #
... (output sequel of previous command)
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

这里尽管输入y.

root #
... (output sequel of previous command)
New password:

现在输入给root用户的密码

root #
... (output sequel of previous command)
Re-enter new password:

输入确认密码

root #
... (output sequel of previous command)
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来移除匿名用户。

root #
... (output sequel of previous command)
... 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]

现在回复y

root #
... (output sequel of previous command)
... Success! 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

root #
... (output sequel of previous command)
- 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!

在过去的旧版本中

替换<NEW PASSWORD>的值为你想定义的一个新密码,运行:

mysqladmin -u root password '<NEW PASSWORD>'

输入目前的密码或密码从没有定义只需要按回车(Enter)

在客户端登录

现在你可以在服务器客户端中登录通过运行:

root # mysql -u root -p
Enter password:

然后输入你的密码

root #
... (output sequel of previous command)
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is Server version: 10.0.-MariaDB openSUSE package Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

可以通过运行exit;回到终端.

安装 phpMyAdmin

什么是phpMyAdmin

phpMyAdmin -- a.k.a pma -- 是一个通过网站页面来管理你数据库的工具。

安装phpMyAdmin

安装phpMyAdmin,运行:

zypper in phpMyAdmin

这当然会安装一些依赖的php5模块和重启apache2服务。

登录到phpMyAdmin

为了登录到phpMyAdmin:

  • 指向到localhost/phpMyAdmin
  • 输入你mysql服务的用户名root和root用户的密码
  • 点击'go'按钮
当然你会获取到一个错误消息说缺少Multibytes String(mbstring)扩展。这个是下一章节的主题。

检查phpMyAdmin

现在你可以通过你的浏览器浏览http://localhost/phpMyAdmin/http://ip_address/phpMyAdmin/并输入mysql root的用户名和他的密码。

就是这些!你现在可以通过一个网站页面来管理你的数据库了。

你可以阅读phpMyAdmin的文档在phpMyAdmin website

你现在应该有个在运行的LAMP服务了。

另外补充安装php扩展部分

安装php7的扩展

sudo zypper in php7-bcmath php7-opcache php7-bz2 php7-calendar php7-ctype php7-curl php7-dom php7-ftp php7-gd php7-gettext php7-gmp php7-iconv php7-imap php7-ldap php7-mbstring php7-mcrypt php7-odbc php7-openssl php7-pcntl php7-pgsql php7-posix php7-shmop php7-snmp php7-soap php7-sockets php7-sqlite php7-sysvsem php7-tokenizer php7-wddx php7-xmlrpc php7-xsl php7-zlib php7-exif php7-fastcgi php7-pear php7-sysvmsg php7-sysvshm php7-zip

如果你想安装php5的扩张,运行的命令和上面一样,把"php7"替换为"php5",运行:

sudo zypper in php5-bcmath php5-opcache php5-bz2 php5-calendar php5-ctype php5-curl php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm php5-zip

安装完之后,别忘记重启apache2 web服务。

sudo systemctl restart apache2

安装mysql

sudo zypper in mysql-community-server mysql-community-server-client mysql-community-server-tools mysql-connector-java mysql-workbench

参考:

  1. SDB:LAMP setup本文的英文原文

  2. openSUSE之PHP学习之旅(1、环境配置) 学习了如何安装php模块
  3. 19. LAMP和LNMP服务器部署

openSUSE 安装LAMP记录的更多相关文章

  1. opensuse安装pycurl失败记录

    早上在opensuse安装pycurl,一直出现如下错误: pepper@VM_56_243_suse:~/code/gitosis-autotest> pip install pycurl C ...

  2. Linux安装LAMP开发环境及配置文件管理

    Linux主要分为两大系发行版,分别是RedHat和Debian,lamp环境的安装和配置也会有所不同,所以分别以CentOS 7.1和Ubuntu 14.04做为主机(L) Linux下安装软件,最 ...

  3. CentOS使用yum源中自带的rpm包安装LAMP环境

    CentOS使用yum源中自带的rpm包安装LAMP环境.这是Linux下安装LAMP的环境一种最基本最简便的方式.新手可以从容安装使用. 1. 安装基础包(可选安装)yum install -y w ...

  4. CentOS6.3 编译安装LAMP(2):编译安装 Apache2.2.25

    所需源码包: /usr/local/src/Apache-2.2.25/httpd-2.2.25.tar.gz 编译安装 Apache2.2.25 #切换到源码目录 cd /usr/local/src ...

  5. 将php网站移到CentOS 6.7上[一]:yum安装lamp环境

    最近应老师要求,将一个网站从51php上转移到学校提供的服务器上,之前对Linux没有了解,一切都在百度百度百度.于是发现很多步骤自己做过后就忘了,现将有效步骤记录下来,以供下次参考. 原51php上 ...

  6. CentOS 7 / RHEL 7 上安装 LAMP + phpMyAdmin

    原文 CentOS 7 / RHEL 7 上安装 LAMP + phpMyAdmin 发表于 2014-11-02 作者 Haoxian Zeng 更新于 2014-12-12   之前根据在 Lin ...

  7. openSUSE 安装

    https://lug.ustc.edu.cn/sites/opensuse-guide/installation.php 开始 1. 简介2. 改用 GNU/Linux3. 获取 openSUSE4 ...

  8. CentOS 7.4 yum安装LAMP环境

    配置防火墙,开启80.3306端口.CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. #停止firewall服务 systemctl stop firewa ...

  9. linux centos 宝塔主机控制面板安装和安全狗安装过程记录

    linux 宝塔控制面板 安装过程yum install -y wget && wget -O install.sh http://103.224.251.79:5880/instal ...

随机推荐

  1. [JZOJ 5861] 失意

    思路: 求交集最大老套路,排序之后用堆维护即可. #include <bits/stdc++.h> using namespace std; const int mod = 1e9+7; ...

  2. HDU4578-代码一点都不长的线段树

    (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 题意:传送门  原题目描述在最下面.  4种操作,1:区间加法,2:区间乘法,3:区间的所有数都变成一个数,4:访问区间每个数的p次方 ...

  3. PMP项目管理——项目范围管理-规划范围管理

    规划范围管理是为记录如何定义.确认和控制项目范围及产品范围,而创建范围管理计划的过程.主要作用是,在整个项目期间对如何管理范围提供指南和方向.制定范围管理计划和细化项目范围始于对下列信息的分析:项目章 ...

  4. 【JUC】JDK1.8源码分析之AbstractQueuedSynchronizer

    一.前言 在锁框架中,AbstractQueuedSynchronizer抽象类可以毫不夸张的说,占据着核心地位,它提供了一个基于FIFO队列,可以用于构建锁或者其他相关同步装置的基础框架.所以很有必 ...

  5. [01]APUE:sysconf / pathconf

    sysconf / pathconf:用于运行时确定特定系统实际支持的限制值 sysconf 函数的参数格式: “_SC_ + 限制项名称”,如:CHILD_MAX 限制值指每个实际用户 ID 可以启 ...

  6. Python骚操作(一)

    1. 交换变量值 2. 将列表中所有元素组合成字符串 3. 查找列表中频率最高的值 4. 检查连个字符串是不是由相同字母不同顺序组成 5. 反转字符串 6. 反转列表 7. 转置二维数组 8. 链式比 ...

  7. Reverses CodeForces - 906E (最小回文分解)

    题意: 给你两个串s和t,其中t是由s中选择若干个不相交的区间翻转得到的,现在要求求出最少的翻转次数以及给出方案. 1≤|s|=|t|≤500000 题解: 我们将两个字符串合成成T=s1t1s2t2 ...

  8. iOS逆向系列-tweak补充

    tweak加载资源 开发自己的deb插件需要加载自己的资源,比如图片资源.iOS中常用的两种加载图片资源的方式: + (nullable UIImage *)imageNamed:(NSString ...

  9. PHP出现报警后需要修改 date.timezone 的值(php.ini)

    PHP调试的时候出现了警告: It is not safe to rely on the system解决方法,其实就是时区设置不正确造成的,本文提供了3种方法来解决这个问题. 实际上,从PHP 5. ...

  10. CTR预估的常用方法

    1.CTR CTR预估是对每次广告的点击情况做出预测,预测用户是点击还是不点击. CTR预估和很多因素相关,比如历史点击率.广告位置.时间.用户等. CTR预估模型就是综合考虑各种因素.特征,在大量历 ...