(1)配置概要:1、 172.18.17.7主机运行httpd+php服务(php为模块工作模式)配置两台虚拟主机:wordpress个人博客系统、PHPmyadmin远程控制MySQL
2、172.18.17.8主机运行mariadb服务(mysql)
(2)配置流程:首先配置172.18.17.7主机:http服务1、安装程序:[Root@johnson’s linux ~]# yum install httpd php php-mysql php-mbstring========================================================================================Package Arch Version Repository Size========================================================================================Installing:httpd x86_64 2.4.6-40.el7.CentOS base 2.7 Mphp x86_64 5.4.16-36.el7_1 base 1.4 Mphp-mbstring x86_64 5.4.16-36.el7_1 base 503 kphp-mysql x86_64 5.4.16-36.el7_1 base 99 kTransaction Summary=======================================================================================

httpd:提供web服务php:安装后自动编译为httpd的模块,用于处理动态资源php脚本php-mbstring:此程序包为phpMyAdmin远程控制mysql所必须的php-mysql:php驱动mysql的库文件程序包
2、服务配置
包都安装完成之后,进入下一步的配置阶段:
(1)添加虚拟主机:(基于FQDN)虚拟主机有三种配置方式:一种是基于不同ip,相同端口(80),二是相同IP不同端口,三是同一IP不同主机名(FQDN),不管何种配置方式,最后解析到的主机只有一台,但是在请求报文首部信息会有不同!以下,仅演示基于FQDN的配置方式
编辑:/etc/httpd/conf.d/vhost.conf文件[root@johnson’s linux ~]# vim /etc/httpd/conf.d/vhost.conf# 添加如下内容,基于FQDN的虚拟主机配置
Options:为个目录的选项,可以指定多个特性如:Index,启动资源索引,其作用是在用户在访问指定的URL不存在时,返回web资源索引,此选项非常危险,不建议启用,否则源码则会web源码暴露,后果很严重
访问权限设定:Require all Granted/deny, Granted表示允许,all表示所有,deny表示拒绝需要注意的是:CentOS7是默认拒绝所有主机访问DocumentRoot的资源,所以,配置虚拟主机必须要配置此先参数
(2)为虚拟主机创建配置文件中定义的资源目录并[root@johnson’s linux ~]# mkdir/www/{host,host2}/htdoc
(3)添加测试资源[root@johnson’s linux ~]# vim /www/host/htdoc/index.php# 前面这段是测试php与mysql连通性的PHP代码# 测试php是否正常工作的php代码
(4)配置httpd主配置文件编辑:/etc/httpd/conf/httpd.conf[root@johnson’s linux ~]# vim /etc/httpd/conf/httpd.conf# 找到 DocumentRoot “/var/www/html” ,#将其注释掉,一般使用虚拟机都要注释掉,避免冲突#DocumentRoot “/var/www/html”# 添加php主页索引DirectoryIndex index.php index.html # 将index.php添加在前头,这样就会默认访问此类资源索引# 取消 服务器 名称注释
(5)启动服务,测试是否正常# 检测配置文件语法有没有错误[root@johnson’s linux ~]# httpd -t# 语法无误启动服务[root@johnson’s linux ~]# systemctl start httpd.service
打开网页查看服务是否正常
http服务测试正常,php模块也能正常工作,但是,如你所见,mysql的连接是失败,因为我们还mysql的服务器还没有配置
下面关于的内容你可能也喜欢 :
(5)获取wordpress和phpmyadmin博主的是在局域网中ftp服务器中下载的wordpress配置:
# 下载并解压至/www/host/htdoc# cd 到wordpress目录 ,配置文件如下[root@johnson’s linux wordpress]# lsindex.php wp-blog-header.php wp-cron.php wp-Mail.phplicense.txt wp-comments-post.php wp-includes wp-settings.phpreadme.html wp-links-opml.php wp-signup.phpwp-activate.php wp-config-sample.php wp-load.php wp-trackback.phpwp-admin wp-content wp-login.php xmlrpc.php# 复制配置文件以上的 wp-config-sample.php 为 wp-config.php[root@johnson’s linux wordpress]# cp wp-config-sample.php wp-config.php# 编辑配置文件[root@johnson’s linux wordpress]# vim wp-config.php// ** MySQL 设置 – 具体信息来自您正在使用的主机 ** ///** WordPress数据库的名称 */define(‘DB_NAME’, ‘wpdb’); # 此填写mysql所要授权数据库的名字(后面会配置)/** MySQL数据库用户名 */define(‘DB_USER’, ‘wpuser’); # 填写数据库的用户名/** MySQL数据库密码 */define(‘DB_PASSWORD’, ‘wppasswd’); # 填写数据的密码/** MySQL主机 */define(‘DB_HOST’, ‘172.18.17.8’); # 填写mysql主机的ip/** 创建数据表时默认的文字编码 */define(‘DB_CHARSET’, ‘utf8’);/** 数据库整理类型。如不确定请勿更改 */define(‘DB_COLLATE’, ”);
phpmyadmin配置:1234567891011121314151617181920212223242526272829303132 # 将包下载并解压至/www/host2/htdoc# cd 到 文件目录# 创建符号连接[root@johnson’s linux htdoc]# ln -s phpMyAdmin-4.4.14.1-all-languages myadmin[root@johnson’s linux htdoc]# lsindex.php phpMyAdmin-4.4.14.1-all-languagesmyadmin phpMyAdmin-4.4.14.1-all-languages.zip#cd 至myadmin 目录里面,修改配置文件[root@johnson’s linux htdoc]# cp config.sample.inc.php config.inc.php#编辑配置文件[root@johnson’s linux htdoc]# vim config.inc.php$cfg[‘blowfish_secret’] = ‘o71mI9rimj6syc00fT3g’; /* YOU MUST FILL IN THIS FOR COOKIE auth! */#单引号填写随机密码,可使用openssl rand -base64 15(密码长度)生成/** Servers configuration*/$i = 0;/** First server*/$i++;/* Authentication type */$cfg[‘Servers’][$i][‘auth_type’] = ‘cookie’;/* Server parameters */$cfg[‘Servers’][$i][‘host’] = ‘172.18.17.8’; # 数据库主机ip$cfg[‘Servers’][$i][‘connect_type’] = ‘tcp’;$cfg[‘Servers’][$i][‘compress’] = false;$cfg[‘Servers’][$i][‘AllowNoPassword’] = false;
——————————————————————————–172.18.17.8主机配置:mysql服务
(1)yum安装程序1234567891011121314151617 [root@johnson’s linux ~]# yum install mariadb-server========================================================================================Installing:mariadb-server x86_64 1:5.5.44-2.el7.centos base 11 MInstalling for dependencies:mariadb x86_64 1:5.5.44-2.el7.centos base 8.9 Mperl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 kperl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 kperl-DBD-MySQL x86_64 4.023-5.el7 base 140 kperl-DBI x86_64 1.627-4.el7 base 802 kperl-IO-Compress noarch 2.061-2.el7 base 260 kperl-Net-Daemon noarch 0.48-5.el7 base 51 kperl-PlRPC noarch 0.2020-14.el7 base 36 kTransaction Summary========================================================================================
一大推依赖包,只要有yum在且yum源配置没有问题,可以轻松解决
(2)启动服务,执行安全安装操作12345678910111213141516171819202122232425262728293031323334353637383940414243444546 [root@johnson’s linux ~]# systemctl start mariadb# 查看监听端口,3306为mariaDB的默认监听端口[root@johnson’s linux ~]# ss -tnlstate Recv-Q Send-Q Local Address:Port Peer Address:PortLISTEN 0 50 *:3306 *:*LISTEN 0 128 *:22 *:*LISTEN 0 128 :::22 :::*执行安全安装操作[root@johnson’s linux ~]# mysql_secure_installationSetting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [Y/n] y # 设置管理员登陆秘密(此密码和linux系统的root没关系)New password:Re-enter new password: # 输入密码即可Password updated successfully!Reloading privilege tables..… Success!Remove anonymous users? [Y/n] y # 是否移除匿名用户(在执行安全安装之前不需要密码登陆)… Success! # 允许匿名登陆时很危险的,建议移除Disallow root login remotely? [Y/n] n # 是否不允许管理员账号远程登陆,一般情况下建议不允许… skipping.Remove test>
linux下安装GCC
# 解决搭建LAMP环境遇到编译错误# 请将Linux系统盘放入光驱# 以下为Shell脚本# 此脚本功能为安装gcc等解释器mkdir -p /root/isomount /dev/cdrom /root/isocd /root/iso/Server# C++rpm -ivh compat-gcc-34-c++ --force --nodepsrpm -ivh compat-libstdc++ --force --nodepsrpm -ivh compat-libstdc++ --force --nodepsrpm -ivh gcc-c++ --force --nodepsrpm -ivh gcc-objc++ --force --nodepsrpm -ivh libstdc++ --force --nodepsrpm -ivh libstdc++ --force --nodeps# gccrpm -ivh --force --nodepsrpm -ivh --force --nodepsrpm -ivh --force --nodepsrpm -ivh --force --nodepsrpm -ivh --force --nodepsrpm -ivh --force --nodepsrpm -ivh --force --nodepsrpm -ivh --force --nodepsrpm -ivh --force --nodeps# Crpm -ivh --force -nodepsrpm -ivh --force -nodepsrpm -ivh --force -nodepsrpm -ivh --force -nodepsrpm -ivh --force -nodepsrpm -ivh --force -nodepsrpm -ivh --force -nodepsrpm -ivh --force -nodepsrpm -ivh --force -nodeps
如何在 Ubuntu 12.04 Server 中安装图形用户界面
使用ubuntu server安装lamp主机非常的方便,只要在安装系统的步骤中选择就是了 。 但是很多时候我需要在图形界面下管理主机更加方便。 今天的教程就是教大家安装图形界面。 【方法一】首先你需要确定你的源文件中 /etc/apt/ 已经使用Universe和Multiverse库。 然后使用下面的命令来进行更新源列表和安装图形桌面。 sudo apt-get update sudo apt-get upgrade sudo apt-get install x-window-system-coresudo apt-get install gdm sudo apt-get install ubuntu-desktop【方法二】如果你只想安装必要的桌面管理软件而不想安装一些诸如 Evolution 和 OpenOffice 的不需要的应用软件,可使用下面的命令: sudo apt-get install --no-install-recommends ubuntu-desktop我执行此命令提示没有ubuntu-desktop【方法三】安装轻量级桌面 xfce 使用下面的命令: sudo apt-get install xubuntu-desktop【方法四】安装 KDE 桌面,使用下面的命令: sudo apt-get install kubuntu-desktop
弟弟因为车祸腿脚不是很方便,想让我弟弟学PHP要从哪里入手
首先对您弟弟的事情感到遗憾,
然后根据我个人的看法,对待这个问题。
自学,出来的高手,有,不过很少,走的弯路很多。
因为一个很简单的道理,从书上是很难体会和理解的。 必须有人教,去跟他详细解释。
毕竟写书的,他的思维角度不会跟着他所有的读者一样,他认为这个地方没必要讲,可能很多人都知道。 但是每个读者的基础都是不一样的。
所以建议送去培训机构学习。
独立PHP开发系统或设计网站
先学HTML,最基础的
网页设计又需要FLASH和PHOTOSHOP 做美化工作
学PHP,又要学数据库。
然后发现,什么都要学。 。 。
发表评论