CentOS 7 环境开发PHP项目常常会用到的指令
2017-07-08 18:27
537 查看
[root@corp ~]# tee /etc/selinux/config <<-'EOF'
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
EOF
或者
[root@corp ~]# sed -i -- 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@corp ~]# set SELINUX=disabled
[root@corp ~]# setenforce 0 ##不重启立刻关闭 SELINUX,设置 /var/log/mariadb 的权限为755 其文件夹内文件权限全部666,还报告mariadb-log-bin.index not found (Errcode: 13), 办法是设置文件夹mariadb与文件所属组chown -R mysql:mysql /var/log/mariadb &&
chown -R mysql:mysql /var/log/mariadb/*
[root@corp ~]# sestatus -v
SELinux status: disabled
[root@corp ~]#
[root@corp ~]# systemctl stop firewalld
[root@corp ~]# systemctl disable firewalld
[root@corp ~]# echo "192.168.10.20 corp.contoso.org" >> /etc/hosts
[root@corp ~]# echo "192.168.10.10 contoso.org" >> /etc/hosts
[root@corp ~]# echo `export PATH=$PATH:/usr/local/zend/bin` >> /etc/profile # 这是Zend Server 服务器下php指令全局性配置方法 可以不用它
[root@corp ~]# source /etc/profile
[root@corp ~]# tail -5 /etc/profile
unset i
unset -f pathmunge
export PATH=$PATH:/usr/local/zend/bin ## 配置PHP指令全局执行,例如执行指令 php -m
[root@corp ~]# more /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 corp.contoso.org
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.20 corp.contoso.org
192.168.10.10 contoso.org
[root@corp ~]# systemctl restart network # 不启动系统让hosts文件修改即刻生效
提示所有可用扩展软件包在此位置:http://rpms.remirepo.net/enterprise/7/php71/x86_64/
http://rpms.remirepo.net/wizard/ 安装PHP7.1 需要打开此链接
Operating system: CentOS 7
PHP version: 7.1.7(active support until Dec 2018)
Type of installation: Single version
Command to install the EPEL repository configuration package:
[root@corp ~]$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Command to install the Remi repository configuration package:
[root@corp ~]$ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Command to install the yum-utils package (for the yum-config-manager command):
[root@corp ~]$ sudo yum install yum-utils
Command to enable the repository:
[root@corp ~]$ sudo yum-config-manager --enable remi-php71
Command to upgrade (the repository only provides PHP):
[root@corp ~]$ sudo yum update
Command to install additional packages:
[root@corp ~]$ sudo yum --enablerepo=remi-php71,remi,epel -y install php php-devel php-mysql php-fpm php-pecl-xdebug php-gd php-intl php-freetype php-mcrypt php-mbstring
php-pecl-memcached php-pecl-redis php-pecl-swoole
[root@corp ~]$ sudo [b]yum[/b]--enablerepo=remi-php71,remi,epel -y install php-pecl-mongo
[root@corp ~]$ sudo [b]yum--enablerepo=remi-php71,remi,epel -y install php-simplexml php-xml php-zip[/b]
[root@corp ~]$ sudo [b]yum--enablerepo=remi-php71,remi,epel -y install php-gd php-freetype php-pecl-jpeg[/b]
// pChart
[root@corp ~]$ sudo [b]yum--enablerepo=remi-php71,remi,epel -y install php-pecl-geoip geoip[/b]
yum info geoip //查官网地址
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel -y install php-pecl-apcu
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel -y install nodejs npm
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel -y install php-intl
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel -y install php-pecl-zip
[root@corp ~]$ sudo [b]yum--enablerepo=remi-php71,remi,epel -y remove mariadb mariadb-server[/b]删掉5.5系列的
目前最新版才5.5.48
Command to check the installed version and available extensions:
[root@corp ~]$ php --version
[root@corp ~]$ php --modules
ls /etc/yum.repos.d
cat /etc/yum.repos.d/remi.repo
ls /etc/pki/rpm-gpg
https://www.digitalocean.com/community/tutorials/how-to-create-an-ssl-certificate-on-apache-for-centos-7
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel install mod_ssl
[root@corp ~]$ sudo timedatectl status
Local time: Mon 2015-12-14 20:28:54 CST
Universal time: Mon 2015-12-14 12:28:54 UTC
RTC time: Mon 2015-12-14 12:28:54
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@corp ~]# su -
[root@corp ~]# vi /etc/php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = PRC
[root@corp ~]# ls /etc/httpd/conf.d/
autoindex.conf php.conf README userdir.conf welcome.conf
[root@corp ~]# cat /etc/httpd/conf.d/ssl.conf
[root@corp ~]# ls /etc/httpd/
conf conf.d conf.modules.d logs modules run
[root@corp ~]# mkdir /etc/httpd/ssl
[root@corp ~]# vi /etc/redis.conf
bind 192.168.10.30 127.0.0.1
[root@corp ~]# cat /etc/php-fpm.conf
[root@corp ~]# cat /etc/php-fpm.d/www.conf // 查看默认端口9000 listen = 127.0.0.1:9000
[root@corp ~]$ sudo
systemctl enable php-fpm.service
[root@corp ~]$ sudo systemctl enable httpd.service
[root@corp ~]$ sudo systemctl enable memcached.service
[root@corp ~]$ sudo systemctl enable redis.service
[root@corp ~]$ sudo systemctl restart php-fpm.service
[root@corp ~]$ sudo systemctl restart httpd.service
[root@corp ~]$ sudo systemctl restart memcached.service
[root@corp ~]$ sudo systemctl restart redis.service
[root@corp ~]$ sudo systemctl reboot
[root@corp ~]$ sudo reboot
[root@corp ~]$ sudo poweroff
[root@corp ~]# cat > /etc/php.d/15-xdebug.ini
; Enable xdebug extension module
zend_extension=xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
; see http://xdebug.org/docs/all_settings
Linux下Apache网站目录读写权限的设置
我们httpd服务器运行的用户和用户组是apache,网站用户myth(登录CentOS 7系统的开发用户名),网站根目录是/home/myth/www
第1步:
我们首先设定网站目录和文件的所有者和所有组为myth,apache,如下命令:
[myth@corp ~]$ mkdir www
[myth@corp ~]$ ll
total 0
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Desktop
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Documents
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Downloads
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Music
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Pictures
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Public
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Templates
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Videos
drwxrwxr-x 2 myth myth 6 Jul 31 09:39 www
[myth@corp ~]$ pwd
/home/myth
[myth@corp ~]$ su -
Password:
[root@corp ~]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 17564 root 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17565 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17566 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17568 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17570 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17571 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 18759 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
[root@corp ~]# pwd
/root
[root@corp ~]# [b]chmod 755 -R /home[b]/myth [/b][/b]##
find /home -type d -exec chmod 755 {} \;[b][/b]
[root@corp ~]# exit
logout
[myth@corp ~]$ pwd
/home/myth
[myth@corp ~]$ ll /home
total 4
drwxr-xr-x. 16 myth myth 4096 Jul 31 18:34 myth
[myth@corp ~]$
[myth@corp ~]$ ll /home/myth
total 0
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Desktop
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Documents
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Download
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Music
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Pictures
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Public
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Templates
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Videos
drwxr-xr-x 3 myth myth 19 Jul 31 19:04 www
[myth@corp ~]$
全局[b]性composer命令安装(myth和www权限设置后下面安装composer才不会出现写文件没有权限)[/b]
https://pkg.phpcomposer.com/
打开命令行并依次执行下列命令安装最新版本的 Composer:
[root@corp ~]$ sudo
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
[root@corp ~]$ sudo php composer-setup.php
[root@corp ~]$ sudo php -r "unlink('composer-setup.php');"
[root@corp ~]$ sudo mv composer.phar /usr/local/bin/composer
[root@corp ~]$ sudo composer config -g repo.packagist composer https://packagist.phpcomposer.com
不要忘了经常执行 composer selfupdate 以保持 Composer 一直是最新版本
第2步:ThinkPHP5.0安装
[myth@corp ~]$
cd /home/myth/www && composer create-project topthink/think think --prefer-dist ## 克隆下载应用项目think,官网这里用的是tp5 ------ 对应最后那个think;隐含克隆核心框架framework自动更名为thinkphp
第3步:
设置网站目录权限为750,750是myth用户对目录拥有读写执行的权限,这样myth用户
可以在任何目录下创建文件,用户组有有读执行权限,这样才能进入目录,其它用户没有任何权限。
[myth@corp ~]$ cd /home/myth/www
[myth@corp ~]$ find /home/myth/www -type d -exec ls -l {} \; ## 注释 上一行 cd /home/myth/www命令可以不用执行,因为指定了搜索目录/home/myth/www 提前查询think项目没被修改时所有子目录和文件的默认权限
[myth@corp ~]$ chown -R myth:myth /home/myth/www
[myth@corp ~]$ find /home/myth/www -type d -exec chmod 775 {} \; ## 注释说明 {} 表示查询结果 内容是/home/myth/www目录下的所有子目录,设置每个子目录的权限为750,开发时需要775
第4步:
设置网站文件权限为640,640指只有myth用户对网站文件有更改的权限,http服务器只
有读取文件的权限,无法更改文件,其它用户无任何权限。
[myth@corp ~]$ [b]find /home/myth/www -not -type d -exec chmod 664 {} \; [/b]##
设置每个子目录下所有文件的权限为640,开发时需要664
第5步:
针对个别目录设置可写权限。比如网站的一些缓存目录就需要给http服务有写入权限。
例如discuz x2的/data/目录就必须要写入权限。
find data -type d -exec chmod 770 {} \;
清空日志文件的内容: [myth@corp ~]$ rm -rf /home/myth/log/httpd && mkdir -p /home/myth/log/httpd
##清空日志可直接删掉日志文件
[root@corp ~]$ cat /dev/null > /home/myth/log/httpd/user-corp-contoso-error_log && cat /dev/null > /home/myth/log/httpd/user-corp-contoso-access_log
[root@corp ~]#$ cat /dev/null > /home/myth/log/httpd/corp-contoso-error_log && cat /dev/null > /home/myth/log/httpd/corp-contoso-access_log
[root@corp ~]#$ cat /dev/null > /home/myth/log/httpd/contoso-error_log && cat /dev/null > /home/myth/log/httpd/contoso-access_log
实时跟踪日志内容:
[root@corp ~]$tail -f[b]/home/myth/log/httpd/user-corp-contoso-error_log
[/b][root@corp ~]$tail -f[b]/home/myth/log/httpd/user-corp-contoso-access_log[/b]
[root@corp ~]$tail -f[b]/home/myth/log/httpd/corp-contoso-error_log
[/b][root@corp ~]$tail -f[b]/home/myth/log/httpd/corp-contoso-access_log[/b]
[root@corp ~]$tail -f[b]/home/myth/log/httpd/contoso-error_log
[/b][root@corp ~]$ tail -f[b]/home/myth/log/httpd/contoso-access_log[/b]
[b]在Cent OS 7.x系统上配置虚拟主机(root账户下):[/b]
[root@contoso ~]#[b] cat > /etc/httpd/conf.d/httpd-vhosts.conf ## 配置虚拟主
<Directory "/var/www/html/SPRabbitMQ">
Options +Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin zhengzizhi@126.com
DocumentRoot "/var/www/html/SPRabbitMQ/app"
ServerName contoso.com
ServerAlias contoso.com
ErrorLog "/var/log/httpd/contoso-error_log"
CustomLog "/var/log/httpd/contoso-access_log" common
</VirtualHost>
[/b]
在Cent OS 7.x系统上配置虚拟主机(非root账户下):
#注意:日志文件的目录需要提前创建好,如果发现No such file or directory: AH02291: Cannot access directory '/home/myth/log/httpd/' for error log of vhost 这样的错误
退出root用户操作环境,进入到myth用户$提示符环境下 [myth@corp ~]$ rm -rf /home/myth/log/httpd && mkdir -p /home/myth/log/httpd 执行此条命令即可解决 请再一次地注意生成的日志文件
拥有者和用户组均属于root 而不是myth用户和myth用户组
[myth@corp ~]$
[myth@corp ~]$ mkdir -p /home/myth/log/httpd #注意:日志文件的目录需要提前创建好,
[myth@corp ~]$ touch /home/myth/log/httpd/user-corp-contoso-error_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/user-corp-contoso-access_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/corp-contoso-error_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/corp-contoso-access_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/contoso-error_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/contoso-access_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ su -
Password:
[root@corp ~]# cat > /etc/httpd/conf.d/httpd-vhosts.conf ## 配置虚拟主机
<Directory "/home/myth/www/think">
Options +Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin zhengzizhi@126.com
DocumentRoot "/home/myth/www/think/public"
ServerName contoso.org
ServerAlias contoso.org
ErrorLog "/home/myth/log/httpd/contoso-error_log"
CustomLog "/home/myth/log/httpd/contoso-access_log" common
</VirtualHost>
<Directory "/home/myth/www/think">
Options +Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin zhengzizhi@126.com
DocumentRoot "/home/myth/www/think/public"
ServerName corp.contoso.org
ServerAlias corp.contoso.org
ErrorLog "/home/myth/log/httpd/corp-contoso-error_log"
CustomLog "/home/myth/log/httpd/corp-contoso-access_log" common
</VirtualHost>
<Directory "/home/myth/www/think">
Options +Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin zhengzizhi@126.com
DocumentRoot "/home/myth/www/think/public"
ServerName user.corp.contoso.org
ServerAlias user.corp.contoso.org
ErrorLog "/home/myth/log/httpd/user-corp-contoso-error_log"
CustomLog "/home/myth/log/httpd/user-corp-contoso-access_log" common
</VirtualHost>
配置域名与IP地址的映射关系,一个域名只能对应一个IP地址,但是一个IP可以对应多个域名
[root@corp ~]# cat > /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 contoso.org
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.20 user.corp.contoso.org
192.168.10.20 corp.contoso.org
192.168.10.20 contoso.org
[root@corp ~]# echo 'contoso.org' > /etc/hostname ## 编辑文件设置主机名,等价命令 hostnamectl set-hostname contoso.org
[root@corp ~]#
在配置文件/etc/httpd/conf/httpd.conf中,我们只需要改下面这行参数值即可,其它参数值保留默认配置:
[root@corp ~]# sed -i -- 's/^#ServerName www.example.com:80/ServerName contoso.org:80/g' /etc/httpd/conf/httpd.conf
[root@contoso ~]# systemctl restart httpd && systemctl restart network && httpd -S
VirtualHost configuration:
*:80 is a NameVirtualHost
default server contoso.org (/etc/httpd/conf.d/httpd-vhosts.conf:9)
port 80 namevhost contoso.org (/etc/httpd/conf.d/httpd-vhosts.conf:9)
alias contoso.org
port 80 namevhost corp.contoso.org (/etc/httpd/conf.d/httpd-vhosts.conf:26)
alias corp.contoso.org
port 80 namevhost user.corp.contoso.org (/etc/httpd/conf.d/httpd-vhosts.conf:43)
alias user.corp.contoso.org
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
[root@contoso ~]#
测试一下网站的访问地址:http://corp.contoso.org,此刻默认主页会显示出来!,如果默认页都无权限访问
那么从[b]mkdir www 到 [b]
[b]chmod 755 -R /home[b]/myth[/b][/b]这两步权限就分配错了
[/b][/b]
[b]大多数人这里根本就没设置权限 开头就错了 后面日志报告权限错误 默认页无权限显示就跟这有关[/b]
[b][b][b][b][b][b]myth[/b][/b][/b][/b]是我的登录系统的管理员用户 默认myth文件夹[b]权限[/b]很低[/b]
[/b]
安装MariaDB
官网给出的baseurl地址下载太慢了
[root@contoso ~]# cat > /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2 CentOS repository list - created 2017-07-08 12:50 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
清华baseurl下载速度很快
[root@contoso ~]# cat > /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2 CentOS repository list - created 2017-07-08 12:50 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-10.2.7/yum/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@contoso ~]# more /etc/yum.repos.d/MariaDB.repo
[root@contoso ~]# yum install -y MariaDB-server MariaDB-client
[root@contoso ~]# find / -name *.cnf
/etc/pki/tls/openssl.cnf
/etc/my.cnf
/etc/my.cnf.d/mysql-clients.cnf
/etc/my.cnf.d/server.cnf
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/wsrep.cnf
[root@contoso ~]# more /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[root@contoso ~]# more /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.1 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.1]
[root@contoso ~]#
[root@contoso ~]# mkdir -p /var/log/mariadb && touch /var/log/mariadb/queries.log && touch /var/log/mariadb/mariadb-error.log && touch /var/log/mariadb/mariadb-slow.log && touch /var/log/mariadb/mariadb-log-bin && touch /var/log/mariadb/mariadb-log-bin.index
&& chown -R mysql:mysql /var/log/mariadb && chmod 755 /var/log/mariadb && chmod 666 /var/log/mariadb/*
[root@contoso ~]#
[root@contoso ~]# cat > /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
character-set-server=utf8
lower-case-table-names=1
log-bin=/var/log/mariadb/mariadb-log-bin
log-bin-index=/var/log/mariadb/mariadb-log-bin.index
log-error=/var/log/mariadb/mariadb-error.log
general-log=ON
general-log-file=/var/log/mariadb/queries.log
log-output=file
slow-query-log=ON
slow-query-log-file=/var/log/mariadb/mariadb-slow.log
long_query_time=1
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.1 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.1]
[root@contoso ~]#
清空日志,实时跟踪日志文件
ll /var/log/mariadb
cat /etc/my.cnf.d/server.cnf
cat /dev/null > /var/log/mariadb/queries.log && cat /dev/null > /var/log/mariadb/mariadb-slow.log && cat /dev/null > /var/log/mariadb/mariadb-error.log
tail -f /var/log/mariadb/queries.log
tail -f /var/log/mariadb/mariadb-slow.log
tail -f /var/log/mariadb/mariadb-error.log
rm -f /var/log/mariadb/*
mysql -uroot -p123456 -h127.0.0.1 -e "reset master" # 清空bin_log日志
[root@contoso ~]# service mysql start
Starting mysql (via systemctl): [ OK ]
[root@contoso ~]# mysql -uroot -h127.0.0.1 -e"show variables like 'character%'"
[root@contoso ~]# mysql -uroot -p123456 -h127.0.0.1 -e"show variables like 'character%'"
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
[root@contoso ~]#/usr/bin/mysql_secure_installation
[root@contoso ~]# mysql -uroot -p123456 -h127.0.0.1
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.2.6-MariaDB-log MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> USE 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]> SELECT host,user FROM user;
+-----------+------+
| host | user |
+-----------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)
MariaDB [mysql]> GRANT ALL ON *.* TO 'root'@'192.168.10.20' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> SELECT host,user FROM user;
+---------------+------+
| host | user |
+---------------+------+
| % | root |
| 127.0.0.1 | root |
| 192.168.10.20 | root |
| ::1 | root |
| contoso.org | root |
| localhost | root |
+---------------+------+
6 rows in set (0.00 sec)
MariaDB [mysql]>
MariaDB [mysql]> quit
Bye
[root@contoso ~]#
另外一种编码配置方式 ------- 表情小图片(是一种字符)使用的编码方式:
[root@contoso ~]# vi /etc/my.cnf.d/client.cnf
#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
default-character-set=utf8mb4
# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
default-character-set=utf8mb4
[root@contoso ~]# vi /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
lower-case-table-names=1
sql-mode="STRICT_TRANS_TABLES"
log-bin=/var/log/mariadb/mariadb-log-bin
log-bin-index=/var/log/mariadb/mariadb-log-bin.index
log-error=/var/log/mariadb/mariadb-error.log
general-log=ON
general-log-file=/var/log/mariadb/queries.log
log-output=file
slow-query-log=ON
slow-query-log-file=/var/log/mariadb/mariadb-slow.log
long_query_time=1
log-queries-not-using-indexes=ON
# this is only for embedded server
[embedded]
# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]
# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
[mariadb-5.5]
[root@contoso ~]# systemctl restart mariadb
[root@contoso ~]# mysql
MariaDB [(none)]> use mysql;
MariaDB [(none)]> SHOW VARIABLES LIKE 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
MariaDB [(none)]> SHOW VARIABLES LIKE '%collation%';
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+----------------------+--------------------+
3 rows in set (0.00 sec)
查看一下你的Apache的执行用户是谁: lsof -i:80
[root@contoso ~]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 11665 root 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29276 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29277 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29278 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29279 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29280 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29281 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29398 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
[root@contoso ~]#
查看apache 的运行的用户
[root@contoso ~]# ps -ef |grep httpd
root 4030 1 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4034 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4035 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4036 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4037 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4039 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 4092 3934 0 11:54 pts/0 00:00:00 grep --color=auto httpd
[root@contoso ~]#
直接在httpd.conf配置文件查看apache执行用户和组,在以下红色字体标识的66行和67行:
[root@contoso ~]# cat -n /etc/httpd/conf/httpd.conf
1 #
2 # This is the main Apache HTTP server configuration file. It contains the
3 # configuration directives that give the server its instructions.
4 # See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
5 # In particular, see
6 # <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
7 # for a discussion of each configuration directive.
8 #
9 # Do NOT simply read the instructions in here without understanding
10 # what they do. They're here only as hints or reminders. If you are unsure
11 # consult the online docs. You have been warned.
12 #
13 # Configuration and logfile names: If the filenames you specify for many
14 # of the server's control files begin with "/" (or "drive:/" for Win32), the
15 # server will use that explicit path. If the filenames do *not* begin
16 # with "/", the value of ServerRoot is prepended -- so 'log/access_log'
17 # with ServerRoot set to '/www' will be interpreted by the
18 # server as '/www/log/access_log', where as '/log/access_log' will be
19 # interpreted as '/log/access_log'.
20
21 #
22 # ServerRoot: The top of the directory tree under which the server's
23 # configuration, error, and log files are kept.
24 #
25 # Do not add a slash at the end of the directory path. If you point
26 # ServerRoot at a non-local disk, be sure to specify a local disk on the
27 # Mutex directive, if file-based mutexes are used. If you wish to share the
28 # same ServerRoot for multiple httpd daemons, you will need to change at
29 # least PidFile.
30 #
31 ServerRoot "/etc/httpd"
32
33 #
34 # Listen: Allows you to bind Apache to specific IP addresses and/or
35 # ports, instead of the default. See also the <VirtualHost>
36 # directive.
37 #
38 # Change this to Listen on specific IP addresses as shown below to
39 # prevent Apache from glomming onto all bound IP addresses.
40 #
41 #Listen 12.34.56.78:80
42 Listen 80
43
44 #
45 # Dynamic Shared Object (DSO) Support
46 #
47 # To be able to use the functionality of a module which was built as a DSO you
48 # have to place corresponding `LoadModule' lines at this location so the
49 # directives contained in it are actually available _before_ they are used.
50 # Statically compiled modules (those listed by `httpd -l') do not need
51 # to be loaded here.
52 #
53 # Example:
54 # LoadModule foo_module modules/mod_foo.so
55 #
56 Include conf.modules.d/*.conf
57
58 #
59 # If you wish httpd to run as a different user or group, you must run
60 # httpd as root initially and it will switch.
61 #
62 # User/Group: The name (or #number) of the user/group to run httpd as.
63 # It is usually good practice to create a dedicated user and group for
64 # running httpd, as with most system services.
65 #
66 User apache
67 Group apache
68
69 # 'Main' server configuration
70 #
71 # The directives in this section set up the values used by the 'main'
72 # server, which responds to any requests that aren't handled by a
73 # <VirtualHost> definition. These values also provide defaults for
74 # any <VirtualHost> containers you may define later in the file.
75 #
76 # All of these directives may appear inside <VirtualHost> containers,
77 # in which case these default settings will be overridden for the
78 # virtual host being defined.
79 #
80
81 #
82 # ServerAdmin: Your address, where problems with the server should be
83 # e-mailed. This address appears on some server-generated pages, such
84 # as error documents. e.g. admin@your-domain.com
85 #
86 ServerAdmin root@localhost
87
88 #
89 # ServerName gives the name and port that the server uses to identify itself.
90 # This can often be determined automatically, but we recommend you specify
91 # it explicitly to prevent problems during startup.
92 #
93 # If your host doesn't have a registered DNS name, enter its IP address here.
94 #
95 ServerName corp.contoso.org:80
96
97 #
98 # Deny access to the entirety of your server's filesystem. You must
99 # explicitly permit access to web content directories in other
100 # <Directory> blocks below.
101 #
102 <Directory />
103 AllowOverride none
104 Require all denied
105 </Directory>
106
107 #
108 # Note that from this point forward you must specifically allow
109 # particular features to be enabled - so if something's not working as
110 # you might expect, make sure that you have specifically enabled it
111 # below.
112 #
113
114 #
115 # DocumentRoot: The directory out of which you will serve your
116 # documents. By default, all requests are taken from this directory, but
117 # symbolic links and aliases may be used to point to other locations.
118 #
119 DocumentRoot "/var/www/html"
120
121 #
122 # Relax access to content within /var/www.
123 #
124 <Directory "/var/www">
125 AllowOverride None
126 # Allow open access:
127 Require all granted
128 </Directory>
129
130 # Further relax access to the default document root:
131 <Directory "/var/www/html">
132 #
133 # Possible values for the Options directive are "None", "All",
134 # or any combination of:
135 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
136 #
137 # Note that "MultiViews" must be named *explicitly* --- "Options All"
138 # doesn't give it to you.
139 #
140 # The Options directive is both complicated and important. Please see
141 # http://httpd.apache.org/docs/2.4/mod/core.html#options
142 # for more information.
143 #
144 Options Indexes FollowSymLinks
145
146 #
147 # AllowOverride controls what directives may be placed in .htaccess files.
148 # It can be "All", "None", or any combination of the keywords:
149 # Options FileInfo AuthConfig Limit
150 #
151 AllowOverride None
152
153 #
154 # Controls who can get stuff from this server.
155 #
156 Require all granted
157 </Directory>
158
159 #
160 # DirectoryIndex: sets the file that Apache will serve if a directory
161 # is requested.
162 #
163 <IfModule dir_module>
164 DirectoryIndex index.html
165 </IfModule>
166
167 #
168 # The following lines prevent .htaccess and .htpasswd files from being
169 # viewed by Web clients.
170 #
171 <Files ".ht*">
172 Require all denied
173 </Files>
174
175 #
176 # ErrorLog: The location of the error log file.
177 # If you do not specify an ErrorLog directive within a <VirtualHost>
178 # container, error messages relating to that virtual host will be
179 # logged here. If you *do* define an error logfile for a <VirtualHost>
180 # container, that host's errors will be logged there and not here.
181 #
182 ErrorLog "logs/error_log"
183
184 #
185 # LogLevel: Control the number of messages logged to the error_log.
186 # Possible values include: debug, info, notice, warn, error, crit,
187 # alert, emerg.
188 #
189 LogLevel warn
190
191 <IfModule log_config_module>
192 #
193 # The following directives define some format nicknames for use with
194 # a CustomLog directive (see below).
195 #
196 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
197 LogFormat "%h %l %u %t \"%r\" %>s %b" common
198
199 <IfModule logio_module>
200 # You need to enable mod_logio.c to use %I and %O
201 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
202 </IfModule>
203
204 #
205 # The location and format of the access logfile (Common Logfile Format).
206 # If you do not define any access logfiles within a <VirtualHost>
207 # container, they will be logged here. Contrariwise, if you *do*
208 # define per-<VirtualHost> access logfiles, transactions will be
209 # logged therein and *not* in this file.
210 #
211 #CustomLog "logs/access_log" common
212
213 #
214 # If you prefer a logfile with access, agent, and referer information
215 # (Combined Logfile Format) you can use the following directive.
216 #
217 CustomLog "logs/access_log" combined
218 </IfModule>
219
220 <IfModule alias_module>
221 #
222 # Redirect: Allows you to tell clients about documents that used to
223 # exist in your server's namespace, but do not anymore. The client
224 # will make a new request for the document at its new location.
225 # Example:
226 # Redirect permanent /foo http://www.example.com/bar
227
228 #
229 # Alias: Maps web paths into filesystem paths and is used to
230 # access content that does not live under the DocumentRoot.
231 # Example:
232 # Alias /webpath /full/filesystem/path
233 #
234 # If you include a trailing / on /webpath then the server will
235 # require it to be present in the URL. You will also likely
236 # need to provide a <Directory> section to allow access to
237 # the filesystem path.
238
239 #
240 # ScriptAlias: This controls which directories contain server scripts.
241 # ScriptAliases are essentially the same as Aliases, except that
242 # documents in the target directory are treated as applications and
243 # run by the server when requested rather than as documents sent to the
244 # client. The same rules about trailing "/" apply to ScriptAlias
245 # directives as to Alias.
246 #
247 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
248
249 </IfModule>
250
251 #
252 # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
253 # CGI directory exists, if you have that configured.
254 #
255 <Directory "/var/www/cgi-bin">
256 AllowOverride None
257 Options None
258 Require all granted
259 </Directory>
260
261 <IfModule mime_module>
262 #
263 # TypesConfig points to the file containing the list of mappings from
264 # filename extension to MIME-type.
265 #
266 TypesConfig /etc/mime.types
267
268 #
269 # AddType allows you to add to or override the MIME configuration
270 # file specified in TypesConfig for specific file types.
271 #
272 #AddType application/x-gzip .tgz
273 #
274 # AddEncoding allows you to have certain browsers uncompress
275 # information on the fly. Note: Not all browsers support this.
276 #
277 #AddEncoding x-compress .Z
278 #AddEncoding x-gzip .gz .tgz
279 #
280 # If the AddEncoding directives above are commented-out, then you
281 # probably should define those extensions to indicate media types:
282 #
283 AddType application/x-compress .Z
284 AddType application/x-gzip .gz .tgz
285
286 #
287 # AddHandler allows you to map certain file extensions to "handlers":
288 # actions unrelated to filetype. These can be either built into the server
289 # or added with the Action directive (see below)
290 #
291 # To use CGI scripts outside of ScriptAliased directories:
292 # (You will also need to add "ExecCGI" to the "Options" directive.)
293 #
294 #AddHandler cgi-script .cgi
295
296 # For type maps (negotiated resources):
297 #AddHandler type-map var
298
299 #
300 # Filters allow you to process content before it is sent to the client.
301 #
302 # To parse .shtml files for server-side includes (SSI):
303 # (You will also need to add "Includes" to the "Options" directive.)
304 #
305 AddType text/html .shtml
306 AddOutputFilter INCLUDES .shtml
307 </IfModule>
308
309 #
310 # Specify a default charset for all content served; this enables
311 # interpretation of all content as UTF-8 by default. To use the
312 # default browser choice (ISO-8859-1), or to allow the META tags
313 # in HTML content to override this choice, comment out this
314 # directive:
315 #
316 AddDefaultCharset UTF-8
317
318 <IfModule mime_magic_module>
319 #
320 # The mod_mime_magic module allows the server to use various hints from the
321 # contents of the file itself to determine its type. The MIMEMagicFile
322 # directive tells the module where the hint definitions are located.
323 #
324 MIMEMagicFile conf/magic
325 </IfModule>
326
327 #
328 # Customizable error responses come in three flavors:
329 # 1) plain text 2) local redirects 3) external redirects
330 #
331 # Some examples:
332 #ErrorDocument 500 "The server made a boo boo."
333 #ErrorDocument 404 /missing.html
334 #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
335 #ErrorDocument 402 http://www.example.com/subscription_info.html
336 #
337
338 #
339 # EnableMMAP and EnableSendfile: On systems that support it,
340 # memory-mapping or the sendfile syscall may be used to deliver
341 # files. This usually improves server performance, but must
342 # be turned off when serving from networked-mounted
343 # filesystems or if support for these functions is otherwise
344 # broken on your system.
345 # Defaults if commented: EnableMMAP On, EnableSendfile Off
346 #
347 #EnableMMAP off
348 EnableSendfile on
349
350 # Supplemental configuration
351 #
352 # Load config files in the "/etc/httpd/conf.d" directory, if any.
353 IncludeOptional conf.d/*.conf
[root@contoso ~]#
/var/www/think/thinkphp/library/think/template/driver/File.php
开启./etc/php.ini 配置文件中 display_errors = On 参数项 ,只在开发的时候开启此项
display_errors = On开启后会捕获以下错误,header会返回status 500 Server error:
PHP Fatal error: Uncaught think\\exception\\ErrorException: mkdir(): Permission denied in /home/myth/www/think/thinkphp/library/think/log/driver/File.php
实际原因是/home/myth/www/think/runtime目录是由httpd服务的用户来读写,默认不是apache这个账户来读写,所以就抛出了没有创建目录的权限,类似也有写这个目录的权限没有,也需要向下面这样改变runtime的读写用户和组
[root@contoso ~]# chown -R apache:apache /home/myth/www/think/runtime && ll /home/myth/www/think
total 28
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[myth@contoso ~]$
[myth@contoso ~]$ ll -a /home/myth/www/think/public
total 24
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 .
drwxrwxr-x 9 myth myth 249 Jul 31 23:36 ..
-rw-rw-r-- 1 myth myth 203 Aug 1 00:36 admin.php
-rw-rw-r-- 1 myth myth 1150 Jul 4 11:52 favicon.ico
-rw-rw-r-- 1 myth myth 216 Jul 4 11:52 .htaccess
-rw-rw-r-- 1 myth myth 759 Jul 31 23:37 index.php
-rw-rw-r-- 1 myth myth 24 Jul 4 11:52 robots.txt
-rw-rw-r-- 1 myth myth 736 Jul 4 11:52 router.php
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 static
[myth@contoso ~]$
[myth@contoso ~]$ cat /home/myth/www/think/public/.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
[myth@contoso ~]$
CentOS7.2 安装Chrome
[root@contoso ~]# cat > /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
[root@contoso ~]# yum install -y google-chrome-stable --nogpgcheck
[root@contoso ~]# cat > /usr/bin/google-chrome
#!/bin/bash
#
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Let the wrapped binary know that it has been run through the wrapper.
export CHROME_WRAPPER="`readlink -f "$0"`"
HERE="`dirname "$CHROME_WRAPPER"`"
# We include some xdg utilities next to the binary, and we want to prefer them
# over the system versions when we know the system versions are very old. We
# detect whether the system xdg utilities are sufficiently new to be likely to
# work for us by looking for xdg-settings. If we find it, we leave $PATH alone,
# so that the system xdg utilities (including any distro patches) will be used.
if ! which xdg-settings &> /dev/null; then
# Old xdg utilities. Prepend $HERE to $PATH to use ours instead.
export PATH="$HERE:$PATH"
else
# Use system xdg utilities. But first create mimeapps.list if it doesn't
# exist; some systems have bugs in xdg-mime that make it fail without it.
xdg_app_dir="${XDG_DATA_HOME:-$HOME/.local/share/applications}"
mkdir -p "$xdg_app_dir"
[ -f "$xdg_app_dir/mimeapps.list" ] || touch "$xdg_app_dir/mimeapps.list"
fi
# Always use our versions of ffmpeg libs.
# This also makes RPMs find the compatibly-named library symlinks.
if [[ -n "$LD_LIBRARY_PATH" ]]; then
LD_LIBRARY_PATH="$HERE:$HERE/lib:$LD_LIBRARY_PATH"
else
LD_LIBRARY_PATH="$HERE:$HERE/lib"
fi
export LD_LIBRARY_PATH
export CHROME_VERSION_EXTRA="stable"
# We don't want bug-buddy intercepting our crashes. http://crbug.com/24120
export GNOME_DISABLE_CRASH_DIALOG=SET_BY_GOOGLE_CHROME
# Sanitize std{in,out,err} because they'll be shared with untrusted child
# processes (http://crbug.com/376567).
exec < /dev/null
exec > >(exec cat)
exec 2> >(exec cat >&2)
# Make sure that the profile directory specified in the environment, if any,
# overrides the default.
if [[ -n "$CHROME_USER_DATA_DIR" ]]; then
# Note: exec -a below is a bashism.
exec -a "$0" "$HERE/chrome" \
--user-data-dir="$CHROME_USER_DATA_DIR" "$@"
else
exec -a "$0" "$HERE/chrome" "$@" --no-sandbox --user-data-dir
fi
[root@contoso ~]#
chrome://extensions/
https://chrome.google.com/webstore/search/postman?hl=en-US
REST请求伪装
[root@contoso ~]# cat > index.html
<form method="post" class="form" action="http://contoso.org/blogs/2">
<input type="submit" class="btn" value=" 删除 ">
<input type="hidden" name="_method" value="DELETE" />
</form>
[root@contoso ~]#
API调试
可以使用ThinkPHP5.0 的Trace 调试中的Socket 调试功能来解决API 开发的调试问题。
SocketLog安装方法
[root@contoso ~]# yum install -y epel-release nodejs npm
[root@contoso ~]# npm install -g socketlog-server
[root@contoso ~]#
netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2025/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1168/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1140/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1724/master
tcp 0 0 0.0.0.0:10081 0.0.0.0:* LISTEN 2708/lighttpd
tcp 0 0 0.0.0.0:10082 0.0.0.0:* LISTEN 2708/lighttpd
tcp 0 0 127.0.0.1:10083 0.0.0.0:* LISTEN 2585/httpd
tcp 0 0 127.0.0.1:56220 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 192.168.10.10:52650 52.87.97.207:443 ESTABLISHED 4046/chrome --no-sa
tcp 0 96 192.168.10.10:22 192.168.10.1:57798 ESTABLISHED 7158/sshd: root@pts
tcp 0 0 127.0.0.1:56222 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 127.0.0.1:56218 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 192.168.10.10:22 192.168.10.1:56761 ESTABLISHED 6944/sshd: root@pts
tcp 0 1 192.168.10.10:42922 74.125.204.138:443 SYN_SENT 4046/chrome --no-sa
tcp 0 0 192.168.10.10:22 192.168.10.1:51318 ESTABLISHED 5673/sshd: root@pts
tcp 0 0 127.0.0.1:56216 127.0.0.1:10083 TIME_WAIT -
tcp 0 1 192.168.10.10:42920 74.125.204.138:443 SYN_SENT 4046/chrome --no-sa
tcp6 0 0 :::3306 :::* LISTEN 1372/mysqld
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::20080 :::* LISTEN 3872/java
tcp6 0 0 :::80 :::* LISTEN 2585/httpd
tcp6 0 0 :::22 :::* LISTEN 1168/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1140/cupsd
tcp6 0 0 :::10137 :::* LISTEN 3872/java
tcp6 0 0 ::1:25 :::* LISTEN 1724/master
tcp6 0 0 :::28029 :::* LISTEN 3872/java
tcp6 0 0 :::9000 :::* LISTEN 3872/java
tcp6 0 0 :::9001 :::* LISTEN 3872/java
tcp6 0 0 192.168.10.10:3306 192.168.10.1:51051 ESTABLISHED 1372/mysqld
tcp6 0 0 192.168.10.10:3306 192.168.10.1:51053 ESTABLISHED 1372/mysqld
[root@contoso ~]#
[root@contoso ~]# socketlog-server
SocketLog started success
[root@contoso ~]# netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2025/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1168/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1140/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1724/master
tcp 0 0 0.0.0.0:10081 0.0.0.0:* LISTEN 2708/lighttpd
tcp 0 0 0.0.0.0:10082 0.0.0.0:* LISTEN 2708/lighttpd
tcp 0 0 127.0.0.1:10083 0.0.0.0:* LISTEN 2585/httpd
tcp 0 0 192.168.10.10:52650 52.87.97.207:443 ESTABLISHED 4046/chrome --no-sa
tcp 0 96 192.168.10.10:22 192.168.10.1:57798 ESTABLISHED 7158/sshd: root@pts
tcp 0 0 127.0.0.1:56270 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 127.0.0.1:56268 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 192.168.10.10:22 192.168.10.1:56761 ESTABLISHED 6944/sshd: root@pts
tcp 0 0 192.168.10.10:22 192.168.10.1:51318 ESTABLISHED 5673/sshd: root@pts
tcp6 0 0 :::3306 :::* LISTEN 1372/mysqld
tcp6 0 0 :::1229 :::* LISTEN 7442/node
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::20080 :::* LISTEN 3872/java
tcp6 0 0 :::80 :::* LISTEN 2585/httpd
tcp6 0 0 :::22 :::* LISTEN 1168/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1140/cupsd
tcp6 0 0 :::10137 :::* LISTEN 3872/java
tcp6 0 0 ::1:25 :::* LISTEN 1724/master
tcp6 0 0 :::1116 :::* LISTEN 7442/node
tcp6 0 0 :::28029 :::* LISTEN 3872/java
tcp6 0 0 :::9000 :::* LISTEN 3872/java
tcp6 0 0 :::9001 :::* LISTEN 3872/java
tcp6 0 0 192.168.10.10:3306 192.168.10.1:51051 ESTABLISHED 1372/mysqld
tcp6 0 0 192.168.10.10:3306 192.168.10.1:51053 ESTABLISHED 1372/mysqld
[root@contoso ~]#
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
return [
// +----------------------------------------------------------------------
// | 应用设置
// +----------------------------------------------------------------------
// 应用命名空间
'app_namespace' => 'app',
// 应用调试模式
'app_debug' => true,
// 应用Trace
// 'app_trace' => false,
// 开启应用Trace调试
'app_trace' => true,
// 设置Trace显示方式
'trace' => [
// 在当前Html页面显示Trace信息
'type' => 'html',
],
// 应用模式状态
'app_status' => '',
// 是否支持多模块
'app_multi_module' => true,
// 入口自动绑定模块
'auto_bind_module' => false,
// 注册的根命名空间
'root_namespace' => [],
// 扩展函数文件
'extra_file_list' => [THINK_PATH . 'helper' . EXT],
// 默认输出类型
'default_return_type' => 'html',
// 默认AJAX 数据返回格式,可选json xml ...
'default_ajax_return' => 'json',
// 默认JSONP格式返回的处理方法
'default_jsonp_handler' => 'jsonpReturn',
// 默认JSONP处理方法
'var_jsonp_handler' => 'callback',
// 默认时区
'default_timezone' => 'PRC',
// 是否开启多语言
'lang_switch_on' => false,
// 默认全局过滤方法 用逗号分隔多个
//'default_filter' => '',
// 设置默认的全局过滤规则 多个用数组或者逗号分隔
'default_filter' => 'htmlspecialchars',
// 默认语言
'default_lang' => 'zh-cn',
// 应用类库后缀
'class_suffix' => false,
// 控制器类后缀
'controller_suffix' => false,
// 是否启用控制器类后缀
//'controller_suffix' => true,
// +----------------------------------------------------------------------
// | 模块设置
// +----------------------------------------------------------------------
// 默认模块名
'default_module' => 'index',
// 禁止访问模块
'deny_module_list' => ['common'],
// 默认控制器名
'default_controller' => 'Index',
// 默认操作名
'default_action' => 'index',
// 默认验证器
'default_validate' => '',
// 默认的空控制器名
'empty_controller' => 'Error',
// 操作方法后缀
'action_suffix' => '',
// 自动搜索控制器
'controller_auto_search' => false,
// +----------------------------------------------------------------------
// | URL设置
// +----------------------------------------------------------------------
// PATHINFO变量名 用于兼容模式
'var_pathinfo' => 's',
// 兼容PATH_INFO获取
'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
// pathinfo分隔符
'pathinfo_depr' => '/',
// 设置pathinfo分隔符
//'pathinfo_depr' => ':',
// URL伪静态后缀
'url_html_suffix' => 'html',
// URL普通方式参数 用于自动生成
'url_common_param' => false,
// URL参数方式 0 按名称成对解析 1 按顺序解析
'url_param_type' => 0,
// 按照参数顺序获取
//'url_param_type' => 1,
// 是否开启路由
'url_route_on' => true,
// 路由使用完整匹配
'route_complete_match' => false,
// 路由配置文件(支持配置多个)
'route_config_file' => ['route'],
// 是否强制使用路由
'url_route_must' => false,
// 域名部署
'url_domain_deploy' => false,
// 域名根,如thinkphp.cn
'url_domain_root' => '',
// 是否自动转换URL中的控制器和操作名
//'url_convert' => true,
// 关闭URL自动转换(支持驼峰访问控制器)
'url_convert' => false,
// 默认的访问控制器层
'url_controller_layer' => 'controller',
// 表单请求类型伪装变量
'var_method' => '_method',
// 表单ajax伪装变量
'var_ajax' => '_ajax',
// 表单pjax伪装变量
'var_pjax' => '_pjax',
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
'request_cache' => false,
// 请求缓存有效期
'request_cache_expire' => null,
// 全局请求缓存排除规则
'request_cache_except' => [],
// +----------------------------------------------------------------------
// | 模板设置
// +----------------------------------------------------------------------
'template' => [
// 模板引擎类型 支持 php think 支持扩展
'type' => 'Think',
// 模板路径
'view_path' => '',
// 模板后缀
'view_suffix' => 'html',
// 模板文件名分隔符
'view_depr' => DS,
// 模板引擎普通标签开始标记
'tpl_begin' => '{',
// 模板引擎普通标签结束标记
'tpl_end' => '}',
// 标签库标签开始标记
'taglib_begin' => '{',
// 标签库标签结束标记
'taglib_end' => '}',
//统一使用布局
'layout_on' => true,
'layout_name' => 'layout',
'layout_item' => '[__REPLACE__]',
],
/*
'template' => [
// 模板引擎类型 支持 php think 支持扩展
'type' => 'Think',
// 模板路径
'view_path' => '../template/index/',
// 模板后缀
'view_suffix' => '.tpl',
// 模板文件名分隔符
'view_depr' => DS, // '_'
],*/
// 视图输出字符串内容替换
'view_replace_str' => [],
// 默认跳转页面对应的模板文件
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
// +----------------------------------------------------------------------
// | 异常及错误设置
// +----------------------------------------------------------------------
// 异常页面的模板文件
'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',
// 显示错误信息
'show_error_msg' => false,
// 异常处理handle类 留空使用 \think\exception\Handle
//'exception_handle' => '',
//API后台来处理异常
'exception_handle' => '\app\api\exception\Http',
// +----------------------------------------------------------------------
// | 日志设置
// +----------------------------------------------------------------------
/*
'log' => [
// 日志记录方式,内置 file socket 支持扩展
'type' => 'File',
// 日志保存目录
'path' => LOG_PATH,
// 日志记录级别
'level' => [],
// error和sql日志单独记录
'apart_level' => ['error','sql'],
],*/
'log' => [
'type' => 'socket',
'host' => 'localhost',
'show_included_files' => true,
'force_client_ids' => ['slog_20170713'],
'allow_client_ids' => ['slog_20170713'],
],
// +----------------------------------------------------------------------
// | Trace设置 开启 app_trace 后 有效
// +----------------------------------------------------------------------
'trace' => [
// 内置Html Console 支持扩展
'type' => 'Html',
],
// +----------------------------------------------------------------------
// | 缓存设置
// +----------------------------------------------------------------------
'cache' => [
// 驱动方式
'type' => 'File',
// 缓存保存目录
'path' => CACHE_PATH,
// 缓存前缀
'prefix' => '',
// 缓存有效期 0表示永久缓存
'expire' => 0,
],
// +----------------------------------------------------------------------
// | 会话设置
// +----------------------------------------------------------------------
'session' => [
'id' => '',
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id' => '',
// SESSION 前缀
'prefix' => 'think',
// 驱动方式 支持redis memcache memcached
'type' => '',
// 是否自动开启 SESSION
'auto_start' => true,
],
// +----------------------------------------------------------------------
// | Cookie设置
// +----------------------------------------------------------------------
'cookie' => [
// cookie 名称前缀
'prefix' => '',
// cookie 保存时间
'expire' => 0,
// cookie 保存路径
'path' => '/',
// cookie 有效域名
'domain' => '',
// cookie 启用安全传输
'secure' => false,
// httponly设置
'httponly' => '',
// 是否使用 setcookie
'setcookie' => true,
],
//分页配置
'paginate' => [
'type' => 'bootstrap',
'var_page' => 'page',
'list_rows' => 15,
],
// 数据库配置1
'db1' => [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'testdb1',
// 数据库用户名
'username' => 'root',
// 数据库密码
'password' => '123456',
// 数据库连接端口
'hostport' => '3306',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
// 数据库表前缀
'prefix' => 'think_',
],
// 数据库配置2
'db2' => [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'testdb2',
// 数据库用户名
'username' => 'root',
// 数据库密码
'password' => '123456',
// 数据库连接端口
'hostport' => '3306',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
// 数据库表前缀
'prefix' => 'think_',
],
];
远程调试:
[b]显示ThinkPHP5.0命令行当前支持的所有指令:[/b]
[root@contoso ~]# cd /home/myth/www/think
[root@contoso think]# pwd
/home/myth/www/think
[root@contoso think]# php think
Think Console version 0.1
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-V, --version Display this console version
-q, --quiet Do not output any message
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
build Build Application Dirs
clear Clear runtime file
help Displays help for a command
list Lists commands
make
make:controller Create a new resource controller class
make:model Create a new model class
optimize
optimize:autoload Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.
optimize:config Build config and common file cache.
optimize:route Build route cache.
optimize:schema Build database schema cache.
[root@contoso think]#
生成模块:
下面我们给应用生成一个新的模块test ,首先需要在apps 目录下面创建一个build.php 定义
文件,文件内容如下:
return [
// 定义test模块的自动生成
'test' => [
'__dir__' => ['controller', 'model', 'view'],
'controller' => ['User', 'UserType'],
'model' => ['User', 'UserType'],
'view' => ['index/index', 'index/test'],
],
];
[root@contoso think]# ll
total 28
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso think]#
然后在命令行下面,执行:
[root@contoso think]# php think build
Successed
[root@contoso think]# ll [b]/home/myth/www/think/apps[/b]
total 36
drwxrwxr-x 5 myth myth 85 Aug 1 12:35 api
-rw-rw-r-- 1 myth myth 558 Aug 1 12:34 build.php
-rw-rw-r-- 1 myth myth 606 Jul 4 11:52 command.php
-rw-rw-r-- 1 myth myth 616 Jul 4 11:52 common.php
-rw-rw-r-- 1 myth myth 8799 Aug 1 12:23 config.php
-rw-rw-r-- 1 myth myth 1898 Jul 4 11:52 database.php
drwxrwxr-x 5 myth myth 85 Aug 1 12:35 demo
drwxrwxr-x 3 myth myth 24 Jul 4 11:52 index
-rw-rw-r-- 1 myth myth 4435 Aug 1 18:37 route.php
-rw-rw-r-- 1 myth myth 981 Jul 4 11:52 tags.php
drwxrwxr-x 5 myth myth 85 Aug 1 12:35 test
[root@contoso think]# tree [b][b]/home/myth/www/think[/b]/apps/test[/b]
/var/www/think/apps/test
├── common.php
├── config.php
├── controller
│ ├── Index.php
│ ├── User.php
│ └── UserType.php
├── model
│ ├── User.php
│ └── UserType.php
└── view
└── index
├── index.html
└── test.html
4 directories, 9 files
[root@contoso think]#
接下来,我们可以访问
http://contoso.org/test/
生成文件:
还可以用make 指令单独生成某个应用类库文件,例如:
[root@contoso ~]#[b]cd[b][b]/home/myth/www/think[/b][/b]
[/b]
[root@contoso think]#php think make:controller test/Blog
Controller created successfully.
[root@contoso think]# tree [b][b]/home/myth/www/think[/b]/apps/test[/b]
/var/www/think/apps/test
├── common.php
├── config.php
├── controller
│ ├── Blog.php
│ ├── Index.php
│ ├── User.php
│ └── UserType.php
├── model
│ ├── User.php
│ └── UserType.php
└── view
└── index
├── index.html
└── test.html
4 directories, 10 files
[root@contoso think]#
会自动为test模块生成一个 Blog控制器文件。
注意,默认生成的控制器类是属于资源控制器,并且继承了\think\Controller。
如果希望生成一个空的控制器,可以使用
[root@contoso think]#php think make:controller test/Blog --plain
又或者生成一个模型文件
[root@contoso think]#php think make:model test/Blog
Model created successfully.
[root@contoso think]# tree [b][b]/home/myth/www/think[/b]/apps/test[/b]
/home/myth/www/think/apps/test
├── common.php
├── config.php
├── controller
│ ├── Blog.php
│ ├── Index.php
│ ├── User.php
│ └── UserType.php
├── model
│ ├── Blog.php
│ ├── User.php
│ └── UserType.php
└── view
└── index
├── index.html
└── test.html
4 directories, 11 files
[root@contoso think]#
生成类库映射文件
在生成类库文件之后,我们强烈建议使用命令行生成类库映射文件,可以提高自动加载的性能,用法如下:
php think optimize:autoload
[root@contoso think]# tree [b][b][b]/home/myth/www/think[/b][/b]/runtime[/b]
/var/www/think/runtime
├── cache
│ ├── 10
│ ├── 2c
│ ├── 37
│ ├── 97
│ ├── 9b
│ ├── aa
│ ├── b4
│ ├── cd
│ ├── e6
│ └── ef
├── log
│ └── 201707
│ ├── 09.log
│ ├── 10.log
│ ├── 11.log
│ ├── 12.log
│ ├── 12_sql.log
│ ├── 13.log
│ └── 13_sql.log
└── temp
├── 05298ce6c97542a523ca6b9a2f99e2e0.php
├── 0c0761ad40371ca875eef82bed6fac8b.php
├── 40c4cbd97fc727507cce2922e2708d81.php
├── 44086db842173b76b442ec6ee84b74b4.php
├── 6ef062f8ed644a1083155e681e7f7cdc.php
├── e319b0ab5fc2fe69ec85ccc9dad9fb62.php
└── fdc06d0a4ecd09fe301acada23705d1b.php
14 directories, 14 files
[root@contoso think]# pwd
/home/myth/www/think
[root@contoso think]# ll
total 32
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
drwxr-xr-x 3 myth myth 746 Jul 31 23:36 template
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso think]# php think optimize:autoload
Succeed!
[root@contoso think]# tree [b][b][b][b]/home/myth/www/think[/b][/b][/b]/runtime[/b]
/var/www/think/runtime
├── cache
│ ├── 10
│ ├── 2c
│ ├── 37
│ ├── 97
│ ├── 9b
│ ├── aa
│ ├── b4
│ ├── cd
│ ├── e6
│ └── ef
├── classmap.php
├── log
│ └── 201707
│ ├── 09.log
│ ├── 10.log
│ ├── 11.log
│ ├── 12.log
│ ├── 12_sql.log
│ ├── 13.log
│ └── 13_sql.log
└── temp
├── 05298ce6c97542a523ca6b9a2f99e2e0.php
├── 0c0761ad40371ca875eef82bed6fac8b.php
├── 40c4cbd97fc727507cce2922e2708d81.php
├── 44086db842173b76b442ec6ee84b74b4.php
├── 6ef062f8ed644a1083155e681e7f7cdc.php
├── e319b0ab5fc2fe69ec85ccc9dad9fb62.php
└── fdc06d0a4ecd09fe301acada23705d1b.php
14 directories, 15 files
[root@contoso think]#
执行完毕,会在RUNTIME_PATH 目录下面生成一个classmap.php 文件,包括了系统和应用的所有类库
文件的映射列表。
[root@contoso think]# cat [b][b][b][b]/home/myth/www/think[/b][/b][/b]/runtime/classmap.php[/b]
生成路由缓存文件
如果你的应用定义了大量的路由规则,那么建议在实际部署后生成路由缓存文件,可以免去路由注册的开
销,从而改善路由的检测效率,用法如下:
php think optimize:route
[root@contoso think]# cd /home/myth/www/think
[root@contoso think]# ll
total 32
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
drwxr-xr-x 3 myth myth 746 Jul 31 23:36 template
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso think]# php think optimize:route
Succeed!
[root@contoso think]# tree /home/myth/www/think/runtime
/home/myth/www/think/runtime
├── cache
│ ├── 10
│ ├── 2c
│ ├── 37
│ ├── 97
│ ├── 9b
│ ├── aa
│ ├── b4
│ ├── cd
│ ├── e6
│ └── ef
├── classmap.php
├── log
│ └── 201707
│ ├── 09.log
│ ├── 10.log
│ ├── 11.log
│ ├── 12.log
│ ├── 12_sql.log
│ ├── 13.log
│ └── 13_sql.log
├── route.php
└── temp
├── 05298ce6c97542a523ca6b9a2f99e2e0.php
├── 0c0761ad40371ca875eef82bed6fac8b.php
├── 40c4cbd97fc727507cce2922e2708d81.php
├── 44086db842173b76b442ec6ee84b74b4.php
├── 6ef062f8ed644a1083155e681e7f7cdc.php
├── e319b0ab5fc2fe69ec85ccc9dad9fb62.php
└── fdc06d0a4ecd09fe301acada23705d1b.php
14 directories, 16 files
[root@contoso think]#
执行完毕,会在RUNTIME_PATH 目录下面生成一个route.php 文件,包括了应用的所有路由规则定义列
表。
生成数据表字段缓存文件
如果你希望提高查询的性能,可以通过生成字段缓存来减少查询。用法如下:
php think optimize:schema
执行完毕,会在RUNTIME_PATH 目录下面创建schema目录,然后在该目录下面按照
database.table.php 的文件命名生成数据表字段缓存文件。
也可以指定数据库生成字段缓存(必须有用户权限),例如,下面指定生成demo数据库下面的所有数据表的
字段缓存信息。
php think optimize:schema --db demo
还可以读取模块的模型类来生成数据表字段缓存(这个适合多数据库连接的情况),如下:
php think optimize:schema --module index
会读取index模块的模型来生成数据表字段缓存。
[root@contoso think]# pwd
/var/www/think
[root@contoso think]# ll
total 32
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
drwxr-xr-x 3 myth myth 746 Jul 31 23:36 template
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso think]# php think optimize:schema
Succeed!
[root@contoso think]# tree /home/myth/www/think/runtime
/home/myth/www/think/runtime
├── cache
│ ├── 10
│ ├── 2c
│ ├── 37
│ ├── 97
│ ├── 9b
│ ├── aa
│ ├── b4
│ ├── cd
│ ├── e6
│ └── ef
├── classmap.php
├── log
│ └── 201707
│ ├── 09.log
│ ├── 10.log
│ ├── 11.log
│ ├── 12.log
│ ├── 12_sql.log
│ ├── 13.log
│ └── 13_sql.log
├── route.php
├── schema
│ ├── testdb1.think_access.php
│ ├── testdb1.think_blog.php
│ ├── testdb1.think_book.php
│ ├── testdb1.think_data.php
│ ├── testdb1.think_profile.php
│ ├── testdb1.think_role.php
│ └── testdb1.think_user.php
└── temp
├── 05298ce6c97542a523ca6b9a2f99e2e0.php
├── 0c0761ad40371ca875eef82bed6fac8b.php
├── 40c4cbd97fc727507cce2922e2708d81.php
├── 44086db842173b76b442ec6ee84b74b4.php
├── 6ef062f8ed644a1083155e681e7f7cdc.php
├── e319b0ab5fc2fe69ec85ccc9dad9fb62.php
└── fdc06d0a4ecd09fe301acada23705d1b.php
15 directories, 23 files
[root@contoso think]#
更新数据表字段缓存也是同样的方式,每次执行都会重新生成缓存。如果需要单独更新某个数据表的缓存,
可以使用:
php think optimize:schema --table think_user
支持指定数据库名称
php think optimize:schema --table demo.think_user
sendmail服务配置(注意:qq邮箱接收sendmail发的邮件一律被拒绝接收,别指望qq邮箱测试会成功):
[root@contoso ~]# sestatus -v
SELinux status: disabled
php.ini (默认值即可):
SMTP=localhost
smtp_port=25
sendmail_path="/usr/lib/sendmail -t -i"
[root@contoso ~]# yum install -y sendmail
[root@contoso ~]# systemctl enable sendmail
[root@contoso ~]# systemctl restart sendmail
[root@contoso ~]# systemctl status sendmail
[root@contoso ~]# echo 'HOSTNAME=contoso.org' >> /etc/sysconfig/network
[root@contoso ~]# echo 'contoso.org # this is my email domainname' >> /etc/mail/local-host-names
[root@contoso ~]# vi /etc/mail/sendmail.cf
# SMTP daemon options
O DaemonPortOptions=Port=smtp,Addr=0.0.0.0, Name=MTA
[root@contoso ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
contoso.org
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.10 contoso.org
[root@contoso ~]#
[root@contoso ~]# nslookup -query=mx qq.com
C:\Users\Administrator>nslookup -qt=mx qq.com
[root@contoso ~]# tail -f /var/log/maillog
[root@contoso ~]# mail -s "this is a testing email content." zhengzizhi@aliyun.com < anaconda-ks.cfg
[root@contoso ~]# mail -s "this is a testing email content." zhengzizhi@126.com < anaconda-ks.cfg
[root@contoso ~]# cat /dev/null > /var/spool/mail/root && cat /dev/null > /var/log/maillog
[root@contoso ~]# alternatives --display mta
mta - status is auto.
link currently points to /usr/sbin/sendmail.sendmail
/usr/sbin/sendmail.postfix - priority 30
slave mta-pam: /etc/pam.d/smtp.postfix
slave mta-mailq: /usr/bin/mailq.postfix
slave mta-newaliases: /usr/bin/newaliases.postfix
slave mta-rmail: /usr/bin/rmail.postfix
slave mta-sendmail: /usr/lib/sendmail.postfix
slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz
slave mta-rmailman: (null)
slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz
/usr/sbin/sendmail.sendmail - priority 90
slave mta-pam: /etc/pam.d/smtp.sendmail
slave mta-mailq: /usr/bin/mailq.sendmail
slave mta-newaliases: /usr/bin/newaliases.sendmail
slave mta-rmail: /usr/bin/rmail.sendmail
slave mta-sendmail: /usr/lib/sendmail.sendmail
slave mta-mailqman: /usr/share/man/man1/mailq.sendmail.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.sendmail.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.sendmail.5.gz
slave mta-rmailman: /usr/share/man/man8/rmail.sendmail.8.gz
slave mta-sendmailman: /usr/share/man/man8/sendmail.sendmail.8.gz
Current `best' version is /usr/sbin/sendmail.sendmail.
[root@contoso ~]#
thinkphp5.0 config.php错误日志的接收邮箱配置方式:
'log' => [
'type' => 'driver\log\Email',
'email_addr' => 'zhengzizhi@126.com',
'send_level' => ['error', 'info'],
],
安装验证码类库,在命令行下面切换到应用根目录下面,执行:
[root@contoso ~]$ cd [b]/home/myth/www/think[/b]
[root@contoso think]# tree -L 2
.
├── apps
│ ├── api
│ ├── build.php
│ ├── command.php
│ ├── common.php
│ ├── config.php
│ ├── database.php
│ ├── demo
│ ├── index
│ ├── route.php
│ └── tags.php
├── build.php
├── composer.json
├── composer.lock
├── extend
│ ├── ArrayList.php
│ └── driver
├── LICENSE.txt
├── public
│ ├── favicon.ico
│ ├── index.php
│ ├── robots.txt
│ ├── router.php
│ └── static
├── README.md
├── runtime
│ ├── log
│ └── temp
├── template
│ └── index
├── think
├── thinkphp
│ ├── base.php
│ ├── codecov.yml
│ ├── composer.json
│ ├── console.php
│ ├── CONTRIBUTING.md
│ ├── convention.php
│ ├── helper.php
│ ├── lang
│ ├── library
│ ├── LICENSE.txt
│ ├── logo.png
│ ├── phpunit.xml
│ ├── README.md
│ ├── start.php
│ └── tpl
└── vendor
├── autoload.php
├── composer
└── topthink
20 directories, 31 files
[root@contoso think]# composer require topthink/think-captcha
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^1.0 for topthink/think-captcha
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing topthink/think-captcha (v1.0.7): Downloading (100%)
Writing lock file
Generating autoload files
[root@contoso think]#
因为httpd服务的运行用户默认是apache,所以上传文件夹uploads的权限必须分配给apache这个用户:
查看一下你的Apache的执行用户是谁: lsof -i:80
[root@contoso ~]# lsof -i:80
[root@contoso ~]# ll [b]/home/myth/www/think/public[/b]
total 20
-rw-rw-r-- 1 myth myth 203 Aug 1 00:36 admin.php
-rw-rw-r-- 1 myth myth 1150 Jul 4 11:52 favicon.ico
-rw-rw-r-- 1 myth myth 759 Jul 31 23:37 index.php
-rw-rw-r-- 1 myth myth 24 Jul 4 11:52 robots.txt
-rw-rw-r-- 1 myth myth 736 Jul 4 11:52 router.php
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 static
drwxr-xr-x 2 myth myth 24 Jul 4 11:52 uploads
[root@contoso ~]# chown -R apache:apache /home/myth/www/think/runtime && ll /home/myth/www/think
total 28
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso ~]#
安装ThinkPHP5 的单元测试扩展,进入命令行,切换到应用根目录下面后,执行:
[myth@contoso ~]$ cd /home/myth/www/think
[root@contoso think]$ tree -L 2
.
├── apps
│ ├── api
│ ├── build.php
│ ├── command.php
│ ├── common.php
│ ├── config.php
│ ├── database.php
│ ├── demo
│ ├── index
│ ├── route.php
│ └── tags.php
├── build.php
├── composer.json
├── composer.lock
├── extend
│ ├── ArrayList.php
│ └── driver
├── LICENSE.txt
├── public
│ ├── favicon.ico
│ ├── index.php
│ ├── robots.txt
│ ├── router.php
│ ├── static
│ └── uploads
├── README.md
├── runtime
│ ├── log
│ └── temp
├── template
│ └── index
├── think
├── thinkphp
│ ├── base.php
│ ├── codecov.yml
│ ├── composer.json
│ ├── console.php
│ ├── CONTRIBUTING.md
│ ├── convention.php
│ ├── helper.php
│ ├── lang
│ ├── library
│ ├── LICENSE.txt
│ ├── logo.png
│ ├── phpunit.xml
│ ├── README.md
│ ├── start.php
│ └── tpl
└── vendor
├── autoload.php
├── composer
└── topthink
21 directories, 31 files
[root@contoso think]# composer require topthink/think-testing
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^1.0 for topthink/think-testing
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 25 installs, 0 updates, 0 removals
- Installing symfony/polyfill-mbstring (v1.4.0): Downloading (100%)
- Installing symfony/dom-crawler (v2.8.25): Downloading (100%)
- Installing symfony/yaml (v3.3.5): Downloading (100%)
- Installing sebastian/version (1.0.6): Downloading (100%)
- Installing sebastian/global-state (1.1.1): Downloading (100%)
- Installing sebastian/recursion-context (1.0.5): Downloading (100%)
- Installing sebastian/exporter (1.2.2): Downloading (100%)
- Installing sebastian/environment (1.3.8): Downloading (100%)
- Installing sebastian/diff (1.4.3): Downloading (100%)
- Installing sebastian/comparator (1.2.4): Downloading (100%)
- Installing doctrine/instantiator (1.1.0): Downloading (100%)
- Installing phpunit/php-text-template (1.2.1): Downloading (100%)
- Installing phpunit/phpunit-mock-objects (2.3.8): Downloading (100%)
- Installing phpunit/php-timer (1.0.9): Downloading (100%)
- Installing phpunit/php-file-iterator (1.4.2): Downloading (100%)
- Installing phpunit/php-token-stream (1.4.11): Downloading (100%)
- Installing phpunit/php-code-coverage (2.2.4): Downloading (100%)
- Installing webmozart/assert (1.2.0): Downloading (100%)
- Installing phpdocumentor/reflection-common (1.0): Downloading (100%)
- Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)
- Installing phpdocumentor/reflection-docblock (3.2.0): Downloading (100%)
- Installing phpspec/prophecy (v1.7.0): Downloading (100%)
- Installing phpunit/phpunit (4.8.36): Downloading (100%)
- Installing topthink/think-helper (v1.0.6): Downloading (100%)
- Installing topthink/think-testing (v1.0.6): Downloading (100%)
symfony/dom-crawler suggests installing symfony/css-selector ()
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
[root@contoso think]#
[root@contoso ~]# yum install php71-php-pecl-swoole
[root@contoso think]# pwd
/home/myth/www/think
[root@contoso think]# ll
total 32
drwxrwxr-x 5 myth myth 186 Aug 4 16:23 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 655 Aug 12 10:03 composer.json
-rw-rw-r-- 1 myth myth 7568 Aug 12 10:03 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 5 03:19 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 4 apache apache 47 Aug 1 23:57 runtime
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Aug 11 03:23 thinkphp
drwxrwxr-x 5 myth myth 77 Aug 12 10:03 vendor
[root@contoso think]# php public/index.php index/Demon/start
[root@contoso think]# lsof -i:9501
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php 71618 root 3u IPv4 488904 0t0 TCP *:9501 (LISTEN)
[root@contoso think]# yum install -y telnet
[root@contoso think]# telnet 127.0.0.1 9501
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
hello
onReceive: hello
一次关闭同名称的多个进程:
分解关闭进程指令 ps -eaf |grep 'index/Socket/run'|grep -v "grep"|awk '{print $2}'|xargs kill -9,看看每步操作的效果
[root@contoso ~]# ps -eaf
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 07:02 ? 00:00:06 /usr/lib/systemd/systemd --switched-root --system --deseria
root 2 0 0 07:02 ? 00:00:00 [kthreadd]
root 3 2 0 07:02 ? 00:00:02 [ksoftirqd/0]
root 5 2 0 07:02 ? 00:00:00 [kworker/0:0H]
root 7 2 0 07:02 ? 00:00:00 [migration/0]
root 8 2 0 07:02 ? 00:00:00 [rcu_bh]
root 9 2 0 07:02 ? 00:01:09 [rcu_sched]
root 10 2 0 07:02 ? 00:00:00 [watchdog/0]
root 11 2 0 07:02 ? 00:00:00 [watchdog/1]
root 12 2 0 07:02 ? 00:00:00 [migration/1]
root 13 2 0 07:02 ? 00:00:00 [ksoftirqd/1]
root 16 2 0 07:02 ? 00:00:00 [watchdog/2]
root 17 2 0 07:02 ? 00:00:00 [migration/2]
root 18 2 0 07:02 ? 00:00:00 [ksoftirqd/2]
root 20 2 0 07:02 ? 00:00:00 [kworker/2:0H]
root 21 2 0 07:02 ? 00:00:00 [watchdog/3]
root 22 2 0 07:02 ? 00:00:00 [migration/3]
root 23 2 0 07:02 ? 00:00:00 [ksoftirqd/3]
root 25 2 0 07:02 ? 00:00:00 [kworker/3:0H]
root 27 2 0 07:02 ? 00:00:00 [kdevtmpfs]
root 28 2 0 07:02 ? 00:00:00 [netns]
root 29 2 0 07:02 ? 00:00:00 [khungtaskd]
root 30 2 0 07:02 ? 00:00:00 [writeback]
root 31 2 0 07:02 ? 00:00:00 [kintegrityd]
root 32 2 0 07:02 ? 00:00:00 [bioset]
root 33 2 0 07:02 ? 00:00:00 [kblockd]
root 34 2 0 07:02 ? 00:00:00 [md]
root 40 2 0 07:03 ? 00:00:00 [kswapd0]
root 41 2 0 07:03 ? 00:00:00 [ksmd]
root 42 2 0 07:03 ? 00:00:13 [khugepaged]
root 43 2 0 07:03 ? 00:00:00 [fsnotify_mark]
root 44 2 0 07:03 ? 00:00:00 [crypto]
root 52 2 0 07:03 ? 00:00:00 [kthrotld]
root 53 2 0 07:03 ? 00:00:01 [kworker/u256:1]
root 54 2 0 07:03 ? 00:00:00 [kmpath_rdacd]
root 56 2 0 07:03 ? 00:00:00 [kworker/0:1]
root 57 2 0 07:03 ? 00:00:00 [kpsmoused]
root 59 2 0 07:03 ? 00:00:00 [ipv6_addrconf]
root 79 2 0 07:03 ? 00:00:00 [deferwq]
root 112 2 0 07:03 ? 00:00:00 [kauditd]
root 299 2 0 07:03 ? 00:00:00 [ata_sff]
root 300 2 0 07:03 ? 00:00:00 [mpt_poll_0]
root 301 2 0 07:03 ? 00:00:00 [mpt/0]
root 309 2 0 07:03 ? 00:00:00 [scsi_eh_0]
root 310 2 0 07:03 ? 00:00:00 [scsi_tmf_0]
root 311 2 0 07:03 ? 00:00:00 [scsi_eh_1]
root 313 2 0 07:03 ? 00:00:00 [scsi_tmf_1]
root 314 2 0 07:03 ? 00:00:00 [scsi_eh_2]
root 315 2 0 07:03 ? 00:00:00 [scsi_tmf_2]
root 316 2 0 07:03 ? 00:00:00 [ttm_swap]
root 350 2 0 07:03 ? 00:00:00 [kworker/0:1H]
root 392 2 0 07:03 ? 00:00:00 [kdmflush]
root 393 2 0 07:03 ? 00:00:00 [bioset]
root 404 2 0 07:03 ? 00:00:00 [kdmflush]
root 405 2 0 07:03 ? 00:00:00 [bioset]
root 418 2 0 07:03 ? 00:00:00 [xfsalloc]
root 419 2 0 07:03 ? 00:00:00 [xfs_mru_cache]
root 420 2 0 07:03 ? 00:00:00 [xfs-buf/dm-0]
root 421 2 0 07:03 ? 00:00:00 [xfs-data/dm-0]
root 422 2 0 07:03 ? 00:00:00 [xfs-conv/dm-0]
root 423 2 0 07:03 ? 00:00:00 [xfs-cil/dm-0]
root 424 2 0 07:03 ? 00:00:00 [xfs-reclaim/dm-]
root 425 2 0 07:03 ? 00:00:00 [xfs-log/dm-0]
root 426 2 0 07:03 ? 00:00:00 [xfs-eofblocks/d]
root 427 2 0 07:03 ? 00:00:30 [xfsaild/dm-0]
root 498 1 0 07:03 ? 00:00:00 /usr/lib/systemd/systemd-journald
root 522 2 0 07:03 ? 00:00:00 [rpciod]
root 523 1 0 07:03 ? 00:00:00 /usr/sbin/lvmetad -f
root 528 2 0 07:03 ? 00:00:03 [kworker/2:2]
root 536 1 0 07:03 ? 00:00:00 /usr/lib/systemd/systemd-udevd
root 556 2 0 07:03 ? 00:00:00 [nfit]
root 572 2 0 07:03 ? 00:00:00 [kworker/u257:0]
root 574 2 0 07:03 ? 00:00:00 [hci0]
root 575 2 0 07:03 ? 00:00:00 [hci0]
root 576 2 0 07:03 ? 00:00:00 [kworker/u257:1]
root 633 2 0 07:03 ? 00:00:00 [xfs-buf/sda1]
root 634 2 0 07:03 ? 00:00:00 [xfs-data/sda1]
root 635 2 0 07:03 ? 00:00:00 [xfs-conv/sda1]
root 636 2 0 07:03 ? 00:00:00 [xfs-cil/sda1]
root 637 2 0 07:03 ? 00:00:00 [xfs-reclaim/sda]
root 638 2 0 07:03 ? 00:00:00 [xfs-log/sda1]
root 639 2 0 07:03 ? 00:00:00 [xfs-eofblocks/s]
root 641 2 0 07:03 ? 00:00:00 [xfsaild/sda1]
root 649 2 0 07:03 ? 00:00:00 [kdmflush]
root 650 2 0 07:03 ? 00:00:00 [bioset]
root 657 2 0 07:03 ? 00:00:00 [xfs-buf/dm-2]
root 658 2 0 07:03 ? 00:00:00 [xfs-data/dm-2]
root 659 2 0 07:03 ? 00:00:00 [xfs-conv/dm-2]
root 660 2 0 07:03 ? 00:00:00 [xfs-cil/dm-2]
root 661 2 0 07:03 ? 00:00:00 [xfs-reclaim/dm-]
root 662 2 0 07:03 ? 00:00:00 [xfs-log/dm-2]
root 663 2 0 07:03 ? 00:00:00 [xfs-eofblocks/d]
root 664 2 0 07:03 ? 00:00:08 [xfsaild/dm-2]
root 689 1 0 07:03 ? 00:00:00 /sbin/auditd -n
root 706 689 0 07:03 ? 00:00:00 /sbin/audispd
avahi 709 1 0 07:03 ? 00:00:00 avahi-daemon: running [contoso.local]
libstor+ 711 1 0 07:03 ? 00:00:00 /usr/bin/lsmd -d
root 712 706 0 07:03 ? 00:00:00 /usr/sbin/sedispatch
root 717 1 0 07:03 ? 00:00:47 /usr/bin/vmtoolsd
dbus 718 1 0 07:03 ? 00:00:05 /bin/dbus-daemon --system --address=systemd: --nofork --nop
avahi 719 709 0 07:03 ? 00:00:00 avahi-daemon: chroot helper
root 724 1 0 07:03 ? 00:00:01 /usr/lib/systemd/systemd-logind
rtkit 725 1 0 07:03 ? 00:00:01 /usr/libexec/rtkit-daemon
polkitd 726 1 0 07:03 ? 00:00:02 /usr/lib/polkit-1/polkitd --no-debug
root 727 1 0 07:03 ? 00:00:08 /usr/sbin/irqbalance --foreground
root 728 1 0 07:03 ? 00:00:00 /usr/sbin/abrtd -d -s
root 729 1 0 07:03 ? 00:00:00 /usr/bin/abrt-watch-log -F Backtrace /var/log/Xorg.0.log --
root 730 1 0 07:03 ? 00:00:00 /usr/bin/abrt-watch-log -F BUG: WARNING: at WARNING: CPU: I
root 734 1 0 07:03 ? 00:00:00 /usr/libexec/bluetooth/bluetoothd
root 737 1 0 07:03 ? 00:00:15 /sbin/rngd -f
root 738 1 0 07:03 ? 00:00:00 /usr/sbin/ModemManager
root 740 1 0 07:03 ? 00:00:00 /usr/sbin/NetworkManager --no-daemon
root 741 1 0 07:03 ? 00:00:00 /usr/sbin/smartd -n -q never
root 747 1 0 07:03 ? 00:00:00 /usr/libexec/accounts-daemon
root 748 1 0 07:03 ? 00:00:00 /usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa
root 756 1 0 07:03 ? 00:00:01 /bin/bash /usr/sbin/ksmtuned
root 768 1 0 07:03 ? 00:00:00 /usr/sbin/gssproxy -D
root 844 2 0 07:03 ? 00:00:00 [kworker/3:1H]
memcach+ 983 1 0 07:03 ? 00:00:04 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024
root 986 1 0 07:03 ? 00:00:03 php-fpm: master process (/etc/php-fpm.conf)
root 987 1 0 07:03 ? 00:00:00 /usr/sbin/sshd -D
root 988 1 0 07:03 ? 00:00:00 /usr/sbin/cupsd -f
root 990 1 0 07:03 ? 00:00:06 /usr/bin/python -Es /usr/sbin/tuned -l -P
root 991 1 0 07:03 ? 00:00:00 /usr/sbin/rsyslogd -n
redis 992 1 0 07:03 ? 00:00:53 /usr/bin/redis-server 192.168.10.20:6379
root 1007 1 0 07:03 ? 00:00:04 /usr/sbin/httpd -DFOREGROUND
root 1009 1 0 07:03 ? 00:00:00 /usr/sbin/libvirtd
root 1011 1 0 07:03 ? 00:00:00 /usr/sbin/crond -n
root 1016 1 0 07:03 ? 00:00:00 /usr/sbin/atd -f
root 1021 1 0 07:03 ? 00:00:00 /usr/sbin/gdm
mysql 1176 1 0 07:03 ? 00:00:52 /usr/sbin/mysqld
apache 1246 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1247 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1248 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1249 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1255 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1298 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1299 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1300 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1301 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1302 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1304 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1305 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1307 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1308 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1309 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1313 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1315 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1316 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1317 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1321 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1324 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1325 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1331 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1332 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1338 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1342 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1343 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1344 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1349 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1351 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1352 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1353 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1354 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1355 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1359 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1362 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1365 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1367 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1371 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1376 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1378 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1379 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1383 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1388 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1392 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1398 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1400 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1407 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1435 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1438 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1440 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1444 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1449 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1452 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1456 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1461 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1465 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1469 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1471 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1476 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1478 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1480 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1484 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1490 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1491 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1492 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1495 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1498 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1506 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1508 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1513 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1515 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1519 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1522 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1524 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 1527 1 0 07:03 ? 00:00:00 /usr/libexec/postfix/master -w
apache 1528 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1529 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1530 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1535 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1539 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1541 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1545 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1554 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1558 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1559 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1561 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1565 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1568 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1572 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1576 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
postfix 1579 1527 0 07:03 ? 00:00:00 qmgr -l -t unix -u
apache 1580 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1584 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1589 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1594 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1599 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1603 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1606 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1608 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1615 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1617 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1619 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1621 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1624 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1625 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1628 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
nobody 1879 1 0 07:03 ? 00:00:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.
root 1882 1879 0 07:03 ? 00:00:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.
root 2512 1021 1 07:03 tty1 00:17:03 /usr/bin/Xorg :0 -background none -noreset -audit 4 -verbos
root 2571 1 0 07:03 ? 00:00:00 /usr/libexec/upowerd
colord 2603 1 0 07:03 ? 00:00:00 /usr/libexec/colord
root 2660 2 0 07:03 ? 00:00:00 [kworker/2:1H]
root 2716 1 0 07:03 ? 00:00:00 /usr/sbin/wpa_supplicant -u -f /var/log/wpa_supplicant.log
root 2720 1 0 07:03 ? 00:00:00 /usr/libexec/packagekitd
root 2766 1 0 07:03 ? 00:00:00 /usr/lib/udisks2/udisksd --no-debug
root 2868 1021 0 07:03 ? 00:00:00 gdm-session-worker [pam/gdm-password]
myth 2878 1 0 07:03 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login
myth 2884 2868 0 07:03 ? 00:00:00 gnome-session --session gnome-classic
myth 2891 1 0 07:03 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session
myth 2892 1 0 07:03 ? 00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --s
myth 2959 1 0 07:03 ? 00:00:00 /usr/libexec/gvfsd
myth 2964 1 0 07:03 ? 00:00:00 /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f -o big_write
myth 3049 2884 0 07:03 ? 00:00:00 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNO
myth 3071 1 0 07:03 ? 00:00:00 /usr/libexec/at-spi-bus-launcher
myth 3076 3071 0 07:03 ? 00:00:02 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.c
myth 3078 1 0 07:03 ? 00:00:02 /usr/libexec/at-spi2-registryd --use-gnome-session
myth 3092 2884 0 07:03 ? 00:00:03 /usr/libexec/gnome-settings-daemon
myth 3109 1 0 07:03 ? 00:00:00 /usr/bin/pulseaudio --start --log-target=syslog
root 3123 2 0 07:03 ? 00:00:00 [krfcommd]
myth 3131 2884 6 07:03 ? 00:54:28 /usr/bin/gnome-shell
myth 3136 1 0 07:03 ? 00:00:00 /usr/libexec/gsd-printer
myth 3185 3131 0 07:03 ? 00:00:05 ibus-daemon --xim --panel disable
myth 3190 3185 0 07:03 ? 00:00:00 /usr/libexec/ibus-dconf
myth 3192 1 0 07:03 ? 00:00:02 /usr/libexec/ibus-x11 --kill-daemon
myth 3200 1 0 07:03 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server
myth 3205 1 0 07:03 ? 00:00:00 /usr/libexec/evolution-source-registry
myth 3210 1 0 07:03 ? 00:00:00 /usr/libexec/goa-daemon
myth 3217 1 0 07:03 ? 00:00:03 /usr/libexec/goa-identity-service
myth 3230 1 0 07:03 ? 00:00:00 /usr/libexec/mission-control-5
myth 3232 1 0 07:03 ? 00:00:01 /usr/libexec/caribou
myth 3241 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-udisks2-volume-monitor
myth 3247 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
myth 3252 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-afc-volume-monitor
myth 3259 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-goa-volume-monitor
myth 3267 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
myth 3300 2884 0 07:03 ? 00:00:00 nautilus --no-default-window --force-desktop
myth 3307 2884 0 07:03 ? 00:00:00 /usr/libexec/tracker-miner-user-guides
myth 3309 2884 0 07:03 ? 00:00:00 /usr/bin/gnome-software --gapplication-service
myth 3313 1 0 07:03 ? 00:00:00 /usr/libexec/tracker-store
myth 3319 1 0 07:03 ? 00:01:16 /usr/bin/vmtoolsd -n vmusr
myth 3331 2884 0 07:03 ? 00:00:00 abrt-applet
myth 3341 2884 0 07:03 ? 00:00:00 /usr/libexec/tracker-extract
myth 3352 2884 0 07:03 ? 00:00:00 /usr/libexec/tracker-miner-apps
myth 3355 2884 0 07:03 ? 00:00:00 /usr/libexec/tracker-miner-fs
myth 3413 1 0 07:03 ? 00:00:00 /usr/libexec/gvfsd-trash --spawner :1.3 /org/gtk/gvfs/exec_
myth 3445 1 0 07:03 ? 00:00:00 /usr/libexec/evolution-calendar-factory
myth 3454 1 0 07:03 ? 00:00:00 /usr/libexec/gvfsd-metadata
myth 3466 3185 0 07:03 ? 00:00:01 /usr/libexec/ibus-engine-simple
myth 3510 1 0 07:03 ? 00:00:00 /bin/bash /home/myth/netbeans-8.2/platform/lib/nbexec --use
myth 3760 3510 1 07:03 ? 00:12:38 /home/myth/netbeans-8.2/bin/jre/bin/java -Djdk.home=/home/m
myth 3872 3131 7 07:03 ? 01:05:16 /usr/lib64/firefox/firefox
myth 3920 1 0 07:03 ? 00:00:00 /usr/libexec/gconfd-2
myth 3929 3872 0 07:04 ? 00:08:15 /usr/lib64/firefox/plugin-container -greomni /usr/lib64/fir
apache 4107 1007 0 07:04 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 5838 2 0 09:40 ? 00:00:02 [kworker/3:0]
root 5890 987 0 09:44 ? 00:00:00 sshd: root@pts/0
root 5894 5890 0 09:44 pts/0 00:00:00 -bash
root 5946 987 0 09:44 ? 00:00:00 sshd: root@pts/1
root 5948 5946 0 09:44 pts/1 00:00:00 -bash
root 6165 987 0 09:51 ? 00:00:00 sshd: root@pts/2
root 6175 6165 0 09:51 pts/2 00:00:00 -bash
myth 6437 1 0 10:04 ? 00:00:00 /usr/libexec/dconf-service
root 7694 2 0 11:50 ? 00:00:00 [kworker/3:2]
root 9376 2 0 14:10 ? 00:00:00 [kworker/2:1]
apache 9918 1007 0 14:54 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 9929 1007 0 14:55 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 9932 1007 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 9965 1007 0 14:58 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 9979 1007 0 14:59 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 11479 2 0 16:16 ? 00:00:00 [kworker/1:2H]
root 12088 6175 0 16:50 pts/2 00:00:00 redis-cli -h 127.0.0.1 -p 6379
root 12137 5894 0 16:52 pts/0 00:00:01 php public/index.php index/Socket/run
root 12147 12137 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12152 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12153 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12154 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12155 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 13570 2 0 19:00 ? 00:00:01 [kworker/1:1]
root 13973 5948 0 19:38 pts/1 00:00:00 tail -f /home/myth/www/think/apps/swoole-data/swoole.log
root 14426 2 0 20:20 ? 00:00:00 [kworker/u256:2]
root 14900 2 0 21:04 ? 00:00:00 [kworker/1:1H]
postfix 14973 1527 0 21:10 ? 00:00:00 pickup -l -t unix -u
root 15017 2 0 21:16 ? 00:00:00 [kworker/0:0]
root 15117 2 0 21:26 ? 00:00:00 [kworker/1:2]
root 15174 756 0 21:30 ? 00:00:00 sleep 60
root 15175 2 0 21:31 ? 00:00:00 [kworker/1:0]
root 15176 987 0 21:31 ? 00:00:00 sshd: root@pts/3
root 15178 15176 1 21:31 pts/3 00:00:00 -bash
root 15204 1 0 21:31 ? 00:00:00 /usr/sbin/abrt-dbus -t133
root 15232 15178 0 21:31 pts/3 00:00:00 ps -eaf
[root@contoso ~]#
ps -eaf |grep 'index/Socket/run'
root 12137 5894 0 16:52 pts/0 00:00:01 php public/index.php index/Socket/run
root 12147 12137 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12152 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12153 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12154 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12155 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 15259 15178 0 21:34 pts/3 00:00:00 grep --color=auto index/Socket/run
[root@contoso ~]# ps -eaf |grep 'index/Socket/run'|grep -v "grep"
root 12137 5894 0 16:52 pts/0 00:00:01 php public/index.php index/Socket/run
root 12147 12137 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12152 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12153 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12154 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12155 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
[root@contoso ~]# ps -eaf |grep 'index/Socket/run'|grep -v "grep"|awk '{print $2}'
12137
12147
12152
12153
12154
12155
[root@contoso ~]# ps -eaf |grep 'index/Socket/run'|grep -v "grep"|awk '{print $2}'|xargs
12137 12147 12152 12153 12154 12155
[root@contoso ~]#
ps -eaf |grep 'index/Socket/run'|grep -v "grep"|awk '{print $2}'|xargs kill -9
[root@contoso ~]# ps -eaf |grep 'index/Socket/run'|grep -v "grep"
[root@contoso ~]#
持续粘贴中 ... ... ... ...
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
EOF
或者
[root@corp ~]# sed -i -- 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@corp ~]# set SELINUX=disabled
[root@corp ~]# setenforce 0 ##不重启立刻关闭 SELINUX,设置 /var/log/mariadb 的权限为755 其文件夹内文件权限全部666,还报告mariadb-log-bin.index not found (Errcode: 13), 办法是设置文件夹mariadb与文件所属组chown -R mysql:mysql /var/log/mariadb &&
chown -R mysql:mysql /var/log/mariadb/*
[root@corp ~]# sestatus -v
SELinux status: disabled
[root@corp ~]#
[root@corp ~]# systemctl stop firewalld
[root@corp ~]# systemctl disable firewalld
[root@corp ~]# echo "192.168.10.20 corp.contoso.org" >> /etc/hosts
[root@corp ~]# echo "192.168.10.10 contoso.org" >> /etc/hosts
[root@corp ~]# echo `export PATH=$PATH:/usr/local/zend/bin` >> /etc/profile # 这是Zend Server 服务器下php指令全局性配置方法 可以不用它
[root@corp ~]# source /etc/profile
[root@corp ~]# tail -5 /etc/profile
unset i
unset -f pathmunge
export PATH=$PATH:/usr/local/zend/bin ## 配置PHP指令全局执行,例如执行指令 php -m
[root@corp ~]# more /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 corp.contoso.org
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.20 corp.contoso.org
192.168.10.10 contoso.org
[root@corp ~]# systemctl restart network # 不启动系统让hosts文件修改即刻生效
提示所有可用扩展软件包在此位置:http://rpms.remirepo.net/enterprise/7/php71/x86_64/
http://rpms.remirepo.net/wizard/ 安装PHP7.1 需要打开此链接
Operating system: CentOS 7
PHP version: 7.1.7(active support until Dec 2018)
Type of installation: Single version
Command to install the EPEL repository configuration package:
[root@corp ~]$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Command to install the Remi repository configuration package:
[root@corp ~]$ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Command to install the yum-utils package (for the yum-config-manager command):
[root@corp ~]$ sudo yum install yum-utils
Command to enable the repository:
[root@corp ~]$ sudo yum-config-manager --enable remi-php71
Command to upgrade (the repository only provides PHP):
[root@corp ~]$ sudo yum update
Command to install additional packages:
[root@corp ~]$ sudo yum --enablerepo=remi-php71,remi,epel -y install php php-devel php-mysql php-fpm php-pecl-xdebug php-gd php-intl php-freetype php-mcrypt php-mbstring
php-pecl-memcached php-pecl-redis php-pecl-swoole
[root@corp ~]$ sudo [b]yum[/b]--enablerepo=remi-php71,remi,epel -y install php-pecl-mongo
[root@corp ~]$ sudo [b]yum--enablerepo=remi-php71,remi,epel -y install php-simplexml php-xml php-zip[/b]
[root@corp ~]$ sudo [b]yum--enablerepo=remi-php71,remi,epel -y install php-gd php-freetype php-pecl-jpeg[/b]
// pChart
[root@corp ~]$ sudo [b]yum--enablerepo=remi-php71,remi,epel -y install php-pecl-geoip geoip[/b]
yum info geoip //查官网地址
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel -y install php-pecl-apcu
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel -y install nodejs npm
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel -y install php-intl
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel -y install php-pecl-zip
[root@corp ~]$ sudo [b]yum--enablerepo=remi-php71,remi,epel -y remove mariadb mariadb-server[/b]删掉5.5系列的
目前最新版才5.5.48
Command to check the installed version and available extensions:
[root@corp ~]$ php --version
[root@corp ~]$ php --modules
ls /etc/yum.repos.d
cat /etc/yum.repos.d/remi.repo
ls /etc/pki/rpm-gpg
https://www.digitalocean.com/community/tutorials/how-to-create-an-ssl-certificate-on-apache-for-centos-7
[root@corp ~]$ sudo
[b]yum [/b]--enablerepo=remi-php71,remi,epel install mod_ssl
[root@corp ~]$ sudo timedatectl status
Local time: Mon 2015-12-14 20:28:54 CST
Universal time: Mon 2015-12-14 12:28:54 UTC
RTC time: Mon 2015-12-14 12:28:54
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@corp ~]# su -
[root@corp ~]# vi /etc/php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = PRC
[root@corp ~]# ls /etc/httpd/conf.d/
autoindex.conf php.conf README userdir.conf welcome.conf
[root@corp ~]# cat /etc/httpd/conf.d/ssl.conf
[root@corp ~]# ls /etc/httpd/
conf conf.d conf.modules.d logs modules run
[root@corp ~]# mkdir /etc/httpd/ssl
[root@corp ~]# vi /etc/redis.conf
bind 192.168.10.30 127.0.0.1
[root@corp ~]# cat /etc/php-fpm.conf
[root@corp ~]# cat /etc/php-fpm.d/www.conf // 查看默认端口9000 listen = 127.0.0.1:9000
[root@corp ~]$ sudo
systemctl enable php-fpm.service
[root@corp ~]$ sudo systemctl enable httpd.service
[root@corp ~]$ sudo systemctl enable memcached.service
[root@corp ~]$ sudo systemctl enable redis.service
[root@corp ~]$ sudo systemctl restart php-fpm.service
[root@corp ~]$ sudo systemctl restart httpd.service
[root@corp ~]$ sudo systemctl restart memcached.service
[root@corp ~]$ sudo systemctl restart redis.service
[root@corp ~]$ sudo systemctl reboot
[root@corp ~]$ sudo reboot
[root@corp ~]$ sudo poweroff
[root@corp ~]# cat > /etc/php.d/15-xdebug.ini
; Enable xdebug extension module
zend_extension=xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
; see http://xdebug.org/docs/all_settings
Linux下Apache网站目录读写权限的设置
我们httpd服务器运行的用户和用户组是apache,网站用户myth(登录CentOS 7系统的开发用户名),网站根目录是/home/myth/www
第1步:
我们首先设定网站目录和文件的所有者和所有组为myth,apache,如下命令:
[myth@corp ~]$ mkdir www
[myth@corp ~]$ ll
total 0
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Desktop
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Documents
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Downloads
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Music
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Pictures
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Public
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Templates
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Videos
drwxrwxr-x 2 myth myth 6 Jul 31 09:39 www
[myth@corp ~]$ pwd
/home/myth
[myth@corp ~]$ su -
Password:
[root@corp ~]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 17564 root 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17565 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17566 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17568 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17570 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 17571 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
httpd 18759 apache 4u IPv6 90702 0t0 TCP *:http (LISTEN)
[root@corp ~]# pwd
/root
[root@corp ~]# [b]chmod 755 -R /home[b]/myth [/b][/b]##
find /home -type d -exec chmod 755 {} \;[b][/b]
[root@corp ~]# exit
logout
[myth@corp ~]$ pwd
/home/myth
[myth@corp ~]$ ll /home
total 4
drwxr-xr-x. 16 myth myth 4096 Jul 31 18:34 myth
[myth@corp ~]$
[myth@corp ~]$ ll /home/myth
total 0
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Desktop
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Documents
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Download
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Music
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Pictures
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Public
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Templates
drwxr-xr-x. 2 myth myth 6 Jul 30 15:46 Videos
drwxr-xr-x 3 myth myth 19 Jul 31 19:04 www
[myth@corp ~]$
全局[b]性composer命令安装(myth和www权限设置后下面安装composer才不会出现写文件没有权限)[/b]
https://pkg.phpcomposer.com/
打开命令行并依次执行下列命令安装最新版本的 Composer:
[root@corp ~]$ sudo
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
[root@corp ~]$ sudo php composer-setup.php
[root@corp ~]$ sudo php -r "unlink('composer-setup.php');"
[root@corp ~]$ sudo mv composer.phar /usr/local/bin/composer
[root@corp ~]$ sudo composer config -g repo.packagist composer https://packagist.phpcomposer.com
不要忘了经常执行 composer selfupdate 以保持 Composer 一直是最新版本
第2步:ThinkPHP5.0安装
[myth@corp ~]$
cd /home/myth/www && composer create-project topthink/think think --prefer-dist ## 克隆下载应用项目think,官网这里用的是tp5 ------ 对应最后那个think;隐含克隆核心框架framework自动更名为thinkphp
第3步:
设置网站目录权限为750,750是myth用户对目录拥有读写执行的权限,这样myth用户
可以在任何目录下创建文件,用户组有有读执行权限,这样才能进入目录,其它用户没有任何权限。
[myth@corp ~]$ cd /home/myth/www
[myth@corp ~]$ find /home/myth/www -type d -exec ls -l {} \; ## 注释 上一行 cd /home/myth/www命令可以不用执行,因为指定了搜索目录/home/myth/www 提前查询think项目没被修改时所有子目录和文件的默认权限
[myth@corp ~]$ chown -R myth:myth /home/myth/www
[myth@corp ~]$ find /home/myth/www -type d -exec chmod 775 {} \; ## 注释说明 {} 表示查询结果 内容是/home/myth/www目录下的所有子目录,设置每个子目录的权限为750,开发时需要775
第4步:
设置网站文件权限为640,640指只有myth用户对网站文件有更改的权限,http服务器只
有读取文件的权限,无法更改文件,其它用户无任何权限。
[myth@corp ~]$ [b]find /home/myth/www -not -type d -exec chmod 664 {} \; [/b]##
设置每个子目录下所有文件的权限为640,开发时需要664
第5步:
针对个别目录设置可写权限。比如网站的一些缓存目录就需要给http服务有写入权限。
例如discuz x2的/data/目录就必须要写入权限。
find data -type d -exec chmod 770 {} \;
清空日志文件的内容: [myth@corp ~]$ rm -rf /home/myth/log/httpd && mkdir -p /home/myth/log/httpd
##清空日志可直接删掉日志文件
[root@corp ~]$ cat /dev/null > /home/myth/log/httpd/user-corp-contoso-error_log && cat /dev/null > /home/myth/log/httpd/user-corp-contoso-access_log
[root@corp ~]#$ cat /dev/null > /home/myth/log/httpd/corp-contoso-error_log && cat /dev/null > /home/myth/log/httpd/corp-contoso-access_log
[root@corp ~]#$ cat /dev/null > /home/myth/log/httpd/contoso-error_log && cat /dev/null > /home/myth/log/httpd/contoso-access_log
实时跟踪日志内容:
[root@corp ~]$tail -f[b]/home/myth/log/httpd/user-corp-contoso-error_log
[/b][root@corp ~]$tail -f[b]/home/myth/log/httpd/user-corp-contoso-access_log[/b]
[root@corp ~]$tail -f[b]/home/myth/log/httpd/corp-contoso-error_log
[/b][root@corp ~]$tail -f[b]/home/myth/log/httpd/corp-contoso-access_log[/b]
[root@corp ~]$tail -f[b]/home/myth/log/httpd/contoso-error_log
[/b][root@corp ~]$ tail -f[b]/home/myth/log/httpd/contoso-access_log[/b]
[b]在Cent OS 7.x系统上配置虚拟主机(root账户下):[/b]
[root@contoso ~]#[b] cat > /etc/httpd/conf.d/httpd-vhosts.conf ## 配置虚拟主
<Directory "/var/www/html/SPRabbitMQ">
Options +Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin zhengzizhi@126.com
DocumentRoot "/var/www/html/SPRabbitMQ/app"
ServerName contoso.com
ServerAlias contoso.com
ErrorLog "/var/log/httpd/contoso-error_log"
CustomLog "/var/log/httpd/contoso-access_log" common
</VirtualHost>
[/b]
在Cent OS 7.x系统上配置虚拟主机(非root账户下):
#注意:日志文件的目录需要提前创建好,如果发现No such file or directory: AH02291: Cannot access directory '/home/myth/log/httpd/' for error log of vhost 这样的错误
退出root用户操作环境,进入到myth用户$提示符环境下 [myth@corp ~]$ rm -rf /home/myth/log/httpd && mkdir -p /home/myth/log/httpd 执行此条命令即可解决 请再一次地注意生成的日志文件
拥有者和用户组均属于root 而不是myth用户和myth用户组
[myth@corp ~]$
[myth@corp ~]$ mkdir -p /home/myth/log/httpd #注意:日志文件的目录需要提前创建好,
[myth@corp ~]$ touch /home/myth/log/httpd/user-corp-contoso-error_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/user-corp-contoso-access_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/corp-contoso-error_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/corp-contoso-access_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/contoso-error_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ touch /home/myth/log/httpd/contoso-access_log # 不需要执行此行指令,就会自动生成这个日志文件
[myth@corp ~]$ su -
Password:
[root@corp ~]# cat > /etc/httpd/conf.d/httpd-vhosts.conf ## 配置虚拟主机
<Directory "/home/myth/www/think">
Options +Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin zhengzizhi@126.com
DocumentRoot "/home/myth/www/think/public"
ServerName contoso.org
ServerAlias contoso.org
ErrorLog "/home/myth/log/httpd/contoso-error_log"
CustomLog "/home/myth/log/httpd/contoso-access_log" common
</VirtualHost>
<Directory "/home/myth/www/think">
Options +Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin zhengzizhi@126.com
DocumentRoot "/home/myth/www/think/public"
ServerName corp.contoso.org
ServerAlias corp.contoso.org
ErrorLog "/home/myth/log/httpd/corp-contoso-error_log"
CustomLog "/home/myth/log/httpd/corp-contoso-access_log" common
</VirtualHost>
<Directory "/home/myth/www/think">
Options +Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin zhengzizhi@126.com
DocumentRoot "/home/myth/www/think/public"
ServerName user.corp.contoso.org
ServerAlias user.corp.contoso.org
ErrorLog "/home/myth/log/httpd/user-corp-contoso-error_log"
CustomLog "/home/myth/log/httpd/user-corp-contoso-access_log" common
</VirtualHost>
配置域名与IP地址的映射关系,一个域名只能对应一个IP地址,但是一个IP可以对应多个域名
[root@corp ~]# cat > /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 contoso.org
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.20 user.corp.contoso.org
192.168.10.20 corp.contoso.org
192.168.10.20 contoso.org
[root@corp ~]# echo 'contoso.org' > /etc/hostname ## 编辑文件设置主机名,等价命令 hostnamectl set-hostname contoso.org
[root@corp ~]#
在配置文件/etc/httpd/conf/httpd.conf中,我们只需要改下面这行参数值即可,其它参数值保留默认配置:
[root@corp ~]# sed -i -- 's/^#ServerName www.example.com:80/ServerName contoso.org:80/g' /etc/httpd/conf/httpd.conf
[root@contoso ~]# systemctl restart httpd && systemctl restart network && httpd -S
VirtualHost configuration:
*:80 is a NameVirtualHost
default server contoso.org (/etc/httpd/conf.d/httpd-vhosts.conf:9)
port 80 namevhost contoso.org (/etc/httpd/conf.d/httpd-vhosts.conf:9)
alias contoso.org
port 80 namevhost corp.contoso.org (/etc/httpd/conf.d/httpd-vhosts.conf:26)
alias corp.contoso.org
port 80 namevhost user.corp.contoso.org (/etc/httpd/conf.d/httpd-vhosts.conf:43)
alias user.corp.contoso.org
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
[root@contoso ~]#
测试一下网站的访问地址:http://corp.contoso.org,此刻默认主页会显示出来!,如果默认页都无权限访问
那么从[b]mkdir www 到 [b]
[b]chmod 755 -R /home[b]/myth[/b][/b]这两步权限就分配错了
[/b][/b]
[b]大多数人这里根本就没设置权限 开头就错了 后面日志报告权限错误 默认页无权限显示就跟这有关[/b]
[b][b][b][b][b][b]myth[/b][/b][/b][/b]是我的登录系统的管理员用户 默认myth文件夹[b]权限[/b]很低[/b]
[/b]
安装MariaDB
官网给出的baseurl地址下载太慢了
[root@contoso ~]# cat > /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2 CentOS repository list - created 2017-07-08 12:50 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
清华baseurl下载速度很快
[root@contoso ~]# cat > /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2 CentOS repository list - created 2017-07-08 12:50 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-10.2.7/yum/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@contoso ~]# more /etc/yum.repos.d/MariaDB.repo
[root@contoso ~]# yum install -y MariaDB-server MariaDB-client
[root@contoso ~]# find / -name *.cnf
/etc/pki/tls/openssl.cnf
/etc/my.cnf
/etc/my.cnf.d/mysql-clients.cnf
/etc/my.cnf.d/server.cnf
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/wsrep.cnf
[root@contoso ~]# more /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[root@contoso ~]# more /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.1 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.1]
[root@contoso ~]#
[root@contoso ~]# mkdir -p /var/log/mariadb && touch /var/log/mariadb/queries.log && touch /var/log/mariadb/mariadb-error.log && touch /var/log/mariadb/mariadb-slow.log && touch /var/log/mariadb/mariadb-log-bin && touch /var/log/mariadb/mariadb-log-bin.index
&& chown -R mysql:mysql /var/log/mariadb && chmod 755 /var/log/mariadb && chmod 666 /var/log/mariadb/*
[root@contoso ~]#
[root@contoso ~]# cat > /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
character-set-server=utf8
lower-case-table-names=1
log-bin=/var/log/mariadb/mariadb-log-bin
log-bin-index=/var/log/mariadb/mariadb-log-bin.index
log-error=/var/log/mariadb/mariadb-error.log
general-log=ON
general-log-file=/var/log/mariadb/queries.log
log-output=file
slow-query-log=ON
slow-query-log-file=/var/log/mariadb/mariadb-slow.log
long_query_time=1
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.1 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.1]
[root@contoso ~]#
清空日志,实时跟踪日志文件
ll /var/log/mariadb
cat /etc/my.cnf.d/server.cnf
cat /dev/null > /var/log/mariadb/queries.log && cat /dev/null > /var/log/mariadb/mariadb-slow.log && cat /dev/null > /var/log/mariadb/mariadb-error.log
tail -f /var/log/mariadb/queries.log
tail -f /var/log/mariadb/mariadb-slow.log
tail -f /var/log/mariadb/mariadb-error.log
rm -f /var/log/mariadb/*
mysql -uroot -p123456 -h127.0.0.1 -e "reset master" # 清空bin_log日志
[root@contoso ~]# service mysql start
Starting mysql (via systemctl): [ OK ]
[root@contoso ~]# mysql -uroot -h127.0.0.1 -e"show variables like 'character%'"
[root@contoso ~]# mysql -uroot -p123456 -h127.0.0.1 -e"show variables like 'character%'"
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
[root@contoso ~]#/usr/bin/mysql_secure_installation
[root@contoso ~]# mysql -uroot -p123456 -h127.0.0.1
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.2.6-MariaDB-log MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> USE 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]> SELECT host,user FROM user;
+-----------+------+
| host | user |
+-----------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)
MariaDB [mysql]> GRANT ALL ON *.* TO 'root'@'192.168.10.20' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> SELECT host,user FROM user;
+---------------+------+
| host | user |
+---------------+------+
| % | root |
| 127.0.0.1 | root |
| 192.168.10.20 | root |
| ::1 | root |
| contoso.org | root |
| localhost | root |
+---------------+------+
6 rows in set (0.00 sec)
MariaDB [mysql]>
MariaDB [mysql]> quit
Bye
[root@contoso ~]#
另外一种编码配置方式 ------- 表情小图片(是一种字符)使用的编码方式:
[root@contoso ~]# vi /etc/my.cnf.d/client.cnf
#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
default-character-set=utf8mb4
# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
default-character-set=utf8mb4
[root@contoso ~]# vi /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
lower-case-table-names=1
sql-mode="STRICT_TRANS_TABLES"
log-bin=/var/log/mariadb/mariadb-log-bin
log-bin-index=/var/log/mariadb/mariadb-log-bin.index
log-error=/var/log/mariadb/mariadb-error.log
general-log=ON
general-log-file=/var/log/mariadb/queries.log
log-output=file
slow-query-log=ON
slow-query-log-file=/var/log/mariadb/mariadb-slow.log
long_query_time=1
log-queries-not-using-indexes=ON
# this is only for embedded server
[embedded]
# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]
# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
[mariadb-5.5]
[root@contoso ~]# systemctl restart mariadb
[root@contoso ~]# mysql
MariaDB [(none)]> use mysql;
MariaDB [(none)]> SHOW VARIABLES LIKE 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
MariaDB [(none)]> SHOW VARIABLES LIKE '%collation%';
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+----------------------+--------------------+
3 rows in set (0.00 sec)
查看一下你的Apache的执行用户是谁: lsof -i:80
[root@contoso ~]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 11665 root 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29276 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29277 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29278 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29279 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29280 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29281 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
httpd 29398 apache 4u IPv6 91552 0t0 TCP *:http (LISTEN)
[root@contoso ~]#
查看apache 的运行的用户
[root@contoso ~]# ps -ef |grep httpd
root 4030 1 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4034 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4035 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4036 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4037 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 4039 4030 0 11:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 4092 3934 0 11:54 pts/0 00:00:00 grep --color=auto httpd
[root@contoso ~]#
直接在httpd.conf配置文件查看apache执行用户和组,在以下红色字体标识的66行和67行:
[root@contoso ~]# cat -n /etc/httpd/conf/httpd.conf
1 #
2 # This is the main Apache HTTP server configuration file. It contains the
3 # configuration directives that give the server its instructions.
4 # See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
5 # In particular, see
6 # <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
7 # for a discussion of each configuration directive.
8 #
9 # Do NOT simply read the instructions in here without understanding
10 # what they do. They're here only as hints or reminders. If you are unsure
11 # consult the online docs. You have been warned.
12 #
13 # Configuration and logfile names: If the filenames you specify for many
14 # of the server's control files begin with "/" (or "drive:/" for Win32), the
15 # server will use that explicit path. If the filenames do *not* begin
16 # with "/", the value of ServerRoot is prepended -- so 'log/access_log'
17 # with ServerRoot set to '/www' will be interpreted by the
18 # server as '/www/log/access_log', where as '/log/access_log' will be
19 # interpreted as '/log/access_log'.
20
21 #
22 # ServerRoot: The top of the directory tree under which the server's
23 # configuration, error, and log files are kept.
24 #
25 # Do not add a slash at the end of the directory path. If you point
26 # ServerRoot at a non-local disk, be sure to specify a local disk on the
27 # Mutex directive, if file-based mutexes are used. If you wish to share the
28 # same ServerRoot for multiple httpd daemons, you will need to change at
29 # least PidFile.
30 #
31 ServerRoot "/etc/httpd"
32
33 #
34 # Listen: Allows you to bind Apache to specific IP addresses and/or
35 # ports, instead of the default. See also the <VirtualHost>
36 # directive.
37 #
38 # Change this to Listen on specific IP addresses as shown below to
39 # prevent Apache from glomming onto all bound IP addresses.
40 #
41 #Listen 12.34.56.78:80
42 Listen 80
43
44 #
45 # Dynamic Shared Object (DSO) Support
46 #
47 # To be able to use the functionality of a module which was built as a DSO you
48 # have to place corresponding `LoadModule' lines at this location so the
49 # directives contained in it are actually available _before_ they are used.
50 # Statically compiled modules (those listed by `httpd -l') do not need
51 # to be loaded here.
52 #
53 # Example:
54 # LoadModule foo_module modules/mod_foo.so
55 #
56 Include conf.modules.d/*.conf
57
58 #
59 # If you wish httpd to run as a different user or group, you must run
60 # httpd as root initially and it will switch.
61 #
62 # User/Group: The name (or #number) of the user/group to run httpd as.
63 # It is usually good practice to create a dedicated user and group for
64 # running httpd, as with most system services.
65 #
66 User apache
67 Group apache
68
69 # 'Main' server configuration
70 #
71 # The directives in this section set up the values used by the 'main'
72 # server, which responds to any requests that aren't handled by a
73 # <VirtualHost> definition. These values also provide defaults for
74 # any <VirtualHost> containers you may define later in the file.
75 #
76 # All of these directives may appear inside <VirtualHost> containers,
77 # in which case these default settings will be overridden for the
78 # virtual host being defined.
79 #
80
81 #
82 # ServerAdmin: Your address, where problems with the server should be
83 # e-mailed. This address appears on some server-generated pages, such
84 # as error documents. e.g. admin@your-domain.com
85 #
86 ServerAdmin root@localhost
87
88 #
89 # ServerName gives the name and port that the server uses to identify itself.
90 # This can often be determined automatically, but we recommend you specify
91 # it explicitly to prevent problems during startup.
92 #
93 # If your host doesn't have a registered DNS name, enter its IP address here.
94 #
95 ServerName corp.contoso.org:80
96
97 #
98 # Deny access to the entirety of your server's filesystem. You must
99 # explicitly permit access to web content directories in other
100 # <Directory> blocks below.
101 #
102 <Directory />
103 AllowOverride none
104 Require all denied
105 </Directory>
106
107 #
108 # Note that from this point forward you must specifically allow
109 # particular features to be enabled - so if something's not working as
110 # you might expect, make sure that you have specifically enabled it
111 # below.
112 #
113
114 #
115 # DocumentRoot: The directory out of which you will serve your
116 # documents. By default, all requests are taken from this directory, but
117 # symbolic links and aliases may be used to point to other locations.
118 #
119 DocumentRoot "/var/www/html"
120
121 #
122 # Relax access to content within /var/www.
123 #
124 <Directory "/var/www">
125 AllowOverride None
126 # Allow open access:
127 Require all granted
128 </Directory>
129
130 # Further relax access to the default document root:
131 <Directory "/var/www/html">
132 #
133 # Possible values for the Options directive are "None", "All",
134 # or any combination of:
135 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
136 #
137 # Note that "MultiViews" must be named *explicitly* --- "Options All"
138 # doesn't give it to you.
139 #
140 # The Options directive is both complicated and important. Please see
141 # http://httpd.apache.org/docs/2.4/mod/core.html#options
142 # for more information.
143 #
144 Options Indexes FollowSymLinks
145
146 #
147 # AllowOverride controls what directives may be placed in .htaccess files.
148 # It can be "All", "None", or any combination of the keywords:
149 # Options FileInfo AuthConfig Limit
150 #
151 AllowOverride None
152
153 #
154 # Controls who can get stuff from this server.
155 #
156 Require all granted
157 </Directory>
158
159 #
160 # DirectoryIndex: sets the file that Apache will serve if a directory
161 # is requested.
162 #
163 <IfModule dir_module>
164 DirectoryIndex index.html
165 </IfModule>
166
167 #
168 # The following lines prevent .htaccess and .htpasswd files from being
169 # viewed by Web clients.
170 #
171 <Files ".ht*">
172 Require all denied
173 </Files>
174
175 #
176 # ErrorLog: The location of the error log file.
177 # If you do not specify an ErrorLog directive within a <VirtualHost>
178 # container, error messages relating to that virtual host will be
179 # logged here. If you *do* define an error logfile for a <VirtualHost>
180 # container, that host's errors will be logged there and not here.
181 #
182 ErrorLog "logs/error_log"
183
184 #
185 # LogLevel: Control the number of messages logged to the error_log.
186 # Possible values include: debug, info, notice, warn, error, crit,
187 # alert, emerg.
188 #
189 LogLevel warn
190
191 <IfModule log_config_module>
192 #
193 # The following directives define some format nicknames for use with
194 # a CustomLog directive (see below).
195 #
196 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
197 LogFormat "%h %l %u %t \"%r\" %>s %b" common
198
199 <IfModule logio_module>
200 # You need to enable mod_logio.c to use %I and %O
201 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
202 </IfModule>
203
204 #
205 # The location and format of the access logfile (Common Logfile Format).
206 # If you do not define any access logfiles within a <VirtualHost>
207 # container, they will be logged here. Contrariwise, if you *do*
208 # define per-<VirtualHost> access logfiles, transactions will be
209 # logged therein and *not* in this file.
210 #
211 #CustomLog "logs/access_log" common
212
213 #
214 # If you prefer a logfile with access, agent, and referer information
215 # (Combined Logfile Format) you can use the following directive.
216 #
217 CustomLog "logs/access_log" combined
218 </IfModule>
219
220 <IfModule alias_module>
221 #
222 # Redirect: Allows you to tell clients about documents that used to
223 # exist in your server's namespace, but do not anymore. The client
224 # will make a new request for the document at its new location.
225 # Example:
226 # Redirect permanent /foo http://www.example.com/bar
227
228 #
229 # Alias: Maps web paths into filesystem paths and is used to
230 # access content that does not live under the DocumentRoot.
231 # Example:
232 # Alias /webpath /full/filesystem/path
233 #
234 # If you include a trailing / on /webpath then the server will
235 # require it to be present in the URL. You will also likely
236 # need to provide a <Directory> section to allow access to
237 # the filesystem path.
238
239 #
240 # ScriptAlias: This controls which directories contain server scripts.
241 # ScriptAliases are essentially the same as Aliases, except that
242 # documents in the target directory are treated as applications and
243 # run by the server when requested rather than as documents sent to the
244 # client. The same rules about trailing "/" apply to ScriptAlias
245 # directives as to Alias.
246 #
247 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
248
249 </IfModule>
250
251 #
252 # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
253 # CGI directory exists, if you have that configured.
254 #
255 <Directory "/var/www/cgi-bin">
256 AllowOverride None
257 Options None
258 Require all granted
259 </Directory>
260
261 <IfModule mime_module>
262 #
263 # TypesConfig points to the file containing the list of mappings from
264 # filename extension to MIME-type.
265 #
266 TypesConfig /etc/mime.types
267
268 #
269 # AddType allows you to add to or override the MIME configuration
270 # file specified in TypesConfig for specific file types.
271 #
272 #AddType application/x-gzip .tgz
273 #
274 # AddEncoding allows you to have certain browsers uncompress
275 # information on the fly. Note: Not all browsers support this.
276 #
277 #AddEncoding x-compress .Z
278 #AddEncoding x-gzip .gz .tgz
279 #
280 # If the AddEncoding directives above are commented-out, then you
281 # probably should define those extensions to indicate media types:
282 #
283 AddType application/x-compress .Z
284 AddType application/x-gzip .gz .tgz
285
286 #
287 # AddHandler allows you to map certain file extensions to "handlers":
288 # actions unrelated to filetype. These can be either built into the server
289 # or added with the Action directive (see below)
290 #
291 # To use CGI scripts outside of ScriptAliased directories:
292 # (You will also need to add "ExecCGI" to the "Options" directive.)
293 #
294 #AddHandler cgi-script .cgi
295
296 # For type maps (negotiated resources):
297 #AddHandler type-map var
298
299 #
300 # Filters allow you to process content before it is sent to the client.
301 #
302 # To parse .shtml files for server-side includes (SSI):
303 # (You will also need to add "Includes" to the "Options" directive.)
304 #
305 AddType text/html .shtml
306 AddOutputFilter INCLUDES .shtml
307 </IfModule>
308
309 #
310 # Specify a default charset for all content served; this enables
311 # interpretation of all content as UTF-8 by default. To use the
312 # default browser choice (ISO-8859-1), or to allow the META tags
313 # in HTML content to override this choice, comment out this
314 # directive:
315 #
316 AddDefaultCharset UTF-8
317
318 <IfModule mime_magic_module>
319 #
320 # The mod_mime_magic module allows the server to use various hints from the
321 # contents of the file itself to determine its type. The MIMEMagicFile
322 # directive tells the module where the hint definitions are located.
323 #
324 MIMEMagicFile conf/magic
325 </IfModule>
326
327 #
328 # Customizable error responses come in three flavors:
329 # 1) plain text 2) local redirects 3) external redirects
330 #
331 # Some examples:
332 #ErrorDocument 500 "The server made a boo boo."
333 #ErrorDocument 404 /missing.html
334 #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
335 #ErrorDocument 402 http://www.example.com/subscription_info.html
336 #
337
338 #
339 # EnableMMAP and EnableSendfile: On systems that support it,
340 # memory-mapping or the sendfile syscall may be used to deliver
341 # files. This usually improves server performance, but must
342 # be turned off when serving from networked-mounted
343 # filesystems or if support for these functions is otherwise
344 # broken on your system.
345 # Defaults if commented: EnableMMAP On, EnableSendfile Off
346 #
347 #EnableMMAP off
348 EnableSendfile on
349
350 # Supplemental configuration
351 #
352 # Load config files in the "/etc/httpd/conf.d" directory, if any.
353 IncludeOptional conf.d/*.conf
[root@contoso ~]#
/var/www/think/thinkphp/library/think/template/driver/File.php
开启./etc/php.ini 配置文件中 display_errors = On 参数项 ,只在开发的时候开启此项
display_errors = On开启后会捕获以下错误,header会返回status 500 Server error:
PHP Fatal error: Uncaught think\\exception\\ErrorException: mkdir(): Permission denied in /home/myth/www/think/thinkphp/library/think/log/driver/File.php
实际原因是/home/myth/www/think/runtime目录是由httpd服务的用户来读写,默认不是apache这个账户来读写,所以就抛出了没有创建目录的权限,类似也有写这个目录的权限没有,也需要向下面这样改变runtime的读写用户和组
[root@contoso ~]# chown -R apache:apache /home/myth/www/think/runtime && ll /home/myth/www/think
total 28
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[myth@contoso ~]$
[myth@contoso ~]$ ll -a /home/myth/www/think/public
total 24
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 .
drwxrwxr-x 9 myth myth 249 Jul 31 23:36 ..
-rw-rw-r-- 1 myth myth 203 Aug 1 00:36 admin.php
-rw-rw-r-- 1 myth myth 1150 Jul 4 11:52 favicon.ico
-rw-rw-r-- 1 myth myth 216 Jul 4 11:52 .htaccess
-rw-rw-r-- 1 myth myth 759 Jul 31 23:37 index.php
-rw-rw-r-- 1 myth myth 24 Jul 4 11:52 robots.txt
-rw-rw-r-- 1 myth myth 736 Jul 4 11:52 router.php
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 static
[myth@contoso ~]$
[myth@contoso ~]$ cat /home/myth/www/think/public/.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
[myth@contoso ~]$
CentOS7.2 安装Chrome
[root@contoso ~]# cat > /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
[root@contoso ~]# yum install -y google-chrome-stable --nogpgcheck
[root@contoso ~]# cat > /usr/bin/google-chrome
#!/bin/bash
#
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Let the wrapped binary know that it has been run through the wrapper.
export CHROME_WRAPPER="`readlink -f "$0"`"
HERE="`dirname "$CHROME_WRAPPER"`"
# We include some xdg utilities next to the binary, and we want to prefer them
# over the system versions when we know the system versions are very old. We
# detect whether the system xdg utilities are sufficiently new to be likely to
# work for us by looking for xdg-settings. If we find it, we leave $PATH alone,
# so that the system xdg utilities (including any distro patches) will be used.
if ! which xdg-settings &> /dev/null; then
# Old xdg utilities. Prepend $HERE to $PATH to use ours instead.
export PATH="$HERE:$PATH"
else
# Use system xdg utilities. But first create mimeapps.list if it doesn't
# exist; some systems have bugs in xdg-mime that make it fail without it.
xdg_app_dir="${XDG_DATA_HOME:-$HOME/.local/share/applications}"
mkdir -p "$xdg_app_dir"
[ -f "$xdg_app_dir/mimeapps.list" ] || touch "$xdg_app_dir/mimeapps.list"
fi
# Always use our versions of ffmpeg libs.
# This also makes RPMs find the compatibly-named library symlinks.
if [[ -n "$LD_LIBRARY_PATH" ]]; then
LD_LIBRARY_PATH="$HERE:$HERE/lib:$LD_LIBRARY_PATH"
else
LD_LIBRARY_PATH="$HERE:$HERE/lib"
fi
export LD_LIBRARY_PATH
export CHROME_VERSION_EXTRA="stable"
# We don't want bug-buddy intercepting our crashes. http://crbug.com/24120
export GNOME_DISABLE_CRASH_DIALOG=SET_BY_GOOGLE_CHROME
# Sanitize std{in,out,err} because they'll be shared with untrusted child
# processes (http://crbug.com/376567).
exec < /dev/null
exec > >(exec cat)
exec 2> >(exec cat >&2)
# Make sure that the profile directory specified in the environment, if any,
# overrides the default.
if [[ -n "$CHROME_USER_DATA_DIR" ]]; then
# Note: exec -a below is a bashism.
exec -a "$0" "$HERE/chrome" \
--user-data-dir="$CHROME_USER_DATA_DIR" "$@"
else
exec -a "$0" "$HERE/chrome" "$@" --no-sandbox --user-data-dir
fi
[root@contoso ~]#
chrome://extensions/
https://chrome.google.com/webstore/search/postman?hl=en-US
REST请求伪装
[root@contoso ~]# cat > index.html
<form method="post" class="form" action="http://contoso.org/blogs/2">
<input type="submit" class="btn" value=" 删除 ">
<input type="hidden" name="_method" value="DELETE" />
</form>
[root@contoso ~]#
API调试
可以使用ThinkPHP5.0 的Trace 调试中的Socket 调试功能来解决API 开发的调试问题。
SocketLog安装方法
[root@contoso ~]# yum install -y epel-release nodejs npm
[root@contoso ~]# npm install -g socketlog-server
[root@contoso ~]#
netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2025/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1168/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1140/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1724/master
tcp 0 0 0.0.0.0:10081 0.0.0.0:* LISTEN 2708/lighttpd
tcp 0 0 0.0.0.0:10082 0.0.0.0:* LISTEN 2708/lighttpd
tcp 0 0 127.0.0.1:10083 0.0.0.0:* LISTEN 2585/httpd
tcp 0 0 127.0.0.1:56220 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 192.168.10.10:52650 52.87.97.207:443 ESTABLISHED 4046/chrome --no-sa
tcp 0 96 192.168.10.10:22 192.168.10.1:57798 ESTABLISHED 7158/sshd: root@pts
tcp 0 0 127.0.0.1:56222 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 127.0.0.1:56218 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 192.168.10.10:22 192.168.10.1:56761 ESTABLISHED 6944/sshd: root@pts
tcp 0 1 192.168.10.10:42922 74.125.204.138:443 SYN_SENT 4046/chrome --no-sa
tcp 0 0 192.168.10.10:22 192.168.10.1:51318 ESTABLISHED 5673/sshd: root@pts
tcp 0 0 127.0.0.1:56216 127.0.0.1:10083 TIME_WAIT -
tcp 0 1 192.168.10.10:42920 74.125.204.138:443 SYN_SENT 4046/chrome --no-sa
tcp6 0 0 :::3306 :::* LISTEN 1372/mysqld
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::20080 :::* LISTEN 3872/java
tcp6 0 0 :::80 :::* LISTEN 2585/httpd
tcp6 0 0 :::22 :::* LISTEN 1168/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1140/cupsd
tcp6 0 0 :::10137 :::* LISTEN 3872/java
tcp6 0 0 ::1:25 :::* LISTEN 1724/master
tcp6 0 0 :::28029 :::* LISTEN 3872/java
tcp6 0 0 :::9000 :::* LISTEN 3872/java
tcp6 0 0 :::9001 :::* LISTEN 3872/java
tcp6 0 0 192.168.10.10:3306 192.168.10.1:51051 ESTABLISHED 1372/mysqld
tcp6 0 0 192.168.10.10:3306 192.168.10.1:51053 ESTABLISHED 1372/mysqld
[root@contoso ~]#
[root@contoso ~]# socketlog-server
SocketLog started success
[root@contoso ~]# netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2025/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1168/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1140/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1724/master
tcp 0 0 0.0.0.0:10081 0.0.0.0:* LISTEN 2708/lighttpd
tcp 0 0 0.0.0.0:10082 0.0.0.0:* LISTEN 2708/lighttpd
tcp 0 0 127.0.0.1:10083 0.0.0.0:* LISTEN 2585/httpd
tcp 0 0 192.168.10.10:52650 52.87.97.207:443 ESTABLISHED 4046/chrome --no-sa
tcp 0 96 192.168.10.10:22 192.168.10.1:57798 ESTABLISHED 7158/sshd: root@pts
tcp 0 0 127.0.0.1:56270 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 127.0.0.1:56268 127.0.0.1:10083 TIME_WAIT -
tcp 0 0 192.168.10.10:22 192.168.10.1:56761 ESTABLISHED 6944/sshd: root@pts
tcp 0 0 192.168.10.10:22 192.168.10.1:51318 ESTABLISHED 5673/sshd: root@pts
tcp6 0 0 :::3306 :::* LISTEN 1372/mysqld
tcp6 0 0 :::1229 :::* LISTEN 7442/node
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::20080 :::* LISTEN 3872/java
tcp6 0 0 :::80 :::* LISTEN 2585/httpd
tcp6 0 0 :::22 :::* LISTEN 1168/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1140/cupsd
tcp6 0 0 :::10137 :::* LISTEN 3872/java
tcp6 0 0 ::1:25 :::* LISTEN 1724/master
tcp6 0 0 :::1116 :::* LISTEN 7442/node
tcp6 0 0 :::28029 :::* LISTEN 3872/java
tcp6 0 0 :::9000 :::* LISTEN 3872/java
tcp6 0 0 :::9001 :::* LISTEN 3872/java
tcp6 0 0 192.168.10.10:3306 192.168.10.1:51051 ESTABLISHED 1372/mysqld
tcp6 0 0 192.168.10.10:3306 192.168.10.1:51053 ESTABLISHED 1372/mysqld
[root@contoso ~]#
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
return [
// +----------------------------------------------------------------------
// | 应用设置
// +----------------------------------------------------------------------
// 应用命名空间
'app_namespace' => 'app',
// 应用调试模式
'app_debug' => true,
// 应用Trace
// 'app_trace' => false,
// 开启应用Trace调试
'app_trace' => true,
// 设置Trace显示方式
'trace' => [
// 在当前Html页面显示Trace信息
'type' => 'html',
],
// 应用模式状态
'app_status' => '',
// 是否支持多模块
'app_multi_module' => true,
// 入口自动绑定模块
'auto_bind_module' => false,
// 注册的根命名空间
'root_namespace' => [],
// 扩展函数文件
'extra_file_list' => [THINK_PATH . 'helper' . EXT],
// 默认输出类型
'default_return_type' => 'html',
// 默认AJAX 数据返回格式,可选json xml ...
'default_ajax_return' => 'json',
// 默认JSONP格式返回的处理方法
'default_jsonp_handler' => 'jsonpReturn',
// 默认JSONP处理方法
'var_jsonp_handler' => 'callback',
// 默认时区
'default_timezone' => 'PRC',
// 是否开启多语言
'lang_switch_on' => false,
// 默认全局过滤方法 用逗号分隔多个
//'default_filter' => '',
// 设置默认的全局过滤规则 多个用数组或者逗号分隔
'default_filter' => 'htmlspecialchars',
// 默认语言
'default_lang' => 'zh-cn',
// 应用类库后缀
'class_suffix' => false,
// 控制器类后缀
'controller_suffix' => false,
// 是否启用控制器类后缀
//'controller_suffix' => true,
// +----------------------------------------------------------------------
// | 模块设置
// +----------------------------------------------------------------------
// 默认模块名
'default_module' => 'index',
// 禁止访问模块
'deny_module_list' => ['common'],
// 默认控制器名
'default_controller' => 'Index',
// 默认操作名
'default_action' => 'index',
// 默认验证器
'default_validate' => '',
// 默认的空控制器名
'empty_controller' => 'Error',
// 操作方法后缀
'action_suffix' => '',
// 自动搜索控制器
'controller_auto_search' => false,
// +----------------------------------------------------------------------
// | URL设置
// +----------------------------------------------------------------------
// PATHINFO变量名 用于兼容模式
'var_pathinfo' => 's',
// 兼容PATH_INFO获取
'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
// pathinfo分隔符
'pathinfo_depr' => '/',
// 设置pathinfo分隔符
//'pathinfo_depr' => ':',
// URL伪静态后缀
'url_html_suffix' => 'html',
// URL普通方式参数 用于自动生成
'url_common_param' => false,
// URL参数方式 0 按名称成对解析 1 按顺序解析
'url_param_type' => 0,
// 按照参数顺序获取
//'url_param_type' => 1,
// 是否开启路由
'url_route_on' => true,
// 路由使用完整匹配
'route_complete_match' => false,
// 路由配置文件(支持配置多个)
'route_config_file' => ['route'],
// 是否强制使用路由
'url_route_must' => false,
// 域名部署
'url_domain_deploy' => false,
// 域名根,如thinkphp.cn
'url_domain_root' => '',
// 是否自动转换URL中的控制器和操作名
//'url_convert' => true,
// 关闭URL自动转换(支持驼峰访问控制器)
'url_convert' => false,
// 默认的访问控制器层
'url_controller_layer' => 'controller',
// 表单请求类型伪装变量
'var_method' => '_method',
// 表单ajax伪装变量
'var_ajax' => '_ajax',
// 表单pjax伪装变量
'var_pjax' => '_pjax',
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
'request_cache' => false,
// 请求缓存有效期
'request_cache_expire' => null,
// 全局请求缓存排除规则
'request_cache_except' => [],
// +----------------------------------------------------------------------
// | 模板设置
// +----------------------------------------------------------------------
'template' => [
// 模板引擎类型 支持 php think 支持扩展
'type' => 'Think',
// 模板路径
'view_path' => '',
// 模板后缀
'view_suffix' => 'html',
// 模板文件名分隔符
'view_depr' => DS,
// 模板引擎普通标签开始标记
'tpl_begin' => '{',
// 模板引擎普通标签结束标记
'tpl_end' => '}',
// 标签库标签开始标记
'taglib_begin' => '{',
// 标签库标签结束标记
'taglib_end' => '}',
//统一使用布局
'layout_on' => true,
'layout_name' => 'layout',
'layout_item' => '[__REPLACE__]',
],
/*
'template' => [
// 模板引擎类型 支持 php think 支持扩展
'type' => 'Think',
// 模板路径
'view_path' => '../template/index/',
// 模板后缀
'view_suffix' => '.tpl',
// 模板文件名分隔符
'view_depr' => DS, // '_'
],*/
// 视图输出字符串内容替换
'view_replace_str' => [],
// 默认跳转页面对应的模板文件
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
// +----------------------------------------------------------------------
// | 异常及错误设置
// +----------------------------------------------------------------------
// 异常页面的模板文件
'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',
// 显示错误信息
'show_error_msg' => false,
// 异常处理handle类 留空使用 \think\exception\Handle
//'exception_handle' => '',
//API后台来处理异常
'exception_handle' => '\app\api\exception\Http',
// +----------------------------------------------------------------------
// | 日志设置
// +----------------------------------------------------------------------
/*
'log' => [
// 日志记录方式,内置 file socket 支持扩展
'type' => 'File',
// 日志保存目录
'path' => LOG_PATH,
// 日志记录级别
'level' => [],
// error和sql日志单独记录
'apart_level' => ['error','sql'],
],*/
'log' => [
'type' => 'socket',
'host' => 'localhost',
'show_included_files' => true,
'force_client_ids' => ['slog_20170713'],
'allow_client_ids' => ['slog_20170713'],
],
// +----------------------------------------------------------------------
// | Trace设置 开启 app_trace 后 有效
// +----------------------------------------------------------------------
'trace' => [
// 内置Html Console 支持扩展
'type' => 'Html',
],
// +----------------------------------------------------------------------
// | 缓存设置
// +----------------------------------------------------------------------
'cache' => [
// 驱动方式
'type' => 'File',
// 缓存保存目录
'path' => CACHE_PATH,
// 缓存前缀
'prefix' => '',
// 缓存有效期 0表示永久缓存
'expire' => 0,
],
// +----------------------------------------------------------------------
// | 会话设置
// +----------------------------------------------------------------------
'session' => [
'id' => '',
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id' => '',
// SESSION 前缀
'prefix' => 'think',
// 驱动方式 支持redis memcache memcached
'type' => '',
// 是否自动开启 SESSION
'auto_start' => true,
],
// +----------------------------------------------------------------------
// | Cookie设置
// +----------------------------------------------------------------------
'cookie' => [
// cookie 名称前缀
'prefix' => '',
// cookie 保存时间
'expire' => 0,
// cookie 保存路径
'path' => '/',
// cookie 有效域名
'domain' => '',
// cookie 启用安全传输
'secure' => false,
// httponly设置
'httponly' => '',
// 是否使用 setcookie
'setcookie' => true,
],
//分页配置
'paginate' => [
'type' => 'bootstrap',
'var_page' => 'page',
'list_rows' => 15,
],
// 数据库配置1
'db1' => [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'testdb1',
// 数据库用户名
'username' => 'root',
// 数据库密码
'password' => '123456',
// 数据库连接端口
'hostport' => '3306',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
// 数据库表前缀
'prefix' => 'think_',
],
// 数据库配置2
'db2' => [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'testdb2',
// 数据库用户名
'username' => 'root',
// 数据库密码
'password' => '123456',
// 数据库连接端口
'hostport' => '3306',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
// 数据库表前缀
'prefix' => 'think_',
],
];
远程调试:
[b]显示ThinkPHP5.0命令行当前支持的所有指令:[/b]
[root@contoso ~]# cd /home/myth/www/think
[root@contoso think]# pwd
/home/myth/www/think
[root@contoso think]# php think
Think Console version 0.1
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-V, --version Display this console version
-q, --quiet Do not output any message
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
build Build Application Dirs
clear Clear runtime file
help Displays help for a command
list Lists commands
make
make:controller Create a new resource controller class
make:model Create a new model class
optimize
optimize:autoload Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.
optimize:config Build config and common file cache.
optimize:route Build route cache.
optimize:schema Build database schema cache.
[root@contoso think]#
生成模块:
下面我们给应用生成一个新的模块test ,首先需要在apps 目录下面创建一个build.php 定义
文件,文件内容如下:
return [
// 定义test模块的自动生成
'test' => [
'__dir__' => ['controller', 'model', 'view'],
'controller' => ['User', 'UserType'],
'model' => ['User', 'UserType'],
'view' => ['index/index', 'index/test'],
],
];
[root@contoso think]# ll
total 28
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso think]#
然后在命令行下面,执行:
[root@contoso think]# php think build
Successed
[root@contoso think]# ll [b]/home/myth/www/think/apps[/b]
total 36
drwxrwxr-x 5 myth myth 85 Aug 1 12:35 api
-rw-rw-r-- 1 myth myth 558 Aug 1 12:34 build.php
-rw-rw-r-- 1 myth myth 606 Jul 4 11:52 command.php
-rw-rw-r-- 1 myth myth 616 Jul 4 11:52 common.php
-rw-rw-r-- 1 myth myth 8799 Aug 1 12:23 config.php
-rw-rw-r-- 1 myth myth 1898 Jul 4 11:52 database.php
drwxrwxr-x 5 myth myth 85 Aug 1 12:35 demo
drwxrwxr-x 3 myth myth 24 Jul 4 11:52 index
-rw-rw-r-- 1 myth myth 4435 Aug 1 18:37 route.php
-rw-rw-r-- 1 myth myth 981 Jul 4 11:52 tags.php
drwxrwxr-x 5 myth myth 85 Aug 1 12:35 test
[root@contoso think]# tree [b][b]/home/myth/www/think[/b]/apps/test[/b]
/var/www/think/apps/test
├── common.php
├── config.php
├── controller
│ ├── Index.php
│ ├── User.php
│ └── UserType.php
├── model
│ ├── User.php
│ └── UserType.php
└── view
└── index
├── index.html
└── test.html
4 directories, 9 files
[root@contoso think]#
接下来,我们可以访问
http://contoso.org/test/
生成文件:
还可以用make 指令单独生成某个应用类库文件,例如:
[root@contoso ~]#[b]cd[b][b]/home/myth/www/think[/b][/b]
[/b]
[root@contoso think]#php think make:controller test/Blog
Controller created successfully.
[root@contoso think]# tree [b][b]/home/myth/www/think[/b]/apps/test[/b]
/var/www/think/apps/test
├── common.php
├── config.php
├── controller
│ ├── Blog.php
│ ├── Index.php
│ ├── User.php
│ └── UserType.php
├── model
│ ├── User.php
│ └── UserType.php
└── view
└── index
├── index.html
└── test.html
4 directories, 10 files
[root@contoso think]#
会自动为test模块生成一个 Blog控制器文件。
注意,默认生成的控制器类是属于资源控制器,并且继承了\think\Controller。
如果希望生成一个空的控制器,可以使用
[root@contoso think]#php think make:controller test/Blog --plain
又或者生成一个模型文件
[root@contoso think]#php think make:model test/Blog
Model created successfully.
[root@contoso think]# tree [b][b]/home/myth/www/think[/b]/apps/test[/b]
/home/myth/www/think/apps/test
├── common.php
├── config.php
├── controller
│ ├── Blog.php
│ ├── Index.php
│ ├── User.php
│ └── UserType.php
├── model
│ ├── Blog.php
│ ├── User.php
│ └── UserType.php
└── view
└── index
├── index.html
└── test.html
4 directories, 11 files
[root@contoso think]#
生成类库映射文件
在生成类库文件之后,我们强烈建议使用命令行生成类库映射文件,可以提高自动加载的性能,用法如下:
php think optimize:autoload
[root@contoso think]# tree [b][b][b]/home/myth/www/think[/b][/b]/runtime[/b]
/var/www/think/runtime
├── cache
│ ├── 10
│ ├── 2c
│ ├── 37
│ ├── 97
│ ├── 9b
│ ├── aa
│ ├── b4
│ ├── cd
│ ├── e6
│ └── ef
├── log
│ └── 201707
│ ├── 09.log
│ ├── 10.log
│ ├── 11.log
│ ├── 12.log
│ ├── 12_sql.log
│ ├── 13.log
│ └── 13_sql.log
└── temp
├── 05298ce6c97542a523ca6b9a2f99e2e0.php
├── 0c0761ad40371ca875eef82bed6fac8b.php
├── 40c4cbd97fc727507cce2922e2708d81.php
├── 44086db842173b76b442ec6ee84b74b4.php
├── 6ef062f8ed644a1083155e681e7f7cdc.php
├── e319b0ab5fc2fe69ec85ccc9dad9fb62.php
└── fdc06d0a4ecd09fe301acada23705d1b.php
14 directories, 14 files
[root@contoso think]# pwd
/home/myth/www/think
[root@contoso think]# ll
total 32
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
drwxr-xr-x 3 myth myth 746 Jul 31 23:36 template
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso think]# php think optimize:autoload
Succeed!
[root@contoso think]# tree [b][b][b][b]/home/myth/www/think[/b][/b][/b]/runtime[/b]
/var/www/think/runtime
├── cache
│ ├── 10
│ ├── 2c
│ ├── 37
│ ├── 97
│ ├── 9b
│ ├── aa
│ ├── b4
│ ├── cd
│ ├── e6
│ └── ef
├── classmap.php
├── log
│ └── 201707
│ ├── 09.log
│ ├── 10.log
│ ├── 11.log
│ ├── 12.log
│ ├── 12_sql.log
│ ├── 13.log
│ └── 13_sql.log
└── temp
├── 05298ce6c97542a523ca6b9a2f99e2e0.php
├── 0c0761ad40371ca875eef82bed6fac8b.php
├── 40c4cbd97fc727507cce2922e2708d81.php
├── 44086db842173b76b442ec6ee84b74b4.php
├── 6ef062f8ed644a1083155e681e7f7cdc.php
├── e319b0ab5fc2fe69ec85ccc9dad9fb62.php
└── fdc06d0a4ecd09fe301acada23705d1b.php
14 directories, 15 files
[root@contoso think]#
执行完毕,会在RUNTIME_PATH 目录下面生成一个classmap.php 文件,包括了系统和应用的所有类库
文件的映射列表。
[root@contoso think]# cat [b][b][b][b]/home/myth/www/think[/b][/b][/b]/runtime/classmap.php[/b]
生成路由缓存文件
如果你的应用定义了大量的路由规则,那么建议在实际部署后生成路由缓存文件,可以免去路由注册的开
销,从而改善路由的检测效率,用法如下:
php think optimize:route
[root@contoso think]# cd /home/myth/www/think
[root@contoso think]# ll
total 32
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
drwxr-xr-x 3 myth myth 746 Jul 31 23:36 template
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso think]# php think optimize:route
Succeed!
[root@contoso think]# tree /home/myth/www/think/runtime
/home/myth/www/think/runtime
├── cache
│ ├── 10
│ ├── 2c
│ ├── 37
│ ├── 97
│ ├── 9b
│ ├── aa
│ ├── b4
│ ├── cd
│ ├── e6
│ └── ef
├── classmap.php
├── log
│ └── 201707
│ ├── 09.log
│ ├── 10.log
│ ├── 11.log
│ ├── 12.log
│ ├── 12_sql.log
│ ├── 13.log
│ └── 13_sql.log
├── route.php
└── temp
├── 05298ce6c97542a523ca6b9a2f99e2e0.php
├── 0c0761ad40371ca875eef82bed6fac8b.php
├── 40c4cbd97fc727507cce2922e2708d81.php
├── 44086db842173b76b442ec6ee84b74b4.php
├── 6ef062f8ed644a1083155e681e7f7cdc.php
├── e319b0ab5fc2fe69ec85ccc9dad9fb62.php
└── fdc06d0a4ecd09fe301acada23705d1b.php
14 directories, 16 files
[root@contoso think]#
执行完毕,会在RUNTIME_PATH 目录下面生成一个route.php 文件,包括了应用的所有路由规则定义列
表。
生成数据表字段缓存文件
如果你希望提高查询的性能,可以通过生成字段缓存来减少查询。用法如下:
php think optimize:schema
执行完毕,会在RUNTIME_PATH 目录下面创建schema目录,然后在该目录下面按照
database.table.php 的文件命名生成数据表字段缓存文件。
也可以指定数据库生成字段缓存(必须有用户权限),例如,下面指定生成demo数据库下面的所有数据表的
字段缓存信息。
php think optimize:schema --db demo
还可以读取模块的模型类来生成数据表字段缓存(这个适合多数据库连接的情况),如下:
php think optimize:schema --module index
会读取index模块的模型来生成数据表字段缓存。
[root@contoso think]# pwd
/var/www/think
[root@contoso think]# ll
total 32
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
drwxr-xr-x 3 myth myth 746 Jul 31 23:36 template
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso think]# php think optimize:schema
Succeed!
[root@contoso think]# tree /home/myth/www/think/runtime
/home/myth/www/think/runtime
├── cache
│ ├── 10
│ ├── 2c
│ ├── 37
│ ├── 97
│ ├── 9b
│ ├── aa
│ ├── b4
│ ├── cd
│ ├── e6
│ └── ef
├── classmap.php
├── log
│ └── 201707
│ ├── 09.log
│ ├── 10.log
│ ├── 11.log
│ ├── 12.log
│ ├── 12_sql.log
│ ├── 13.log
│ └── 13_sql.log
├── route.php
├── schema
│ ├── testdb1.think_access.php
│ ├── testdb1.think_blog.php
│ ├── testdb1.think_book.php
│ ├── testdb1.think_data.php
│ ├── testdb1.think_profile.php
│ ├── testdb1.think_role.php
│ └── testdb1.think_user.php
└── temp
├── 05298ce6c97542a523ca6b9a2f99e2e0.php
├── 0c0761ad40371ca875eef82bed6fac8b.php
├── 40c4cbd97fc727507cce2922e2708d81.php
├── 44086db842173b76b442ec6ee84b74b4.php
├── 6ef062f8ed644a1083155e681e7f7cdc.php
├── e319b0ab5fc2fe69ec85ccc9dad9fb62.php
└── fdc06d0a4ecd09fe301acada23705d1b.php
15 directories, 23 files
[root@contoso think]#
更新数据表字段缓存也是同样的方式,每次执行都会重新生成缓存。如果需要单独更新某个数据表的缓存,
可以使用:
php think optimize:schema --table think_user
支持指定数据库名称
php think optimize:schema --table demo.think_user
sendmail服务配置(注意:qq邮箱接收sendmail发的邮件一律被拒绝接收,别指望qq邮箱测试会成功):
[root@contoso ~]# sestatus -v
SELinux status: disabled
php.ini (默认值即可):
SMTP=localhost
smtp_port=25
sendmail_path="/usr/lib/sendmail -t -i"
[root@contoso ~]# yum install -y sendmail
[root@contoso ~]# systemctl enable sendmail
[root@contoso ~]# systemctl restart sendmail
[root@contoso ~]# systemctl status sendmail
[root@contoso ~]# echo 'HOSTNAME=contoso.org' >> /etc/sysconfig/network
[root@contoso ~]# echo 'contoso.org # this is my email domainname' >> /etc/mail/local-host-names
[root@contoso ~]# vi /etc/mail/sendmail.cf
# SMTP daemon options
O DaemonPortOptions=Port=smtp,Addr=0.0.0.0, Name=MTA
[root@contoso ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
contoso.org
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.10 contoso.org
[root@contoso ~]#
[root@contoso ~]# nslookup -query=mx qq.com
C:\Users\Administrator>nslookup -qt=mx qq.com
[root@contoso ~]# tail -f /var/log/maillog
[root@contoso ~]# mail -s "this is a testing email content." zhengzizhi@aliyun.com < anaconda-ks.cfg
[root@contoso ~]# mail -s "this is a testing email content." zhengzizhi@126.com < anaconda-ks.cfg
[root@contoso ~]# cat /dev/null > /var/spool/mail/root && cat /dev/null > /var/log/maillog
[root@contoso ~]# alternatives --display mta
mta - status is auto.
link currently points to /usr/sbin/sendmail.sendmail
/usr/sbin/sendmail.postfix - priority 30
slave mta-pam: /etc/pam.d/smtp.postfix
slave mta-mailq: /usr/bin/mailq.postfix
slave mta-newaliases: /usr/bin/newaliases.postfix
slave mta-rmail: /usr/bin/rmail.postfix
slave mta-sendmail: /usr/lib/sendmail.postfix
slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz
slave mta-rmailman: (null)
slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz
/usr/sbin/sendmail.sendmail - priority 90
slave mta-pam: /etc/pam.d/smtp.sendmail
slave mta-mailq: /usr/bin/mailq.sendmail
slave mta-newaliases: /usr/bin/newaliases.sendmail
slave mta-rmail: /usr/bin/rmail.sendmail
slave mta-sendmail: /usr/lib/sendmail.sendmail
slave mta-mailqman: /usr/share/man/man1/mailq.sendmail.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.sendmail.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.sendmail.5.gz
slave mta-rmailman: /usr/share/man/man8/rmail.sendmail.8.gz
slave mta-sendmailman: /usr/share/man/man8/sendmail.sendmail.8.gz
Current `best' version is /usr/sbin/sendmail.sendmail.
[root@contoso ~]#
thinkphp5.0 config.php错误日志的接收邮箱配置方式:
'log' => [
'type' => 'driver\log\Email',
'email_addr' => 'zhengzizhi@126.com',
'send_level' => ['error', 'info'],
],
安装验证码类库,在命令行下面切换到应用根目录下面,执行:
[root@contoso ~]$ cd [b]/home/myth/www/think[/b]
[root@contoso think]# tree -L 2
.
├── apps
│ ├── api
│ ├── build.php
│ ├── command.php
│ ├── common.php
│ ├── config.php
│ ├── database.php
│ ├── demo
│ ├── index
│ ├── route.php
│ └── tags.php
├── build.php
├── composer.json
├── composer.lock
├── extend
│ ├── ArrayList.php
│ └── driver
├── LICENSE.txt
├── public
│ ├── favicon.ico
│ ├── index.php
│ ├── robots.txt
│ ├── router.php
│ └── static
├── README.md
├── runtime
│ ├── log
│ └── temp
├── template
│ └── index
├── think
├── thinkphp
│ ├── base.php
│ ├── codecov.yml
│ ├── composer.json
│ ├── console.php
│ ├── CONTRIBUTING.md
│ ├── convention.php
│ ├── helper.php
│ ├── lang
│ ├── library
│ ├── LICENSE.txt
│ ├── logo.png
│ ├── phpunit.xml
│ ├── README.md
│ ├── start.php
│ └── tpl
└── vendor
├── autoload.php
├── composer
└── topthink
20 directories, 31 files
[root@contoso think]# composer require topthink/think-captcha
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^1.0 for topthink/think-captcha
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing topthink/think-captcha (v1.0.7): Downloading (100%)
Writing lock file
Generating autoload files
[root@contoso think]#
因为httpd服务的运行用户默认是apache,所以上传文件夹uploads的权限必须分配给apache这个用户:
查看一下你的Apache的执行用户是谁: lsof -i:80
[root@contoso ~]# lsof -i:80
[root@contoso ~]# ll [b]/home/myth/www/think/public[/b]
total 20
-rw-rw-r-- 1 myth myth 203 Aug 1 00:36 admin.php
-rw-rw-r-- 1 myth myth 1150 Jul 4 11:52 favicon.ico
-rw-rw-r-- 1 myth myth 759 Jul 31 23:37 index.php
-rw-rw-r-- 1 myth myth 24 Jul 4 11:52 robots.txt
-rw-rw-r-- 1 myth myth 736 Jul 4 11:52 router.php
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 static
drwxr-xr-x 2 myth myth 24 Jul 4 11:52 uploads
[root@contoso ~]# chown -R apache:apache /home/myth/www/think/runtime && ll /home/myth/www/think
total 28
drwxrwxr-x 5 myth myth 186 Aug 1 18:37 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 570 Jul 4 11:52 composer.json
-rw-rw-r-- 1 myth myth 3786 Jul 31 19:04 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 1 00:36 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 2 apache apache 24 Jul 4 11:52 runtime
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Jul 31 19:04 thinkphp
drwxrwxr-x 4 myth myth 76 Jul 31 19:04 vendor
[root@contoso ~]#
安装ThinkPHP5 的单元测试扩展,进入命令行,切换到应用根目录下面后,执行:
[myth@contoso ~]$ cd /home/myth/www/think
[root@contoso think]$ tree -L 2
.
├── apps
│ ├── api
│ ├── build.php
│ ├── command.php
│ ├── common.php
│ ├── config.php
│ ├── database.php
│ ├── demo
│ ├── index
│ ├── route.php
│ └── tags.php
├── build.php
├── composer.json
├── composer.lock
├── extend
│ ├── ArrayList.php
│ └── driver
├── LICENSE.txt
├── public
│ ├── favicon.ico
│ ├── index.php
│ ├── robots.txt
│ ├── router.php
│ ├── static
│ └── uploads
├── README.md
├── runtime
│ ├── log
│ └── temp
├── template
│ └── index
├── think
├── thinkphp
│ ├── base.php
│ ├── codecov.yml
│ ├── composer.json
│ ├── console.php
│ ├── CONTRIBUTING.md
│ ├── convention.php
│ ├── helper.php
│ ├── lang
│ ├── library
│ ├── LICENSE.txt
│ ├── logo.png
│ ├── phpunit.xml
│ ├── README.md
│ ├── start.php
│ └── tpl
└── vendor
├── autoload.php
├── composer
└── topthink
21 directories, 31 files
[root@contoso think]# composer require topthink/think-testing
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^1.0 for topthink/think-testing
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 25 installs, 0 updates, 0 removals
- Installing symfony/polyfill-mbstring (v1.4.0): Downloading (100%)
- Installing symfony/dom-crawler (v2.8.25): Downloading (100%)
- Installing symfony/yaml (v3.3.5): Downloading (100%)
- Installing sebastian/version (1.0.6): Downloading (100%)
- Installing sebastian/global-state (1.1.1): Downloading (100%)
- Installing sebastian/recursion-context (1.0.5): Downloading (100%)
- Installing sebastian/exporter (1.2.2): Downloading (100%)
- Installing sebastian/environment (1.3.8): Downloading (100%)
- Installing sebastian/diff (1.4.3): Downloading (100%)
- Installing sebastian/comparator (1.2.4): Downloading (100%)
- Installing doctrine/instantiator (1.1.0): Downloading (100%)
- Installing phpunit/php-text-template (1.2.1): Downloading (100%)
- Installing phpunit/phpunit-mock-objects (2.3.8): Downloading (100%)
- Installing phpunit/php-timer (1.0.9): Downloading (100%)
- Installing phpunit/php-file-iterator (1.4.2): Downloading (100%)
- Installing phpunit/php-token-stream (1.4.11): Downloading (100%)
- Installing phpunit/php-code-coverage (2.2.4): Downloading (100%)
- Installing webmozart/assert (1.2.0): Downloading (100%)
- Installing phpdocumentor/reflection-common (1.0): Downloading (100%)
- Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)
- Installing phpdocumentor/reflection-docblock (3.2.0): Downloading (100%)
- Installing phpspec/prophecy (v1.7.0): Downloading (100%)
- Installing phpunit/phpunit (4.8.36): Downloading (100%)
- Installing topthink/think-helper (v1.0.6): Downloading (100%)
- Installing topthink/think-testing (v1.0.6): Downloading (100%)
symfony/dom-crawler suggests installing symfony/css-selector ()
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
[root@contoso think]#
[root@contoso ~]# yum install php71-php-pecl-swoole
[root@contoso think]# pwd
/home/myth/www/think
[root@contoso think]# ll
total 32
drwxrwxr-x 5 myth myth 186 Aug 4 16:23 apps
-rw-rw-r-- 1 myth myth 1099 Jul 31 23:34 build.php
-rw-rw-r-- 1 myth myth 655 Aug 12 10:03 composer.json
-rw-rw-r-- 1 myth myth 7568 Aug 12 10:03 composer.lock
drwxrwxr-x 2 myth myth 24 Jul 4 11:52 extend
-rw-rw-r-- 1 myth myth 1822 Jul 4 11:52 LICENSE.txt
drwxrwxr-x 3 myth myth 126 Aug 5 03:19 public
-rw-rw-r-- 1 myth myth 5775 Jul 4 11:52 README.md
drwxrwxr-x 4 apache apache 47 Aug 1 23:57 runtime
-rw-rw-r-- 1 myth myth 746 Jul 31 23:36 think
drwxrwxr-x 5 myth myth 324 Aug 11 03:23 thinkphp
drwxrwxr-x 5 myth myth 77 Aug 12 10:03 vendor
[root@contoso think]# php public/index.php index/Demon/start
[root@contoso think]# lsof -i:9501
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php 71618 root 3u IPv4 488904 0t0 TCP *:9501 (LISTEN)
[root@contoso think]# yum install -y telnet
[root@contoso think]# telnet 127.0.0.1 9501
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
hello
onReceive: hello
apps/index/controller目录下建立
Demon.php文件
<?php namespace app\index\controller; // 必须 use 并继承 \think\swoole\Server 类 use think\swoole\Server; class Demon extends Server { // 监听所有地址 protected $host = '0.0.0.0'; // 监听 9501 端口 protected $port = 9501; // 指定运行模式为多进程 protected $mode = SWOOLE_PROCESS; // 指定 socket 的类型为 ipv4 的 tcp socket protected $sockType = SWOOLE_SOCK_TCP; // 配置项 protected $option = [ /** * 设置启动的worker进程数 * 业务代码是全异步非阻塞的,这里设置为CPU的1-4倍最合理 * 业务代码为同步阻塞,需要根据请求响应时间和系统负载来调整 */ 'worker_num' => 4, // 守护进程化 'daemonize' => true, // 监听队列的长度 'backlog' => 128 ]; /** * 收到信息时回调函数 * @param \swoole_server $serv swoole_server对象 * @param $fd TCP客户端连接的文件描述符 * @param $from_id TCP连接所在的Reactor线程ID * @param $data 收到的数据内容 */ public function onReceive(\swoole_server $server, $fd, $from_id, $data) { $server->send($fd, 'onReceive: ' . $data); } }
一次关闭同名称的多个进程:
分解关闭进程指令 ps -eaf |grep 'index/Socket/run'|grep -v "grep"|awk '{print $2}'|xargs kill -9,看看每步操作的效果
[root@contoso ~]# ps -eaf
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 07:02 ? 00:00:06 /usr/lib/systemd/systemd --switched-root --system --deseria
root 2 0 0 07:02 ? 00:00:00 [kthreadd]
root 3 2 0 07:02 ? 00:00:02 [ksoftirqd/0]
root 5 2 0 07:02 ? 00:00:00 [kworker/0:0H]
root 7 2 0 07:02 ? 00:00:00 [migration/0]
root 8 2 0 07:02 ? 00:00:00 [rcu_bh]
root 9 2 0 07:02 ? 00:01:09 [rcu_sched]
root 10 2 0 07:02 ? 00:00:00 [watchdog/0]
root 11 2 0 07:02 ? 00:00:00 [watchdog/1]
root 12 2 0 07:02 ? 00:00:00 [migration/1]
root 13 2 0 07:02 ? 00:00:00 [ksoftirqd/1]
root 16 2 0 07:02 ? 00:00:00 [watchdog/2]
root 17 2 0 07:02 ? 00:00:00 [migration/2]
root 18 2 0 07:02 ? 00:00:00 [ksoftirqd/2]
root 20 2 0 07:02 ? 00:00:00 [kworker/2:0H]
root 21 2 0 07:02 ? 00:00:00 [watchdog/3]
root 22 2 0 07:02 ? 00:00:00 [migration/3]
root 23 2 0 07:02 ? 00:00:00 [ksoftirqd/3]
root 25 2 0 07:02 ? 00:00:00 [kworker/3:0H]
root 27 2 0 07:02 ? 00:00:00 [kdevtmpfs]
root 28 2 0 07:02 ? 00:00:00 [netns]
root 29 2 0 07:02 ? 00:00:00 [khungtaskd]
root 30 2 0 07:02 ? 00:00:00 [writeback]
root 31 2 0 07:02 ? 00:00:00 [kintegrityd]
root 32 2 0 07:02 ? 00:00:00 [bioset]
root 33 2 0 07:02 ? 00:00:00 [kblockd]
root 34 2 0 07:02 ? 00:00:00 [md]
root 40 2 0 07:03 ? 00:00:00 [kswapd0]
root 41 2 0 07:03 ? 00:00:00 [ksmd]
root 42 2 0 07:03 ? 00:00:13 [khugepaged]
root 43 2 0 07:03 ? 00:00:00 [fsnotify_mark]
root 44 2 0 07:03 ? 00:00:00 [crypto]
root 52 2 0 07:03 ? 00:00:00 [kthrotld]
root 53 2 0 07:03 ? 00:00:01 [kworker/u256:1]
root 54 2 0 07:03 ? 00:00:00 [kmpath_rdacd]
root 56 2 0 07:03 ? 00:00:00 [kworker/0:1]
root 57 2 0 07:03 ? 00:00:00 [kpsmoused]
root 59 2 0 07:03 ? 00:00:00 [ipv6_addrconf]
root 79 2 0 07:03 ? 00:00:00 [deferwq]
root 112 2 0 07:03 ? 00:00:00 [kauditd]
root 299 2 0 07:03 ? 00:00:00 [ata_sff]
root 300 2 0 07:03 ? 00:00:00 [mpt_poll_0]
root 301 2 0 07:03 ? 00:00:00 [mpt/0]
root 309 2 0 07:03 ? 00:00:00 [scsi_eh_0]
root 310 2 0 07:03 ? 00:00:00 [scsi_tmf_0]
root 311 2 0 07:03 ? 00:00:00 [scsi_eh_1]
root 313 2 0 07:03 ? 00:00:00 [scsi_tmf_1]
root 314 2 0 07:03 ? 00:00:00 [scsi_eh_2]
root 315 2 0 07:03 ? 00:00:00 [scsi_tmf_2]
root 316 2 0 07:03 ? 00:00:00 [ttm_swap]
root 350 2 0 07:03 ? 00:00:00 [kworker/0:1H]
root 392 2 0 07:03 ? 00:00:00 [kdmflush]
root 393 2 0 07:03 ? 00:00:00 [bioset]
root 404 2 0 07:03 ? 00:00:00 [kdmflush]
root 405 2 0 07:03 ? 00:00:00 [bioset]
root 418 2 0 07:03 ? 00:00:00 [xfsalloc]
root 419 2 0 07:03 ? 00:00:00 [xfs_mru_cache]
root 420 2 0 07:03 ? 00:00:00 [xfs-buf/dm-0]
root 421 2 0 07:03 ? 00:00:00 [xfs-data/dm-0]
root 422 2 0 07:03 ? 00:00:00 [xfs-conv/dm-0]
root 423 2 0 07:03 ? 00:00:00 [xfs-cil/dm-0]
root 424 2 0 07:03 ? 00:00:00 [xfs-reclaim/dm-]
root 425 2 0 07:03 ? 00:00:00 [xfs-log/dm-0]
root 426 2 0 07:03 ? 00:00:00 [xfs-eofblocks/d]
root 427 2 0 07:03 ? 00:00:30 [xfsaild/dm-0]
root 498 1 0 07:03 ? 00:00:00 /usr/lib/systemd/systemd-journald
root 522 2 0 07:03 ? 00:00:00 [rpciod]
root 523 1 0 07:03 ? 00:00:00 /usr/sbin/lvmetad -f
root 528 2 0 07:03 ? 00:00:03 [kworker/2:2]
root 536 1 0 07:03 ? 00:00:00 /usr/lib/systemd/systemd-udevd
root 556 2 0 07:03 ? 00:00:00 [nfit]
root 572 2 0 07:03 ? 00:00:00 [kworker/u257:0]
root 574 2 0 07:03 ? 00:00:00 [hci0]
root 575 2 0 07:03 ? 00:00:00 [hci0]
root 576 2 0 07:03 ? 00:00:00 [kworker/u257:1]
root 633 2 0 07:03 ? 00:00:00 [xfs-buf/sda1]
root 634 2 0 07:03 ? 00:00:00 [xfs-data/sda1]
root 635 2 0 07:03 ? 00:00:00 [xfs-conv/sda1]
root 636 2 0 07:03 ? 00:00:00 [xfs-cil/sda1]
root 637 2 0 07:03 ? 00:00:00 [xfs-reclaim/sda]
root 638 2 0 07:03 ? 00:00:00 [xfs-log/sda1]
root 639 2 0 07:03 ? 00:00:00 [xfs-eofblocks/s]
root 641 2 0 07:03 ? 00:00:00 [xfsaild/sda1]
root 649 2 0 07:03 ? 00:00:00 [kdmflush]
root 650 2 0 07:03 ? 00:00:00 [bioset]
root 657 2 0 07:03 ? 00:00:00 [xfs-buf/dm-2]
root 658 2 0 07:03 ? 00:00:00 [xfs-data/dm-2]
root 659 2 0 07:03 ? 00:00:00 [xfs-conv/dm-2]
root 660 2 0 07:03 ? 00:00:00 [xfs-cil/dm-2]
root 661 2 0 07:03 ? 00:00:00 [xfs-reclaim/dm-]
root 662 2 0 07:03 ? 00:00:00 [xfs-log/dm-2]
root 663 2 0 07:03 ? 00:00:00 [xfs-eofblocks/d]
root 664 2 0 07:03 ? 00:00:08 [xfsaild/dm-2]
root 689 1 0 07:03 ? 00:00:00 /sbin/auditd -n
root 706 689 0 07:03 ? 00:00:00 /sbin/audispd
avahi 709 1 0 07:03 ? 00:00:00 avahi-daemon: running [contoso.local]
libstor+ 711 1 0 07:03 ? 00:00:00 /usr/bin/lsmd -d
root 712 706 0 07:03 ? 00:00:00 /usr/sbin/sedispatch
root 717 1 0 07:03 ? 00:00:47 /usr/bin/vmtoolsd
dbus 718 1 0 07:03 ? 00:00:05 /bin/dbus-daemon --system --address=systemd: --nofork --nop
avahi 719 709 0 07:03 ? 00:00:00 avahi-daemon: chroot helper
root 724 1 0 07:03 ? 00:00:01 /usr/lib/systemd/systemd-logind
rtkit 725 1 0 07:03 ? 00:00:01 /usr/libexec/rtkit-daemon
polkitd 726 1 0 07:03 ? 00:00:02 /usr/lib/polkit-1/polkitd --no-debug
root 727 1 0 07:03 ? 00:00:08 /usr/sbin/irqbalance --foreground
root 728 1 0 07:03 ? 00:00:00 /usr/sbin/abrtd -d -s
root 729 1 0 07:03 ? 00:00:00 /usr/bin/abrt-watch-log -F Backtrace /var/log/Xorg.0.log --
root 730 1 0 07:03 ? 00:00:00 /usr/bin/abrt-watch-log -F BUG: WARNING: at WARNING: CPU: I
root 734 1 0 07:03 ? 00:00:00 /usr/libexec/bluetooth/bluetoothd
root 737 1 0 07:03 ? 00:00:15 /sbin/rngd -f
root 738 1 0 07:03 ? 00:00:00 /usr/sbin/ModemManager
root 740 1 0 07:03 ? 00:00:00 /usr/sbin/NetworkManager --no-daemon
root 741 1 0 07:03 ? 00:00:00 /usr/sbin/smartd -n -q never
root 747 1 0 07:03 ? 00:00:00 /usr/libexec/accounts-daemon
root 748 1 0 07:03 ? 00:00:00 /usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa
root 756 1 0 07:03 ? 00:00:01 /bin/bash /usr/sbin/ksmtuned
root 768 1 0 07:03 ? 00:00:00 /usr/sbin/gssproxy -D
root 844 2 0 07:03 ? 00:00:00 [kworker/3:1H]
memcach+ 983 1 0 07:03 ? 00:00:04 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024
root 986 1 0 07:03 ? 00:00:03 php-fpm: master process (/etc/php-fpm.conf)
root 987 1 0 07:03 ? 00:00:00 /usr/sbin/sshd -D
root 988 1 0 07:03 ? 00:00:00 /usr/sbin/cupsd -f
root 990 1 0 07:03 ? 00:00:06 /usr/bin/python -Es /usr/sbin/tuned -l -P
root 991 1 0 07:03 ? 00:00:00 /usr/sbin/rsyslogd -n
redis 992 1 0 07:03 ? 00:00:53 /usr/bin/redis-server 192.168.10.20:6379
root 1007 1 0 07:03 ? 00:00:04 /usr/sbin/httpd -DFOREGROUND
root 1009 1 0 07:03 ? 00:00:00 /usr/sbin/libvirtd
root 1011 1 0 07:03 ? 00:00:00 /usr/sbin/crond -n
root 1016 1 0 07:03 ? 00:00:00 /usr/sbin/atd -f
root 1021 1 0 07:03 ? 00:00:00 /usr/sbin/gdm
mysql 1176 1 0 07:03 ? 00:00:52 /usr/sbin/mysqld
apache 1246 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1247 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1248 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1249 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1255 986 0 07:03 ? 00:00:00 php-fpm: pool www
apache 1298 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1299 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1300 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1301 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1302 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1304 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1305 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1307 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1308 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1309 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1313 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1315 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1316 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1317 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1321 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1324 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1325 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1331 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1332 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1338 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1342 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1343 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1344 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1349 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1351 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1352 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1353 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1354 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1355 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1359 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1362 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1365 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1367 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1371 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1376 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1378 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1379 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1383 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1388 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1392 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1398 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1400 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1407 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1435 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1438 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1440 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1444 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1449 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1452 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1456 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1461 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1465 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1469 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1471 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1476 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1478 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1480 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1484 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1490 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1491 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1492 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1495 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1498 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1506 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1508 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1513 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1515 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1519 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1522 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1524 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 1527 1 0 07:03 ? 00:00:00 /usr/libexec/postfix/master -w
apache 1528 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1529 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1530 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1535 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1539 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1541 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1545 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1554 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1558 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1559 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1561 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1565 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1568 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1572 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1576 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
postfix 1579 1527 0 07:03 ? 00:00:00 qmgr -l -t unix -u
apache 1580 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1584 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1589 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1594 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1599 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1603 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1606 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1608 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1615 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1617 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1619 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1621 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1624 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1625 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 1628 1007 0 07:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
nobody 1879 1 0 07:03 ? 00:00:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.
root 1882 1879 0 07:03 ? 00:00:00 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.
root 2512 1021 1 07:03 tty1 00:17:03 /usr/bin/Xorg :0 -background none -noreset -audit 4 -verbos
root 2571 1 0 07:03 ? 00:00:00 /usr/libexec/upowerd
colord 2603 1 0 07:03 ? 00:00:00 /usr/libexec/colord
root 2660 2 0 07:03 ? 00:00:00 [kworker/2:1H]
root 2716 1 0 07:03 ? 00:00:00 /usr/sbin/wpa_supplicant -u -f /var/log/wpa_supplicant.log
root 2720 1 0 07:03 ? 00:00:00 /usr/libexec/packagekitd
root 2766 1 0 07:03 ? 00:00:00 /usr/lib/udisks2/udisksd --no-debug
root 2868 1021 0 07:03 ? 00:00:00 gdm-session-worker [pam/gdm-password]
myth 2878 1 0 07:03 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login
myth 2884 2868 0 07:03 ? 00:00:00 gnome-session --session gnome-classic
myth 2891 1 0 07:03 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session
myth 2892 1 0 07:03 ? 00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --s
myth 2959 1 0 07:03 ? 00:00:00 /usr/libexec/gvfsd
myth 2964 1 0 07:03 ? 00:00:00 /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f -o big_write
myth 3049 2884 0 07:03 ? 00:00:00 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNO
myth 3071 1 0 07:03 ? 00:00:00 /usr/libexec/at-spi-bus-launcher
myth 3076 3071 0 07:03 ? 00:00:02 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.c
myth 3078 1 0 07:03 ? 00:00:02 /usr/libexec/at-spi2-registryd --use-gnome-session
myth 3092 2884 0 07:03 ? 00:00:03 /usr/libexec/gnome-settings-daemon
myth 3109 1 0 07:03 ? 00:00:00 /usr/bin/pulseaudio --start --log-target=syslog
root 3123 2 0 07:03 ? 00:00:00 [krfcommd]
myth 3131 2884 6 07:03 ? 00:54:28 /usr/bin/gnome-shell
myth 3136 1 0 07:03 ? 00:00:00 /usr/libexec/gsd-printer
myth 3185 3131 0 07:03 ? 00:00:05 ibus-daemon --xim --panel disable
myth 3190 3185 0 07:03 ? 00:00:00 /usr/libexec/ibus-dconf
myth 3192 1 0 07:03 ? 00:00:02 /usr/libexec/ibus-x11 --kill-daemon
myth 3200 1 0 07:03 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server
myth 3205 1 0 07:03 ? 00:00:00 /usr/libexec/evolution-source-registry
myth 3210 1 0 07:03 ? 00:00:00 /usr/libexec/goa-daemon
myth 3217 1 0 07:03 ? 00:00:03 /usr/libexec/goa-identity-service
myth 3230 1 0 07:03 ? 00:00:00 /usr/libexec/mission-control-5
myth 3232 1 0 07:03 ? 00:00:01 /usr/libexec/caribou
myth 3241 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-udisks2-volume-monitor
myth 3247 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
myth 3252 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-afc-volume-monitor
myth 3259 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-goa-volume-monitor
myth 3267 1 0 07:03 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
myth 3300 2884 0 07:03 ? 00:00:00 nautilus --no-default-window --force-desktop
myth 3307 2884 0 07:03 ? 00:00:00 /usr/libexec/tracker-miner-user-guides
myth 3309 2884 0 07:03 ? 00:00:00 /usr/bin/gnome-software --gapplication-service
myth 3313 1 0 07:03 ? 00:00:00 /usr/libexec/tracker-store
myth 3319 1 0 07:03 ? 00:01:16 /usr/bin/vmtoolsd -n vmusr
myth 3331 2884 0 07:03 ? 00:00:00 abrt-applet
myth 3341 2884 0 07:03 ? 00:00:00 /usr/libexec/tracker-extract
myth 3352 2884 0 07:03 ? 00:00:00 /usr/libexec/tracker-miner-apps
myth 3355 2884 0 07:03 ? 00:00:00 /usr/libexec/tracker-miner-fs
myth 3413 1 0 07:03 ? 00:00:00 /usr/libexec/gvfsd-trash --spawner :1.3 /org/gtk/gvfs/exec_
myth 3445 1 0 07:03 ? 00:00:00 /usr/libexec/evolution-calendar-factory
myth 3454 1 0 07:03 ? 00:00:00 /usr/libexec/gvfsd-metadata
myth 3466 3185 0 07:03 ? 00:00:01 /usr/libexec/ibus-engine-simple
myth 3510 1 0 07:03 ? 00:00:00 /bin/bash /home/myth/netbeans-8.2/platform/lib/nbexec --use
myth 3760 3510 1 07:03 ? 00:12:38 /home/myth/netbeans-8.2/bin/jre/bin/java -Djdk.home=/home/m
myth 3872 3131 7 07:03 ? 01:05:16 /usr/lib64/firefox/firefox
myth 3920 1 0 07:03 ? 00:00:00 /usr/libexec/gconfd-2
myth 3929 3872 0 07:04 ? 00:08:15 /usr/lib64/firefox/plugin-container -greomni /usr/lib64/fir
apache 4107 1007 0 07:04 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 5838 2 0 09:40 ? 00:00:02 [kworker/3:0]
root 5890 987 0 09:44 ? 00:00:00 sshd: root@pts/0
root 5894 5890 0 09:44 pts/0 00:00:00 -bash
root 5946 987 0 09:44 ? 00:00:00 sshd: root@pts/1
root 5948 5946 0 09:44 pts/1 00:00:00 -bash
root 6165 987 0 09:51 ? 00:00:00 sshd: root@pts/2
root 6175 6165 0 09:51 pts/2 00:00:00 -bash
myth 6437 1 0 10:04 ? 00:00:00 /usr/libexec/dconf-service
root 7694 2 0 11:50 ? 00:00:00 [kworker/3:2]
root 9376 2 0 14:10 ? 00:00:00 [kworker/2:1]
apache 9918 1007 0 14:54 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 9929 1007 0 14:55 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 9932 1007 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 9965 1007 0 14:58 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 9979 1007 0 14:59 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 11479 2 0 16:16 ? 00:00:00 [kworker/1:2H]
root 12088 6175 0 16:50 pts/2 00:00:00 redis-cli -h 127.0.0.1 -p 6379
root 12137 5894 0 16:52 pts/0 00:00:01 php public/index.php index/Socket/run
root 12147 12137 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12152 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12153 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12154 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12155 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 13570 2 0 19:00 ? 00:00:01 [kworker/1:1]
root 13973 5948 0 19:38 pts/1 00:00:00 tail -f /home/myth/www/think/apps/swoole-data/swoole.log
root 14426 2 0 20:20 ? 00:00:00 [kworker/u256:2]
root 14900 2 0 21:04 ? 00:00:00 [kworker/1:1H]
postfix 14973 1527 0 21:10 ? 00:00:00 pickup -l -t unix -u
root 15017 2 0 21:16 ? 00:00:00 [kworker/0:0]
root 15117 2 0 21:26 ? 00:00:00 [kworker/1:2]
root 15174 756 0 21:30 ? 00:00:00 sleep 60
root 15175 2 0 21:31 ? 00:00:00 [kworker/1:0]
root 15176 987 0 21:31 ? 00:00:00 sshd: root@pts/3
root 15178 15176 1 21:31 pts/3 00:00:00 -bash
root 15204 1 0 21:31 ? 00:00:00 /usr/sbin/abrt-dbus -t133
root 15232 15178 0 21:31 pts/3 00:00:00 ps -eaf
[root@contoso ~]#
ps -eaf |grep 'index/Socket/run'
root 12137 5894 0 16:52 pts/0 00:00:01 php public/index.php index/Socket/run
root 12147 12137 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12152 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12153 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12154 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12155 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 15259 15178 0 21:34 pts/3 00:00:00 grep --color=auto index/Socket/run
[root@contoso ~]# ps -eaf |grep 'index/Socket/run'|grep -v "grep"
root 12137 5894 0 16:52 pts/0 00:00:01 php public/index.php index/Socket/run
root 12147 12137 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12152 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12153 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12154 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
root 12155 12147 0 16:52 pts/0 00:00:00 php public/index.php index/Socket/run
[root@contoso ~]# ps -eaf |grep 'index/Socket/run'|grep -v "grep"|awk '{print $2}'
12137
12147
12152
12153
12154
12155
[root@contoso ~]# ps -eaf |grep 'index/Socket/run'|grep -v "grep"|awk '{print $2}'|xargs
12137 12147 12152 12153 12154 12155
[root@contoso ~]#
ps -eaf |grep 'index/Socket/run'|grep -v "grep"|awk '{print $2}'|xargs kill -9
[root@contoso ~]# ps -eaf |grep 'index/Socket/run'|grep -v "grep"
[root@contoso ~]#
持续粘贴中 ... ... ... ...
相关文章推荐
- CentOS6.2 配置apache+MySQL+php开发环境
- 详解三:CentOS下编译安装PHP开发环境,配置LAMP
- CentOS 6部署PHP开发环境
- 开发php的扩展模块(centos环境下)
- centos6.5安装php开发环境
- [配置]centos5.3下配置php开发环境
- 在Visual Studio环境中开发PHP项目
- centos 配置php开发环境
- CentOS 7.0 配置php开发环境
- centos 配置php开发环境(eclipse PDT+Zend Debugger)
- 详解一:CentOS下编译安装PHP开发环境,配置LAMP
- 一步一步搭建CentOS+PHP+Mysql+Nginx开发环境
- 让PHP支持大型项目-构建JSP、PHP与JAVA融为一体的开发环境[转载]
- 在CentOS中配置PHP开发环境
- Windows 下 PHP 开发环境配置系列三 - eclipse PDT + Zend Debugger 调试web 项目
- 详解二:CentOS下编译安装PHP开发环境,配置LAMP
- [转载]让PHP支持大型项目-构建JSP、PHP与JAVA融为一体的开发环境
- Linux(centos)下用vim搭建php开发环境IDE
- PHP开发环境搭建 (XAMPP+Xdebug+netbeans,配置调试),创建第一个php项目
- 安装PHP开发环境及部署PHP项目