重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
1.Apache网站服务
2.MySQL服务
3.LAMP架构应用实例
专注于为中小企业提供网站建设、成都网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业禹城免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了数千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
1.源于A Patchy Server,著名的开源Web服务软件
2.1995年时,发布Apache服务程序的1.0版本
3.由Apache软件基金会(ASF) 负责维护
4.最新的名称为"Apache HTTP Server”
5.官方站点: http://httpd.apache.org/
1.开放源代码、跨平台应用
2.支持多种网页编程语言
3.模块化设计、运行稳定、良好的安全性
1.X:
1.目前最高版本是1.3,运行稳定
2.向下兼容性较好,但缺乏一些较新的功能
2.X:
1.目前最高版本是2.4
2.具有更多的功能特性
3.与1.X相比,配置管理风格存在较大差异
1.具有较大的自由度,功能可定制
2.可及时获得最新的软件版本
3.普遍适用于大多数Linux版本,便于移植使用
1.参考地址: http://httpd.apache.org/download.cgi
1.卸载httpd及相关依赖包
[root@www~]# rpm -e httpd --nodeps
2.源码编译及安装
[root@www ~]# tar zxf httpd-2.4.25.tar.gz -C /usr/src
[root@www ~]# cd /usr/src/httpd
[root@www httpd-2.4.25]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
[root@www httpd-2.4.25]# make && make install
[root@www ~]# Is /usr/local/httpd
bin cgi-bin error icons logs manual
build conf htdocs include man modules
[root@www ~]# In -S /usr/local/httpd/bin/* /usr/local/bin
[root@www ~]# Is -I /usr/local/bin/httpd /usr/local/bin/apachectl
Irwxrwxrwx 1 root root 30 5月10 06:20 /usr/local/bin/apachectl -> /usr/local/httpd/bin/apachectl
Irwxrwxrwx 1 root root 26 5月10 06:20 /usr/local/bin/httpd -> /usr/local/httpd/bin/httpd
1.通过chkconfig进行管理系统服务
2.通过systemctl进行管理系统服务
[root@www ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@www ~]# vim /etc/init.d/httpd
#!/bin/bash
#chkconfig: 35 85 21
#description: Startup script for the Apache HTTP Server
[root@www ~]# chkconfig --add httpd
[root@www ~]# chkconfig --list httpd
httpd 0:关 1:关 2:关 3:开 4:关 5:开 6:关
1.服务目录: /usr/local/httpd/
2.主配置文件: /usr/local/httpd/conf/httpd.conf
3.网页目录: /usr/local/httpd/htdocs/
4.服务脚本: /usr/local/httpd/bin/apachectl
5.执行程序: /usr/localhttpd/bin/httpd
6.访问日志: /usr/local/httpd/log/access log
7.错误日志: /usr/localhttpd/log/error log
1.确定网站名字、IP地址
2.配置并启动httpd服务
3.部署网页文档s
4.在客户机中访问Web站点
5.查看Web站点访问情况
ServerRoot "/usr/local/httpd"
Listen 80
User daemon
Group daemon
ServerAdmin webmaster@kgc.com
ServerName www.kqc.com
DocumentRoot"/usr/local/httpd/htdocs."
DirectoryIndex index.html index.php
ErrorLog logs/error log
LogLevel warn
1 CustomLog logs/access_ log
common
PidFile logs/httpd.pid
CharsetDefault UTF-8
Include conf/extra/httpd-default.conf
......
1.ServerRoot:服务目录
2.Listen:监听的IP地址、端口号
3.User:运行服务的用户身份
4.Group:运行服务的组身份
5.ServerAdmin:管理员邮箱
6.ServerName:网站服务器的域名
7.DocumentRoot:网页文档的根目录
8.DirectoryIndex:默认的索引页文件
9.ErrorLog:设置错误日志文件的路径
10.LogLevel:记录日志的级别,默认为warn
1.CustomLog:访问日志文件的位置
2.PidFile:保存httpd进程PID号的文件
3.AddDefaultCharset:设置站点中的网页默认使用的字符集编码
4.Timeout:网络连接超时,默认为300秒
5.KeepAlive:是否保持连接,可选On或Off
6.MaxKeepAliveRequests:每次连接最多请求文件数
7.KeepAlive' Timeout:保持连接状态时的超时时间
8.Include:需要包含进来的其他配置文件
1.确认没有使用RPM方式安装mysql-server、mysql ,
2.安装光盘自带的ncurses-devel包
3.安装cmake包
[root@www ~]# tar zxf cmake-2.8.6.tar.gz
[root@www ~]# cd cmake-2.8.6
[root@www cmake-2.8.6]# ./configure
[root@www cmake-2.8.6]# gmake && gmake install
[root@www ~]# groupadd mysql
[root@www ~ ]# useradd -M -S /sbin/nologin mysql -g mysql
[root@www ~]# tar zxf mysql-5.6.36.tar.gz -C /usr/src
[root@www ~]# cd /usr/src/mysql-5.6.36
[root@www mysql-5.6.36]# cmake -
DCMAKE INSTALL PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general ci -DWITH EXTRA CHARSETS=all
[root@www mysql-5 6.36]# make && make install
[root@www ~]# chown -R mysql:mysql /usr/local/mysql
[root@www mysql-5.6.36]# rm -rf 7etc/my.cnf
[root@www mysql-5.6.36]# cp support- files/my-default.cnf /etc/my.cnf
[root@www mysql-5.6.36]# /usr/local/mysql/scripts/mysql install db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
[root@www mysql-5.6.36]#echo"PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@www mysql-5.6.36]# . /etc/ profile
[root@www mysql-5.6.36]# cp support-files/mysql.server /etcfred/init.d/ mysqld
[root@www mysql-5.6.36]# chmod +X 7etc/rc.d/init.d/mysqld
[root@www mysql-5.6.36]# chkconfig --add mysqld
[root@www mysql-5.6.36]# service mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/www.err'.
SUCCESS!
[root@www mysql-5.6.36]# /etc/init.d/mysqld status
SUCCESS! MySQL running (41548)
[root@www mysql-5.6.36]# netstat -anpt | grep mysqld
tcp6 0 0..3306 ...* LISTEN 41 548/mysqld
[root@www mysql-5.6.36]# cp support-files/mysql.server /etcfred/init.d/ mysqld
[root@www mysql-5.6.36]# chmod +X 7etc/rc.d/init.d/mysqld
[root@www mysql-5.6.36]# chkconfig --add mysqld
mysql-u用户名_[-p]
提示符: mysql>
mysqladmin -u root _[-p] password 新密码
mysql> exit
1.目前最为成熟的一种企业网站应用模式,可提供动态Web站点应
用及开发环境
1.Linux、 Apache、 MySQL、 PHP/Perl/Python
1.成本低廉
2.可定制、易于开发
3.方便易用、安全和稳定
首先我们需要准备一台Linux主机,LAMP架构需要用到的压缩包(此处可在本人的百度网盘链接进行下载),还有最终我们准备搭建的bbs论坛的文件也在其中
百度网盘资源链接:https://pan.baidu.com/s/1dGbEwswQeej2qD_UTE-7rQ&shfl=sharepset
提取码:bjg6
右键文件夹,选择属性,点击共享,选择共享,下拉选项中选择Everyone,点击添加,再点击右下方的共享,点击完成就可以了,集体操作如下图:
[root@localhost ~]# smbclient -L //192.168.10.13/ //此处输入自己宿主机的IP地址
Enter SAMBA\root's password: //此处直接回车
OS=[Windows 10 Home China 18362] Server=[Windows 10 Home China 6.3]
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk 远程管理
C$ Disk 默认共享
D$ Disk 默认共享
IPC$ IPC 远程 IPC
LAMP-test Disk //此处可以看到共享出来的文件夹
Connection to 192.168.0.103 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
NetBIOS over TCP disabled -- no workgroup available
[root@localhost ~]# ls /mnt/ //此时我们查看挂载是空的
[root@localhost ~]# mount.cifs //192.168.0.103/LAMP-test /mnt/ //把共享的文件挂载到mnt目录下
Password for root@//192.168.0.103/LAMP-test: //此处直接回车
[root@localhost ~]# cd /mnt/ //进入mnt目录
[root@localhost mnt]# ls //此时查看详情就可以看到所有我们需要用到的压缩包了
apr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz
apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2
[root@localhost mnt]# yum install -y gcc gcc-c++ make pcre-devel expat-devel perl
//安装必要组件
[root@localhost mnt]# tar zxvf apr-1.6.2.tar.gz -C /opt/
[root@localhost mnt]# tar zxvf apr-util-1.6.0.tar.gz -C /opt/
[root@localhost mnt]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt/
//解压缩以上文件到opt目录下
[root@localhost mnt]# cd /opt/
[root@localhost opt]# ls
apr-1.6.2 apr-util-1.6.0 dis httpd-2.4.29 rh
[root@localhost opt]# mv apr-1.6.2/ httpd-2.4.29/srclib/apr
[root@localhost opt]# mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util
[root@localhost opt]# cd /opt/httpd-2.4.29/
[root@localhost httpd-2.4.29]# ls
ABOUT_APACHE buildconf httpd.dsp libhttpd.mak README.cmake
acinclude.m4 CHANGES httpd.mak LICENSE README.platforms
Apache-apr2.dsw CMakeLists.txt httpd.spec Makefile.in ROADMAP
Apache.dsw config.layout include Makefile.win server
apache_probes.d configure INSTALL modules srclib
ap.d configure.in InstallBin.dsp NOTICE support
build docs LAYOUT NWGNUmakefile test
BuildAll.dsp emacs-style libhttpd.dep os VERSIONING
BuildBin.dsp httpd.dep libhttpd.dsp README
[root@localhost httpd-2.4.29]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
//安装必要组件
[root@localhost httpd-2.4.29]# make
[root@localhost httpd-2.4.29]# make install
[root@localhost httpd-2.4.29]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
cp:是否覆盖"/etc/init.d/httpd"? yes
[root@localhost httpd-2.4.29]# vim /etc/init.d/httpd
#!/bin/sh
# chkconfig: 35 85 21
# description: Apache is a World Wide Web server
//在#!/bin/sh下行插入这两行内容,按Esc退出插入模式,按:wq保存退出
[root@localhost httpd-2.4.29]# chkconfig --add httpd
[root@localhost httpd-2.4.29]# vim /usr/local/httpd/conf/httpd.conf
输入/Server,找到:ServerName www.example.com:80 把前面的#号注释删除
输入/Listen,查找80端口监听,并开启监听本机的80端口:Listen 192.168.56.128: 80
按Esc退出插入模式,按:wq保存退出
[root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/conf/httpd.conf /etc/
[root@localhost httpd-2.4.29]# ln -s /usr/local/httpd/bin/* /usr/local/bin/
//以上操作为创建软链接
[root@localhost httpd-2.4.29]# systemctl stop firewalld.service
[root@localhost httpd-2.4.29]# setenforce 0
//关闭防火墙及增强型安全功能
[root@localhost httpd-2.4.29]# httpd -t
Syntax OK
[root@localhost httpd-2.4.29]# service httpd start
[root@localhost httpd-2.4.29]# netstat -ntuap | grep httpd
tcp 0 0 192.168.56.128:80 0.0.0.0:* LISTEN 22697/httpd
[root@localhost httpd-2.4.29]# cd ~
[root@localhost ~]# yum install -y ncurses-devel autoconf cmake
//安装必须组件
[root@localhost ~]# tar zxvf mysql-5.6.26.tar.gz -C /opt/
[root@localhost ~]# cd /opt/mysql-5.6.26/
[root@localhost mysql-5.6.26]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DSYSCONFDIR=/etc/ -DMYSQL_DATADIR=/home/mysql/ -DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock
//安装必须组件
[root@localhost mysql-5.6.26]# make
[root@localhost mysql-5.6.26]# make install
[root@localhost mysql-5.6.26]# cp support-files/my-default.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? yes
[root@localhost mysql-5.6.26]# cp support-files/mysql.server /etc/init.d/mysqld
cp:是否覆盖"/etc/init.d/mysqld"? yes
[root@localhost mysql-5.6.26]# cd /etc/init.d
[root@localhost init.d]# ls
functions httpd mysqld netconsole network README
[root@localhost init.d]# chmod 755 mysqld
[root@localhost init.d]# ls -ln
总用量 56
-rw-r--r--. 1 0 0 17500 5月 3 2017 functions
-rwxr-xr-x. 1 0 0 3502 10月 18 22:45 httpd
-rwxr-xr-x. 1 0 0 10870 10月 18 23:20 mysqld
-rwxr-xr-x. 1 0 0 4334 5月 3 2017 netconsole
-rwxr-xr-x. 1 0 0 7293 5月 3 2017 network
-rw-r--r--. 1 0 0 1160 8月 5 2017 README
[root@localhost init.d]# chkconfig --add /etc/init.d/mysqld
[root@localhost init.d]# chkconfig --level 235 mysqld on
[root@localhost init.d]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@localhost init.d]# source /etc/profile
[root@localhost init.d]# echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin:/usr/local/mysql/bin:/root/bin:/usr/local/mysql/bin
[root@localhost init.d]# useradd -s /sbin/nologin mysql
//创建用户“mysql”
[root@localhost init.d]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost init.d]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --ldata=/var/lib/mysql --basedir=/usr/local/mysql --datadir=/home/mysql
//安装必要组件
[root@localhost init.d]# vim /etc/init.d/mysqld
[root@localhost init.d]# service mysqld start
Starting MySQL SUCCESS!
[root@localhost init.d]# netstat -ntuap | grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 1310/mysqld
[root@localhost init.d]# mysqladmin -u root -p password "abc123" //给root账号设置新密码
[root@localhost init.d]# cd ~
[root@localhost ~]# yum install -y gd libpng libpng-devel pcre pcre-devel libxml2-devel libjpeg-devel
[root@localhost ~]# tar jxvf php-5.6.11.tar.bz2 -C /opt/
[root@localhost ~]# cd /opt/php-5.6.11/
[root@localhost php-5.6.11]# ./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring
[root@localhost php-5.6.11]# make
[root@localhost php-5.6.11]# make install
[root@localhost php-5.6.11]# cp php.ini-development /usr/local/php5/php.ini
cp:是否覆盖"/usr/local/php5/php.ini"? yes
[root@localhost php-5.6.11]# ln -s /usr/local/php5/bin/* /usr/local/bin/
[root@localhost php-5.6.11]# vim /etc/httpd.conf
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
//在上两行下面插入下面两行内容
DirectoryIndex index.php index.html
//在DirectoryIndex和index.html中间添加index.php
//按Esc退出插入模式,按:wq保存退出
[root@localhost php-5.6.11]# vim /usr/local/httpd/htdocs/index.php
//写入以上内容,按Esc退出插入模式,按:wq保存退出
[root@localhost php-5.6.11]# service httpd restart
进入网页进行测试(此处IP地址填写的是安装服务的CentOS 7的IP地址):http://192.168.56.128/index.php,如果配置成功因该出现如下界面:
[root@localhost php-5.6.11]# cd ~
[root@localhost ~]# unzip Discuz_X2.5_SC_UTF8.zip -d /opt/Discuz
[root@localhost ~]#cp -r /opt/Discuz/upload/ /usr/local/httpd/htdocs/bbs
[root@localhost ~]#cd /usr/local/httpd/htdocs/bbs/
[root@localhost bbs]# chown -R daemon ./config/
[root@localhost bbs]# chown -R daemon ./data/
[root@localhost bbs]# chown -R daemon ./uc_client/data/cache/
[root@localhost bbs]# chown -R daemon ./uc_server/data/
[root@localhost bbs]# mysql -uroot -pabc123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zzz;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on bbs.* to 'zzz'@'localhost' identified by '123123';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on bbs.* to 'zzz'@'%' identified by '123123';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
数据服务器:192.168.56.128(此处输入自己的虚拟机IP)
数据库名:bbs
数据库用户名:bbsuser(此处可在之前的命令中自行定义)
数据库密码:admin123(此处可在之前的命令中自行定义)
管理员账号:admin(默认)
密码:123123(可自行输入)