手动安装LAMP环境的步骤流程

LAMP架构:

Linux+Apache+Mysql+PHP

httpd # web服务器
mariadb-server #mysql数据库
mariadb # mysql服务器linux下客户端
php #php相关文件
php-mysql #??? #php程序连接mysql使用的模块

官方网站:
http://www.mysql.com/
http://dev.mysql.com/downloads/mysql/
CentOS 7.0中,已经使用MariaDB替代了MySQL数据库,原因你懂的,MYSQL被Oracle收购以后,前景堪忧,所以MYSQL兄弟MariaDB就出来了,继续开源事业。

MySQL服务概述:
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司。
MySQL是最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS(Relational Database Management System:关系数据库管理系统)应用软件之一。

MySQL是一种关联数据库管理系统,关联数据库将数据保存在丌同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。

MySQL所使用的SQL语言是用于访问数据库最常用标准化语言。MySQL软件采用了双授权政策,它分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择MySQL作为网站数据库。由于其社区版的性能卓越,搭配PHP和Apache可组成良好的开发环境。

双授权政策:开放源代码版本和商业版本。
例如:很多公司出售应用软件,例如Microsoft、Apple和Oracle;
如Red Hat和IBM,则通过为其开放源代码软件提供销售支援、托管戒咨询等服务来进行赚钱。但鲜为人知的是,企业可以透过开放源代码发布仕们的软件,也可以同时销售该软件的商业版本。

服务安装

安装需要的软件包

[root@localhost ~]# yum -y install httpd mariadb-server mariadb php php-mysql

查看某个命令由哪个包安装

[root@localhost ~]# rpm -qf `which mysql`
mariadb-5.5.64-1.el7.x86_64

查看apache版本:

[root@localhost ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Aug  8 2019 11:41:18
[root@localhost ~]# mysql -V
mysql  Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1

启动服务

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

当apache启动较慢的时候可以修改一下配置文件
在这里插入图片描述
将ServerName 的注释去掉,可以写成真实的域名,或者写成localhost都可以。

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf 
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

查看运行服务的端口

[root@localhost ~]# netstat -lunt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:25                  :::*                    LISTEN     
udp        0      0 0.0.0.0:68              0.0.0.0:*                          
udp        0      0 127.0.0.1:323           0.0.0.0:*                          
udp6       0      0 ::1:323                 :::*            

查看服务有在正常运行,却无法访问,请查看防火墙firewalld

MySQL安全配置向导
安装完mysql-server 会提示可以运行mysql_secure_installation。运行mysql_secure_installation会执行几个设置:
a)为root用户设置密码
b)删除匿名账号
c)取消root用户远程登录
d)删除test库和对test库的访问权限
e)刷新授权表使修改生效
通过这几项的设置能够提高mysql库的安全。建议生产环境中mysql安装这完成后一定要运行一次mysql_secure_installation,详细步骤请参看下面的命令:

[root@localhost ~]# 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):   #请回车开始设置mysql的安全向导
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              #设置root密码,回车默认选择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]    #是否移除匿名用户
 ... 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]     #是否禁止root远程登录,root用户允许本地登录即可,允许远程登录太危险
 ... 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]   #移除test数据库
 - 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!    

登录mysql

[root@localhost ~]# mysql -uroot -p123456   #登录
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.64-MariaDB MariaDB Server

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

MariaDB [(none)]>     #[(none)]表示当前所在位置
MariaDB [(none)]> use mysql;    #进到mysql库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> show tables;     #查看mysql库的表
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

MariaDB [mysql]> 

测试php是否安装成功
进入到网站的根目录

