20160109http+php+myql
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了20160109http+php+myql相关的知识,希望对你有一定的参考价值。
[[email protected] ~]#yum update
[[email protected] ~]# yum install gcc gcc-c++ blibc blibc-devel cmake
[[email protected] etc]# yum install httpd
[[email protected] ~]#systemctl start httpd
[[email protected] etc]# systemctl start httpd.service
[[email protected] etc]# systemctl start httpd
[[email protected] etc]# systemctl enable httpd
[[email protected] etc]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[[email protected] etc]# firewall-cmd --reload
[[email protected] ~]# systemctl start httpd
[[email protected] ~]# ps -aux|grep httpd
[[email protected] etc]# cd /var/www/html/
[[email protected] html]# vi index.php
<?php
phpinfo();
?>
~
~
~
~
~
[[email protected] etc]#vi /etc/httpd/conf/httpd.conf
ServerSignature On #添加,在错误页中显示Apache的版本,Off为不显示
Options Indexes FollowSymLinks #修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi #修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None #修改为:AllowOverride All (允许.htaccess)
AddDefaultCharset UTF-8 #修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)
#Options Indexes FollowSymLinks #修改为 Options FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html #修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php(设置默认首页文件,增加index.php)
MaxKeepAliveRequests 500 #添加MaxKeepAliveRequests 500 (增加同时连接数)
:wq! #保存退出
systemctl restart httpd.service #重启apache
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #删除默认测试页
二、php配置
vi /etc/php.ini #编辑
date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off #禁止显示php版本的信息
short_open_tag = ON #支持php短标签
open_basedir = .:/tmp/ #设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题(例如:织梦内容管理系统),可以注销此行,或者直接写上程序的目录/data/www.111cn.net/:/tmp/
:wq! #保存退出
systemctl restart mariadb.service #重启MariaDB
systemctl restart httpd.service #重启apache
测试篇
cd /var/www/html
vi index.php #输入下面内容
<?php
phpinfo();
?>
:wq! #保存退出
三 手动編译安装mysql5.6
1 [[email protected] ~]# cd /home
[[email protected] home]# tar -zxvf mysql-5.6.26.tar.gz
2 [[email protected] ~]# yum -y install make gcc-c++ cmake bison-devel ncurses-devel
[[email protected] ~]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
3 出现以下错误提示:
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
解 决方法如下:
[[email protected] mysql-5.6.26]# rm CMakeCache.txt
[[email protected] mysql-5.5.11]# yum install ncurses-devel
[[email protected] mysql-5.5.11]# yum install bison
4 编译安装
[[email protected] mysql-5.5.11]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
[[email protected] mysql-5.5.11]# make && make install
5 如果没有就创建
[[email protected] mysql-5.5.11]#groupadd mysql
[[email protected] mysql-5.5.11]#useradd -g mysql mysql
修改/usr/local/mysql权限
[[email protected] mysql-5.5.11]#chown -R mysql:mysql /usr/local/mysql
[[email protected] mysql]# yum install perl-Module-Install.noarch
6 初始化配置
进入安装路径
cd /usr/local/mysql
进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
7 启动MySQL
添加服务,拷贝服务脚本到init.d目录,并设置开机启动
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start --启动MySQL
/etc目录下的my.cnf文件中涉及到数据文件目录的地方 /etc/my.cnf
[[email protected] mysql]# chown -R mysql:mysql data/
[[email protected] mysql]# chmod -R 777 /usr/local/mysql/data
三
[[email protected] mysql]# /etc/init.d/mysql start 启动后报错过程
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/bogon.pid).
解决过程
[[email protected] ~]# cd /usr/local/mysql
[[email protected] mysql]# chown -R mysql.mysql .
[[email protected] mysql]# su - mysql
[[email protected] ~]$ cd /usr/local/mysql
[[email protected] mysql]$ scripts/mysql_install_db
[[email protected] ~]# vi /etc/my.cnf
1 [mysqld]
2 datadir=/var/lib/mysql
3 socket=/var/lib/mysql/mysql.sock
4 # Disabling symbolic-links is recommended to prevent assorted security risks
5 symbolic-links=0
6 # Settings user and group are ignored when systemd is used.
7 # If you need to run mysqld under a different user or group,
8 # customize your systemd unit file for mariadb according to the
9 # instructions in http://fedoraproject.org/wiki/Systemd
10
11 [mysqld_safe]
12 log-error=/var/log/mysqld.log( 更改后日志路径)
13 pid-file=/var/lib/mysqld.pid( 更改后日志路径)
14 # log-error=/var/log/mariadb/mariadb.log(原安装后日志路径注解掉)
15 # pid-file=/var/run/mariadb/mariadb.pid(原安装后日志路径注解掉)
16
17
18 #
19 # include all files from the config directory
20 #
21 !includedir /etc/my.cnf.d
[[email protected] ~]#firewall-cmd --permanent --zone=public --add-port=3306/tcp
[[email protected] ~]#firewall-cmd --reload
[[email protected] mysql]# mysql -u root -p 进mysql
MySQL [(none)]>
MySQL [(none)]> show databases; 显示数据库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.02 sec)
MySQL [(none)]> use mysql; 用户mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MySQL [mysql]>
MySQL [mysql]> select user,password,host from user; 查看MYSQL用户密码
+------+----------+-----------+
| user | password | host |
+------+----------+-----------+
| root | | localhost |
| root | | bogon |
| root | | 127.0.0.1 |
| root | | ::1 |
| | | localhost |
| | | bogon |
+------+----------+-----------+
6 rows in set (0.00 sec)
MySQL [mysql]> update user set password=password(‘mysql‘); 给MYSQL用户设置密码及更新
Query OK, 6 rows affected (0.00 sec)
Rows matched: 6 Changed: 6 Warnings: 0
MySQL [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MySQL [mysql]>
MySQL [mysql]> select user,password,host from user; 查看MYSQL用户密码
+------+-------------------------------------------+-----------+
| user | password | host |
+------+-------------------------------------------+-----------+
| root | E74858DB86EBA20BC33D0AECAE8A8108C56B17FA | localhost |
| root | E74858DB86EBA20BC33D0AECAE8A8108C56B17FA | bogon |
| root | E74858DB86EBA20BC33D0AECAE8A8108C56B17FA | 127.0.0.1 |
| root | E74858DB86EBA20BC33D0AECAE8A8108C56B17FA | ::1 |
| | E74858DB86EBA20BC33D0AECAE8A8108C56B17FA | localhost |
| | E74858DB86EBA20BC33D0AECAE8A8108C56B17FA | bogon |
+------+-------------------------------------------+-----------+
6 rows in set (0.00 sec)
MySQL [mysql]> update user set host=‘%‘ where host=‘localhost‘; 给远程开启登录使用
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
MySQL [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
以上是关于20160109http+php+myql的主要内容,如果未能解决你的问题,请参考以下文章
PHP:获取 HTTP 协议版本(HTTP/1.1 与 HTTP/2)