WEB网站服务器部署
网页类型
静态网页
HTML超文本协议语言,html.htmls等
动态网页
类似脚本语言,根据传送参数不同,返回结果均不相同
.asp/.php/java(jsp).jsp/Python(Django模块).wsgi/
HTTP – 超文本传输协议版本
http/0.9 仅纯文本传输
http/1.0 MIME机制,多用途互联网邮件扩展
http/1.1 无状态连接(增强缓存机制管理)
@startuml
(Linux)
note right of (Linux)
【httpd】【Tomcat】【Nginx】【Apache】
---- 基于linux平台架构服务
end note
@enduml
@startuml
(Windows)
note right of (Windows)
【IIS】【Lighthttp】【 -- 】【 -- 】
---- 基于Windows平台架构服务
end note
@enduml
tab``tab
键显示结果# apt install apache
apache2 apache2-dbg apache2-ssl-dev apache2-utils apachetop
apache2-bin apache2-dev apache2-suexec-custom apachedex
apache2-data apache2-doc
apache2-suexec-pristine apacheds
# apt install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
# systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Wed 2019-07-03 11:37:04 CST; 4min 0s ago
Main PID: 24538 (apache2)
Tasks: 6 (limit: 1110)
CGroup: /system.slice/apache2.service
├─24538 /usr/sbin/apache2 -k start
├─24624 /usr/sbin/apache2 -k start
├─24625 /usr/sbin/apache2 -k start
├─24626 /usr/sbin/apache2 -k start
├─24627 /usr/sbin/apache2 -k start
└─24628 /usr/sbin/apache2 -k start
Jul 03 11:37:04 nasa systemd[1]: Starting The Apache HTTP Server...
Jul 03 11:37:04 nasa apachectl[24521]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 17
Jul 03 11:37:04 nasa systemd[1]: Started The Apache HTTP Server.
#/etc/init.d/apache2 start //启动Apache服务
#/etc/init.d/apache2 stop //停止Apache服务
#/etc/init.d/apache2 restart //重启Apache服务
# service enable httpd //CentOS7需要此命令设置开机自启
###Apache2修改网站根目录及默认网页
######我们来试着修改web服务器的配置,让我们可以在自己搭建的web服务器上访问到自己规定的数据:
#vim /etc/apache2/sites-available/000-default.conf
修改000-default.conf中的DocumentRoot /var/www/如下: ServerAdmin webmaster@localhost DocumentRoot /var/www/html // 一般我们默认为这个作为网站的根目录
#sudo apache2ctl -k restart
在Unbuntu中重启Apache服务器出现错误: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1.等等。 解决方法:#sudo vim /etc/apache2/apache2.conf 最后加入一句: ServerName localhost:80
#echo 'ServerName localhost:80'>>/etc/apache2/apache2.conf
######注意:>> 是追加
echo '修改成你要增加的内容'>/etc/apache2/apache2.conf
######注意:> 是删除原有内容,仅添加所输入命令! 注意区分!!!
vim /etc/apache2/mods-available/dir.conf
原来是:
添加上想要的/wordpress就行啦~
经过测试,新建立test文件必须处于/var/www/html/test/才能有效执行Apache配置文件。
######Ubuntu中更改所有子文件和子目录所有者权限
Ubuntu中有两个修改命令可以用到,「change mode」&「change owner」
即chmod以及chown,其中可以用递归参数-R来实现更改所有子文件和子目录的权限。
#####1、利用chmod修改权限:
对Document/目录下的所有子文件与子目录执行相同的权限变更:
# chmod -R 700 Document/
例:对/opt/Oracle/目录下的所有文件与子目录执行相同的权限变更:
# chmod -R 700 /opt/oracle/
-R参数是递归 处理目录下的所有文件以及子文件夹
700是变更后的权限表示(只有所有者有读和写以及执行的权限)
/opt/oracle/ 是需要执行的目录
#####2、利用chown改变所有者:
对Document/目录下的所有文件与子目录执行相同的所有者变更,修改所有者为users用户组的username用户
# chown -R username:users Document/
例:对 /opt/oracle/ 目录下的所有文件与子目录执行相同的所有者变更,使所有者修改为oinstall用户组的oracle用户
chown -R oracle:oinstall /opt/oracle/
####创建检查PHP解析信息文件
# touch /var/www/html/te/phpinfo.php
# vim /var/www/html/te/phpinfo.php
@startuml
note right of phpinfo.php #aqua
vim /var/www/html/te/phpinfo.php
touch文件内容
end note
ref over phpinfo.php
end ref
@enduml
# php -v ///显示php版本信息
PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
# apt install php7.2 /// 安装php解析程序
root@ubuntu:/etc/apt# apt install php7.2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libllvm7
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
libapache2-mod-php7.2
Suggested packages:
php-pear
The following NEW packages will be installed:
libapache2-mod-php7.2 php7.2
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,360 kB of archives.
After this operation, 4,879 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 libapache2-mod-php7.2 amd64 7.2.19-0ubuntu0.18.04.1 [1,350 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 php7.2 all 7.2.19-0ubuntu0.18.04.1 [9,244 B]
Fetched 1,360 kB in 0s (4,700 kB/s)
Selecting previously unselected package libapache2-mod-php7.2.
(Reading database ... 170373 files and directories currently installed.)
Preparing to unpack .../libapache2-mod-php7.2_7.2.19-0ubuntu0.18.04.1_amd64.deb ...
Unpacking libapache2-mod-php7.2 (7.2.19-0ubuntu0.18.04.1) ...
Selecting previously unselected package php7.2.
Preparing to unpack .../php7.2_7.2.19-0ubuntu0.18.04.1_all.deb ...
Unpacking php7.2 (7.2.19-0ubuntu0.18.04.1) ...
Setting up libapache2-mod-php7.2 (7.2.19-0ubuntu0.18.04.1) ...
Creating config file /etc/php/7.2/apache2/php.ini with new version
# vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe
# apt update /// 重新更新安装源信息库
# apt upgrade /// 检查是否有新版,且升级至最新版
# scp /etc/yum/repos.d/ubunt.repo [email protected]:/etc/yum/repos.d/
///在另一台配置好的安装原机器上,复制repos.d文件至目标机器
#####检查mysql状态
# systemctl status mysql
# apt install netstat-tools //安装netstat工具
# netstat -tap |grep mysql
tcp 0 0 localhost.localdo:mysql 0.0.0.0:* LISTEN 2220/mysqld
# sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
注:有的可能在 /etc/mysql/my.cnf这里面因为看好多都说在这里面,但是看配置文件就知道了,里面没东西,又引入的其他的文件;
找到bind-address = 127.0.0.1
bind-address = 127.0.0.1 修改为(注释掉)
#bind-address = 127.0.0.1
# systemctl restart mysql
# sudo ufw allow 3306
# netstat -ano |grep 3306
tcp6 0 0 :::3306 :::* LISTEN off (0.00/0/0)
######登录MYSQL数据库
1.没有用户的
# mysql -u root
2.有用户的
# mysql -u root -p
Enter password: //输入root用户密码
mysql> //成功登录mysql数据库
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu) Copyright (c) 2000, 2019, 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. --键入'help;'或'\h'获取帮助。键入'\c'以清除当前的输入语句。
mysql> status//输入查看状态命令 mysql Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using EditLine wrapper Connection id: 2 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/run/mysqld/mysqld.sock Uptime: 3 hours 58 min 16 sec Threads: 1 Questions: 5 Slow queries: 0 Opens: 105 Flush tables: 1 Open tables: 98 Queries per second avg: 0.000
mysql> \h
For information about MySQL products and services, visit:
http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
https://shop.mysql.com/
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
---- 清除当前输入语句
connect (\r) Reconnect to the server. Optional arguments are db and host.
---- 重新连接到服务器。可选参数为db和host
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
---- 向mysql服务器发送命令,垂直显示结果
exit (\q) Exit mysql. Same as quit.
---- 退出MySQL
go (\g) Send command to mysql server.
---- 向mysql服务器发送命令
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
---- 从服务器获取状态信息
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
---- 使用另一个数据库。以数据库名称为参数
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.
---- 清理会话上下文
For server side help, type 'help contents'
mysql> select version(); //显示mysql版本信息
+-------------------------+
| version() |
+-------------------------+
| 5.7.26-0ubuntu0.18.04.1 |
+-------------------------+
1 row in set (0.00 sec)
# cat /etc/mysql/debian.cnf //查看配置文件内容
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = QVn29fsf2Yvp1J // 经过加密的字符
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = QVm29YvdMp321J // 经过加密的字符
socket = /var/run/mysqld/mysqld.sock
sudo apt install phpmyadmin
# apt remove phpmyadmin
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';
将其注释掉并改成你的数据库用户和密码,保存
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = '123456';
刷新或重新打开phpmyadmin
/* Optional: User for advanced features */
$cfg['Servers'][$i]['controluser'] = $dbuser;
$cfg['Servers'][$i]['controlpass'] = $dbpass;
// $cfg['Servers'][$i]['controlport'] = '';
$cfg['Servers'][$i]['controluser'] = '更改为你需要登录的用户';
$cfg['Servers'][$i]['controlpass'] = '用户登录的密码';
解决问题关键方法
mysql> CREATE USER 'lmphp'@'%' IDENTIFIED BY '更改成需要设置的密码';
////创建新用户lmphp,密码为TTUEHD
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'lmphp'@'%' WITH GRANT OPTION;
////给予lmphp最大管理权限
Query OK, 0 rows affected (0.00 sec)