[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ll
总用量 0
[root@localhost html]# pwd
/var/www/html

写一个php测试页面

[root@localhost html]# cat index.php 
<?php
	phpinfo();
?>
[root@localhost html]# systemctl  restart httpd   #重启apache服务

在浏览器输入IP,访问,能访问就说明php.已经安装成功
在这里插入图片描述

ucenter下载

https://addon.dismall.com/
http://download.comsenz.com/UCen … r_1.6.0_SC_UTF8.zip #后台管理

上传至服务器

[root@localhost ~]# ll
总用量 1176
-rw-------. 1 root root   1201 10月 21 01:15 anaconda-ks.cfg
-rw-r--r--. 1 root root 594363 10月 21 02:30 UCenter_1.6.0_SC_GBK.zip
-rw-r--r--. 1 root root 599301 10月 21 02:30 UCenter_1.6.0_SC_UTF8.zip

创建一个目录,解压

[root@localhost ~]# mkdir  ucadmin
[root@localhost ~]# mkdir  /var/www/html/ucadmin
[root@localhost ~]# unzip UCenter_1.6.0_SC_UTF8.zip
[root@localhost ~]# mv upload/* ucadmin/
[root@localhost ~]# cd ucadmin/
[root@localhost ucadmin]# ll
总用量 28
-rw-r--r--. 1 root root 2704 5月  20 2011 admin.php
drwxr-xr-x. 2 root root   23 5月  20 2011 api
-rw-r--r--. 1 root root 1757 5月  20 2011 avatar.php
drwxr-xr-x. 3 root root  222 5月  20 2011 control
-rw-r--r--. 1 root root  280 5月  20 2011 crossdomain.xml
drwxr-xr-x. 8 root root   99 5月  20 2011 data
drwxr-xr-x. 5 root root 4096 5月  20 2011 images
-rw-r--r--. 1 root root 3075 5月  20 2011 index.php
drwxr-xr-x. 3 root root  147 5月  20 2011 install
drwxr-xr-x. 2 root root   94 5月  20 2011 js
drwxr-xr-x. 2 root root  187 5月  20 2011 lib
drwxr-xr-x. 2 root root 4096 5月  20 2011 model
drwxr-xr-x. 3 root root   23 5月  20 2011 plugin
drwxr-xr-x. 2 root root   25 5月  20 2011 release
-rw-r--r--. 1 root root   28 5月  20 2011 robots.txt
drwxr-xr-x. 3 root root   38 5月  20 2011 view
[root@localhost ucadmin]# cp -rp  ./* /var/www/html/ucadmin/

开始安装,后台管理,在浏览输入ip/ucadmin/install,
如:10.10.100.194/ucadmin/install
在这里插入图片描述
根据提示解决问题

[root@localhost ucadmin]# vim /etc/php.ini
short_open_tag = Off  改为On,保存退出,重启apache服务
[root@localhost ucadmin]# systemctl restart httpd

继续安装
在这里插入图片描述
一样,根据报错处理,解决问题
在这里插入图片描述
目录没有写的权限,根目录

[root@localhost ucadmin]# ll -d /var/www/html/ucadmin/
drwxr-xr-x. 13 root root 241 10月 21 02:43 /var/www/html/ucadmin/   #当前目录的属主是root,可以修改属主为apache
[root@localhost ucadmin]# chown -R apache.apache /var/www/html/ucadmin/

继续安装
在这里插入图片描述
下一步,填写数据库信息,设置管理密码
在这里插入图片描述
下一步
在这里插入图片描述
安装成功
在这里插入图片描述
在这里插入图片描述
能够登陆说明后台管理已经完成安装。

接下来安装前端管理
解压压缩包

[root@localhost html]# unzip UCenter_Home_2.0_SC_UTF8.zip

根据提示操作

在这里插入图片描述

[root@localhost html]# mv config.new.php config.php 
[root@localhost html]# systemctl restart httpd

下一步,文件权限问题,修改文件的属主
在这里插入图片描述

[root@localhost html]# chown -R apache.apache ./config.php 
[root@localhost html]# systemctl restart httpd

下一步,又是权限问题,同样的处理方法
在这里插入图片描述

[root@localhost html]# chown -R apache.apache ./data/ ./attachment/ ./uc_client/
[root@localhost html]# systemctl restart httpd

在这里插入图片描述
下一步
在这里插入图片描述
在这里插入图片描述
下一步,配置数据库信息
在这里插入图片描述
配置用户
在这里插入图片描述
配置好用户,密码,直接下一步
在这里插入图片描述
到这里就已经完成安装
在这里插入图片描述
在这里插入图片描述
到此lamp架构的个人博客就搭建完成

下面配置apache同一端口的多个虚拟主机
创建不同域名的虚拟主机

[root@localhost html]# vim /etc/httpd/conf/httpd.conf

在这里插入图片描述
查看这行是否被注释,把注释去掉

[root@localhost html]# vim /etc/httpd/conf.d/vhost.conf  #新增加一个配置文件

<VirtualHost *:80>
ServerAdmin admin@zoho.com                   #邮件地址
DocumentRoot /var/www/html/ucadmin      #根目录
ServerName  admin.test.com                  #域名
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@zoho.com
DocumentRoot /var/www/html/
ServerName  www.test.com
</VirtualHost>

[root@localhost html]# systemctl restart httpd

然后修改电脑的host文件
C:\Windows\System32\drivers\etc\HOST
10.10.100.194 admin.test.cm
10.10.100.194 www.test.com

保存

用域名访问,
备注,这样只能用于内网同网段的访问

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Rio520

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值