码迷,mamicode.com
首页 > Web开发 > 详细

20160109http+php+myql

时间:2018-04-03 15:25:06      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:20160109http+php+myq

[root@bogon ~]#yum update
[root@localhost ~]# yum install gcc gcc-c++ blibc blibc-devel cmake
[root@localhost etc]# yum install httpd

[root@bogon ~]#systemctl start httpd
[root@localhost etc]# systemctl start httpd.service
[root@localhost etc]# systemctl start httpd
[root@localhost etc]# systemctl enable httpd
[root@localhost etc]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[root@localhost etc]# firewall-cmd --reload

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# ps -aux|grep httpd
[root@localhost etc]# cd /var/www/html/
[root@localhost html]# vi index.php
<?php
phpinfo();
?>
~
~
~
~
~

[root@localhost 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 [root@bogon ~]# cd /home
[root@bogon home]# tar -zxvf mysql-5.6.26.tar.gz

2 [root@bogon ~]# yum -y install make gcc-c++ cmake bison-devel ncurses-devel

[root@bogon ~]# 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):
解 决方法如下:

[root@bogon mysql-5.6.26]# rm CMakeCache.txt
[root@localhost mysql-5.5.11]# yum install ncurses-devel
[root@localhost mysql-5.5.11]# yum install bison

4 编译安装

[root@localhost 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

[root@localhost mysql-5.5.11]# make && make install

5 如果没有就创建

[root@localhost mysql-5.5.11]#groupadd mysql
[root@localhost mysql-5.5.11]#useradd -g mysql mysql

修改/usr/local/mysql权限

[root@localhost mysql-5.5.11]#chown -R mysql:mysql /usr/local/mysql
[root@bogon 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

[root@bogon mysql]# chown -R mysql:mysql data/
[root@bogon mysql]# chmod -R 777 /usr/local/mysql/data


[root@bogon mysql]# /etc/init.d/mysql start 启动后报错过程
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/bogon.pid).
解决过程
[root@localhost ~]# cd /usr/local/mysql

[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$ scripts/mysql_install_db

[root@bogon ~]# 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

[root@bogon ~]#firewall-cmd --permanent --zone=public --add-port=3306/tcp
[root@bogon ~]#firewall-cmd --reload

[root@bogon 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

标签:20160109http+php+myq

原文地址:http://blog.51cto.com/china8/2094215

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!