#将yum安装的包缓冲到本地,然后制作本地local_yumvim /etc/yum.conf
#本机信息hostnameLAMP
ip192.168.42.10
#由于官网yum源下载慢,这里添加ali源yum clean all
rm -rf /etc/yum.repos.d/*.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed -i '/aliyuncs/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/aliyuncs/d' /etc/yum.repos.d/epel.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
#关闭selinux&firewalldsed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
#同步各个节点时间:yum -y install rdate
rdate -s time-a.nist.gov
echo rdate -s time-a.nist.gov >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
#添加EPEL repo来安装最新的phpMyAdmin如下:rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release
#MariaDB是MySQL开发人员Monty Widenius的MySQL分支。MariaDB与MySQL兼容,我选择在这里使用MariaDB而不是MySQL。运行这个命令来安装MariaDB和yum:yum -y install mariadb-server mariadb
#启动maridb 并设置开机启动systemctl start mariadb.service
systemctl enable mariadb.service
#设置maridb密码mysql_secure_installation[
root@server1
~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
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]
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]
... 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]
... 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]
- 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]
... 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!
#apache 2.4。Apache包已经提供,因此我们可以这样安装它:yum -y install httpd
#启动apache 并设置开机启动systemctl start httpd.service
systemctl enable httpd.service
#如果开启的防火墙 那么设置防火墙策略来允许firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
#测试apapche是否正常提供网页firefox 192.168.42.10
#安装php
#添加存储库rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
#安装yum - utils,因为我们需要yum -config- manager实用程序。
yum -y install yum-utils
安装php5.4yum -y install php
#安装PHP 7.0(可选)
#可以安装PHP 7.0和Apache PHP 7.0模块如下:yum-config-manager --enable remi-php70
yum -y install php php-opcache
#安装PHP 7.1(可选)
#如果您想使用PHP 7.1,请使用:yum-config-manager --enable remi-php71
yum -y install php php-opcache
#必须重新启动Apache来应用更改:systemctl restart httpd.service
#测试PHP /获取有关PHP安装的详细信息vim /var/www/html/info.php
phpinfo();
?
#查看测试页firefox http://192.168.42.10/info.php
#在PHP中获得MySQL支持
#为了在PHP中获得MySQL支持,我们可以安装php71w - MySQL包。安装其他PHP模块也是一个好主意,因为您可能需要它们用于您的应用程序。您可以搜索可用的PHP5模块:yum search php
#选择你需要的,然后安装:yum -y install php-mysql
#在接下来的步骤中,我将安装一些通用的PHP模块,这些模块是由CMS系统(如Wordpress、Joomla和Drupal)所要求的:yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel
#重启apache更改生效systemctl restart httpd.service
#现在重新加载http://192.168.42.10/info。在您的浏览器中,再向下滚动到模块部分。你现在应该在那里找到很多像curl这样的新模块。
#如果您不再需要php信息输出,那么出于安全原因删除该文件。rm /var/www/html/info.php
#phpMyAdmin是一个可以管理MySQL数据库的web界面。
#phpMyAdmin现在可以安装如下:yum -y install phpMyAdmin
#现在我们配置phpMyAdmin。我们更改Apache配置,以便phpMyAdmin不仅允许来自本地主机的连接vim /etc/httpd/conf.d/phpMyAdmin.conf
[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
AddDefaultCharset UTF-8
# Apache 2.4
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
Options none
AllowOverride Limit
Require all granted
[...]
#接下来,我们将phpMyAdmin中的身份验证更改为http:vim /etc/phpMyAdmin/config.inc.php
[...]
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?
[...]
#重启apache服务systemctl restart httpd.service
#访问http://192.168.42.10/phpmyadmin/下phpMyAdmin:firefox 192.168.42.10/phpmyadmin
#密码为root账号密码
#好了 到这里 LAMP (php7.1)的环境就搭建好了,下一篇,基于LAMP搭建owncloud开源云盘,有不懂得在评论区留言,看到第一时间回复,转载请注明出处,创作不易。