CentOS6.5+Nginx1.9+Mysql5.7+PHP7.0.6(LNMP)环境配置
CentOS6.5 安装就不介绍了,反正就是一键到底。不过建议安装时对安装选项做些调整,不要随系统安装apache、mysql和php,因为系统自带的版本都比较低,安装后再升级也比较麻烦,会出现各种意外。所以安装系统时最好不要用系统自带的程序包安装,等系统装完后到apache、mysql和php的官网下载最新的稳定版自行安装比较好。
CentOS7 的风格已经和6.5 大不一样了,舍弃了mysql数据库,而是采用MariaDB。要是在CentOS上安装Mysql5.7,需要先卸载MariaDB再进行安装。这个后面另外写篇blog单独讲。
#linux版本
[root@localhost ~]# cat /proc/version
Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013
[root@localhost /]# more /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
下载安装包:
Nginx:
http://nginx.org/en/download.html
Mysql:
http://dev.mysql.com/downloads/mysql/
选择合适的版本下载
PHP:
http://php.net/downloads.php
#安装包上传到Linux
[root@localhost ~]# cd /mnt/software/
[root@localhost software]# ll
total 18684
drwxr-xr-x. 4 root root 4096 May 12 09:34 Mysql
drwxr-xr-x. 4 root root 4096 May 11 17:03 nginx
-rw-r--r--. 1 root root 908984 May 11 10:11 nginx-1.9.15.tar.gz
drwxr-xr-x. 3 root root 4096 May 12 08:48 php
-rw-r--r--. 1 root root 18207283 May 11 10:11 php-7.0.6.tar.gz
#Nginx解压缩后
[root@localhost software]# ll nginx/nginx-1.9.15
total 696
drwxr-xr-x. 6 1001 1001 4096 May 11 17:03 auto
-rw-r--r--. 1 1001 1001 262510 Apr 20 00:02 CHANGES
-rw-r--r--. 1 1001 1001 400165 Apr 20 00:02 CHANGES.ru
drwxr-xr-x. 2 1001 1001 4096 May 11 17:03 conf
-rwxr-xr-x. 1 1001 1001 2481 Apr 20 00:02 configure
drwxr-xr-x. 4 1001 1001 4096 May 11 17:03 contrib
drwxr-xr-x. 2 1001 1001 4096 May 11 17:03 html
-rw-r--r--. 1 1001 1001 1397 Apr 20 00:02 LICENSE
-rw-r--r--. 1 root root 376 May 11 17:12 Makefile
drwxr-xr-x. 2 1001 1001 4096 May 11 17:03 man
drwxr-xr-x. 3 root root 4096 May 11 17:14 objs
-rw-r--r--. 1 1001 1001 49 Apr 20 00:02 README
drwxr-xr-x. 9 1001 1001 4096 May 11 17:03 src
#Mysql解压缩后
[root@localhost software]# ll Mysql/
total 457580
drwxr-xr-x. 2 root root 4096 May 12 09:34 -
-rw-r--r--. 1 root root 23767996 Mar 29 09:35 mysql-commercial-client-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 327756 Mar 29 09:35 mysql-commercial-common-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 3743708 Mar 29 09:35 mysql-commercial-devel-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 38838384 Mar 29 09:35 mysql-commercial-embedded-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 134452060 Mar 29 09:36 mysql-commercial-embedded-devel-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 2236920 Mar 29 09:36 mysql-commercial-libs-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 1716448 Mar 29 09:36 mysql-commercial-libs-compat-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 158941748 Mar 29 09:36 mysql-commercial-server-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 104476500 Mar 29 09:37 mysql-commercial-test-5.7.12-1.1.el6.x86_64.rpm
-rw-r--r--. 1 root root 25713 Apr 11 20:27 README.txt
#php安装包解压缩后
[root@localhost software]# ll php/php-7.0.6
total 6116
-rw-r--r--. 1 1000 1000 82119 Apr 29 02:12 acinclude.m4
-rw-r--r--. 1 1000 1000 312496 Apr 29 02:12 aclocal.m4
drwxr-xr-x. 2 1000 1000 4096 Apr 29 02:12 build
-rwxr-xr-x. 1 1000 1000 772 Apr 29 02:12 buildconf
-rw-r--r--. 1 1000 1000 334 Apr 29 02:12 buildconf.bat
-rw-r--r--. 1 1000 1000 11982 Apr 29 02:13 CODING_STANDARDS
-rw-r--r--. 1 1000 1000 42938 Apr 29 02:13 config.guess
-rw-r--r--. 1 root root 1059286 May 13 14:31 config.log
-rwxr-xr-x 1 root root 745 May 13 14:31 config.nice
-rwxr-xr-x. 1 root root 55320 May 13 14:31 config.status
-rw-r--r--. 1 1000 1000 35987 Apr 29 02:12 config.sub
-rwxr-xr-x. 1 1000 1000 2735886 Apr 29 02:12 configure
-rw-r--r--. 1 1000 1000 46742 Apr 29 02:12 configure.in
-rw-r--r--. 1 1000 1000 3163 Apr 29 02:13 CONTRIBUTING.md
-rw-r--r--. 1 1000 1000 91 Apr 29 02:13 CREDITS
drwxr-xr-x. 75 1000 1000 4096 Apr 29 02:12 ext
-rw-r--r--. 1 1000 1000 20831 Apr 29 02:12 EXTENSIONS
-rw-r--r--. 1 1000 1000 137 Apr 29 02:12 footer
-rw-r--r--. 1 1000 1000 1776 Apr 29 02:12 generated_lists
-rwxr-xr-x. 1 1000 1000 581 Apr 29 02:13 genfiles
-rw-r--r--. 1 1000 1000 1143 Apr 29 02:13 header
drwxr-xr-x. 2 root root 4096 May 12 08:52 include
-rw-r--r--. 1 1000 1000 87836 Apr 29 02:12 INSTALL
-rw-r--r--. 1 1000 1000 0 Apr 29 02:12 install-sh
drwxr-xr-x. 2 root root 4096 May 12 08:52 libs
-rwxr-xr-x 1 root root 210732 May 13 14:31 libtool
-rw-r--r--. 1 1000 1000 3218 Apr 29 02:12 LICENSE
-rw-r--r--. 1 1000 1000 199728 Apr 29 02:12 ltmain.sh
drwxr-xr-x. 4 1000 1000 4096 May 13 14:40 main
-rwxr-xr-x. 1 1000 1000 4129 Apr 29 02:13 makedist
-rw-r--r--. 1 root root 324378 May 13 14:31 Makefile
-rw-r--r--. 1 1000 1000 1088 Apr 29 02:12 Makefile.frag
-rw-r--r--. 1 root root 14516 May 13 14:31 Makefile.fragments
-rw-r--r--. 1 1000 1000 2485 Apr 29 02:12 Makefile.gcov
-rw-r--r--. 1 1000 1000 7237 Apr 29 02:12 Makefile.global
-rw-r--r--. 1 root root 270790 May 13 14:31 Makefile.objects
-rw-r--r--. 1 1000 1000 5317 Apr 29 02:12 makerpm
-rw-r--r--. 1 1000 1000 0 Apr 29 02:12 missing
-rw-r--r--. 1 1000 1000 0 Apr 29 02:12 mkinstalldirs
drwxr-xr-x. 2 root root 4096 May 13 14:41 modules
drwxr-xr-x. 2 1000 1000 4096 Apr 29 02:12 netware
-rw-r--r--. 1 1000 1000 55309 Apr 29 02:12 NEWS
drwxr-xr-x. 3 1000 1000 4096 May 12 08:53 pear
-rw-r--r-- 1 root root 1489 May 13 14:31 php7.spec
-rw-r--r--. 1 1000 1000 1489 Apr 29 02:12 php7.spec.in
-rw-r--r--. 1 1000 1000 2523 Apr 29 02:13 php.gif
-rw-r--r--. 1 1000 1000 68881 Apr 29 02:12 php.ini-development
-rw-r--r--. 1 1000 1000 68913 Apr 29 02:12 php.ini-production
-rw-r--r--. 1 1000 1000 7010 Apr 29 02:12 README.EXT_SKEL
-rw-r--r--. 1 1000 1000 5025 Apr 29 02:12 README.GIT-RULES
-rw-r--r--. 1 1000 1000 5417 Apr 29 02:13 README.input_filter
-rw-r--r--. 1 1000 1000 3426 Apr 29 02:12 README.MAILINGLIST_RULES
-rw-r--r--. 1 1000 1000 1473 Apr 29 02:12 README.md
-rw-r--r--. 1 1000 1000 6040 Apr 29 02:12 README.namespaces
-rw-r--r--. 1 1000 1000 5237 Apr 29 02:12 README.NEW-OUTPUT-API
-rw-r--r--. 1 1000 1000 7528 Apr 29 02:12 README.PARAMETER_PARSING_API
-rw-r--r--. 1 1000 1000 19766 Apr 29 02:12 README.REDIST.BINS
-rw-r--r--. 1 1000 1000 12700 Apr 29 02:13 README.RELEASE_PROCESS
-rw-r--r--. 1 1000 1000 5086 Apr 29 02:12 README.SELF-CONTAINED-EXTENSIONS
-rw-r--r--. 1 1000 1000 15355 Apr 29 02:12 README.STREAMS
-rw-r--r--. 1 1000 1000 8126 Apr 29 02:12 README.SUBMITTING_PATCH
-rw-r--r--. 1 1000 1000 6695 Apr 29 02:12 README.TESTING
-rw-r--r--. 1 1000 1000 4958 Apr 29 02:13 README.TESTING2
-rw-r--r--. 1 1000 1000 4261 Apr 29 02:12 README.UNIX-BUILD-SYSTEM
-rw-r--r--. 1 1000 1000 109 Apr 29 02:12 README.WIN32-BUILD-SYSTEM
-rwxr-xr-x. 1 1000 1000 82909 Apr 29 02:13 run-tests.php
drwxr-xr-x. 10 1000 1000 4096 Apr 29 02:12 sapi
drwxr-xr-x. 4 1000 1000 4096 May 13 14:31 scripts
-rwxr-xr-x. 1 1000 1000 2104 Apr 29 02:12 server-tests-config.php
-rwxr-xr-x. 1 1000 1000 53286 Apr 29 02:12 server-tests.php
-rwxr-xr-x. 1 1000 1000 108 Apr 29 02:12 snapshot
-rw-r--r--. 1 1000 1000 10 Apr 29 02:12 stamp-h.in
-rw-r--r--. 1 1000 1000 1 Apr 29 02:12 stub.c
drwxr-xr-x. 10 1000 1000 4096 Apr 29 02:12 tests
drwxr-xr-x. 3 1000 1000 4096 Apr 29 02:12 travis
drwxr-xr-x. 4 1000 1000 4096 May 12 08:58 TSRM
-rw-r--r--. 1 1000 1000 28340 Apr 29 02:12 UPGRADING
-rw-r--r--. 1 1000 1000 15442 Apr 29 02:12 UPGRADING.INTERNALS
-rwxr-xr-x. 1 1000 1000 146 Apr 29 02:12 vcsclean
drwxr-xr-x. 3 1000 1000 4096 Apr 29 02:12 win32
drwxr-xr-x. 5 1000 1000 12288 May 12 09:00 Zend
第一部分:安装Nginx
#Nginx安装
查阅的资料:
CenOS Linux安装nginx
http://www.cnblogs.com/skyblue/archive/2013/05/13/3075900.html
nginx启动,重启,关闭命令
http://www.cnblogs.com/derekchen/archive/2011/02/17/1957209.html
查看服务器上安装的nginx版本号
http://blog.csdn.net/love__coder/article/details/6587922
【转】Linux Nginx负载均衡【精】
http://www.cnblogs.com/skyblue/archive/2013/05/14/3077334.html
一、安装nginx
1、在nginx官方网站下载一个包,下载地址是:http://nginx.org/en/download.html
2、WinSCP(ftp上传工具).exe FTP 上传工具上传达到CentOS中
3、我是先建一个目录,把要用的到的安装包放到一起.
#mkdir /home/
#tar zxf nginx-1.4.1.tar.gz
#cd nginx-1.4.1
4、安装pcre开发包
#yum install -y pcre-devel
5、如果安装出现在下面的错误是缺少编译环境。安装编译源码所需的工具和库
./configure: error: C compiler cc is not found
#yum install gcc gcc-c++ ncurses-devel perl
6、安装cmake,从http://www.cmake.org下载源码并编译安装
#yum -y install make gcc gcc-c++ ncurses-devel
#yum -y install zlib zlib-devel
7、如果需要ssl功能需要openssl库
#yum -y install openssl openssl--devel
8、安装nginx
#cd nginx-1.4.1
#./configure --prefix=/opt/nginx
#make
#make install
9、启动服务
#/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
10、停止服务
#/opt/nginx/sbin/nginx -s stop
11、查看端口占用情况
#netstat -tunlp
12、如果其它机器无法访问,解决方法如下:
#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
然后保存:
#/etc/rc.d/init.d/iptables save
重启防火墙
#/etc/init.d/iptables restart
Nginx 配置
http://www.cnblogs.com/skyblue/archive/2013/05/14/3077334.html
#编译:
#./configure --prefix=/usr/local/nginx
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
#后面安装:
#make & make install
#启动
[root@localhost software]# /usr/local/nginx/sbin/nginx
#查看端口,默认端口是80
[root@localhost software]# netstat -antlp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2723/nginx
#查看进程
[root@localhost software]# ps -ef | grep nginx
root 2723 1 0 15:14 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 2724 2723 0 15:14 ? 00:00:00 nginx: worker process
root 2736 2587 0 15:18 pts/0 00:00:00 grep nginx
#版本
[root@localhost /]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.15
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
configure arguments: --prefix=/usr/local/nginx
#nginx重启
/usr/nginx/sbin/nginx -s reload
小结:Nginx安装没有遇到什么困难,环境包有没有安装都忘了,反正是比较顺利的。
第二部分:Mysql安装
Mysql5.7 增加了安全的新特性,安装后登录方法与之前完全不同,弄了2天才搞定。
参考的资料:
MySQL5.7数据库的初始化方法
http://www.7down.net/article/81736.html
Centos7安装Web服务器–Mysql5.7.12安装
http://linux.it.net.cn/e/data/mysql/2016/0508/21467.html
MySQL5.7的新特性
http://www.cnblogs.com/xuanzhi201111/p/5148113.html
MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket
http://www.jb51.net/article/56952.htm
Installing MySQL on Linux Using the MySQL Yum Repository
http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
如何给mysql创建新用户并授权
http://kaixin322.blog.sohu.com/158493652.html
MySQL创建远程登陆用户并授权实际操作
http://www.bkjia.com/Mysql/581397.html
linux下mysql提示"mysql deamon failed to start"错误的解决方法
http://www.jb51.net/article/36187.htm
CentOS 7的selinux问题:打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器。
#安装小结:
安装mysql5.7
1. 创建mysql用户并授权;
2. 创建mysqldata目录并授权给mysql用户;(data不要与mysql安装文件放在一起)
3. rpm -ivh 安装mysql
4. 修改/etc/my.cnf 配置文档,指定datapath,和sock,log等路径;
5. 初始化mysql,有几种方法:
5.1 #mysqld --initialize 查看mysqllog日志,初始化时会生成一个临时密码:
A temporary password is generated for root@localhost: A#Avu_kyi6<l
# mysql -uroot -p'Zabbix123456'
5.2 #mysqld --initialize-insecure 初始化时不会生成临时密码,
# mysql -uroot --skip-password
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
5.3 mysqld_safe --skip-grant-tables --skip-networking --user=mysql &
mysql -uroot mysql
update user set authentication_string=password('oracle'), host='%', password_expired = 'N' where user='root';
select user, host, password_expired, account_locked, authentication_string from user order by user, host;
flush privileges;
6. 初始化后再启动mysql服务;
7. mysql客户端登录,创建用户,授权密码;
#安装mysql
安装过程没完全记录下来,下面贴了一下老师安装的记录:
安装各个rpm包
rpm -ivh mysql-commercial-common-*.rpm
rpm -ivh mysql-commercial-libs-*.rpm
rpm -ivh mysql-commercial-client-*.rpm
rpm -ivh --replacefiles mysql-commercial-server-*.rpm
rpm -ivh mysql-commercial-devel-*.rpm
rpm -ivh mysql-commercial-embedded-*.rpm
rpm -ivh mysql-commercial-test-*.rpm
检查安装包
rpm -qa | grep ^mysql-commercial- | wc -l
创建mysql用户
usermod -s /bin/bash mysql
echo "mysql:oracle" | /usr/sbin/chpasswd
查看Mysql版本:
mysql -V
初始化前一定要先修改/etc/my.cnf文件,如果初始化错误,要重新修改/etc/my.cnf文件,删除mysql创建的文件夹和文件再重新初始化。
一旦有数据写入数据库,就不能再重新做数据库的初始化。所以建库一开始就要规划好,免得后面维护自添烦恼。
#my.cnf配置参数,红色部分是发生问题后再添加的,算是需要重视的地方吧。
[root@localhost ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
#socket=/tmp/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
#log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /data/mysql_data_3306/mysql.sock
pid-file = /data/mysql_data_3306/mysql.pid
port = 3306
# MyISAM #
key_buffer_size = 1344M
#myisam_recover = FORCE,BACKUP
# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
# DATA STORAGE #
datadir = /data/mysql_data_3306/
long_query_time = 1
# BINARY LOGGING #
log-bin = /data/log-bin/mysql-bin-3306
expire-logs-days = 14
sync-binlog = 1
server-id = 1
max_binlog_size = 500M
# REPLICATION #
relay-log = /data/log-bin/relay-bin-3306
slave-net-timeout = 60
# CACHES AND LIMITS #
tmp_table_size = 32M
max_heap_table_size = 32M
max_connections = 500
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 4096
table_open_cache = 4096
# INNODB #
innodb_data_file_path = ibdata1:128M;ibdata2:10M:autoextend
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_lock_wait_timeout = 50
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_thread_concurrency = 8
innodb_buffer_pool_size = 8G
# LOGGING #
log-error = /data/mysql_log/mysql-error-3306.log
log-queries-not-using-indexes = 1
slow-query-log = 1
long_query_time = 1
slow-query-log-file = /data/mysql_log/mysql-slow-3306.log
explicit_defaults_for_timestamp=true
[mysql]
no-auto-rehash
socket =/data/mysql_data_3306/mysql.sock
[mysqldump]
socket=/data/mysql_data_3306/mysql.sock
[mysqladmin]
socket=/data/mysql_data_3306/mysql.sock
[root@localhost ~]#
#创建目录,并授权:
创建目录mkdir
授权:chown + chmod
注意:/data/mysql_data_3306 这个文件夹不要创建,因为这是mysql初始化时由数据库来创建的。
操作没有记录,下面给出操作后的结果:
[root@localhost software]# cd /
[root@localhost /]# ll
total 1006
drwxr-xr-x. 2 root root 4096 May 12 09:35 -
dr-xr-xr-x. 2 root root 4096 May 12 09:16 bin
dr-xr-xr-x. 5 root root 1024 May 6 16:49 boot
drwxr-xr-x. 2 root root 4096 Nov 23 2013 cgroup
drwxrwxr-x. 5 mysql mysql 4096 May 13 08:55 data
drwxr-xr-x 18 root root 3580 May 15 14:24 dev
drwxr-xr-x. 126 root root 12288 May 15 15:21 etc
drwxr-xr-x. 3 root root 4096 May 6 16:52 home
dr-xr-xr-x. 11 root root 4096 May 11 17:08 lib
dr-xr-xr-x. 9 root root 12288 May 13 09:06 lib64
drwx------. 2 root root 16384 May 6 16:24 lost+found
drwxr-xr-x. 2 root root 4096 Sep 23 2011 media
drwxr-xr-x 2 root root 0 May 15 14:24 misc
drwxr-xr-x. 3 root root 4096 May 11 10:17 mnt
drwxr-xr-x 2 root root 0 May 15 14:24 net
-rw-r--r--. 1 root root 908984 May 11 16:57 nginx
drwxr-xr-x. 3 root root 4096 May 6 16:41 opt
drwxr-xr-x. 2 root root 4096 May 12 09:35 p
dr-xr-xr-x 148 root root 0 May 15 14:23 proc
dr-xr-x---. 28 root root 4096 May 13 21:01 root
dr-xr-xr-x. 2 root root 12288 May 12 09:16 sbin
drwxr-xr-x. 2 root root 4096 May 6 16:28 selinux
drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x 13 root root 0 May 15 14:23 sys
drwxrwxrwt. 21 root root 4096 May 15 15:21 tmp
drwxr-xr-x. 13 root root 4096 May 6 16:28 usr
drwxr-xr-x. 22 root root 4096 May 6 16:41 var
[root@localhost /]# cd data
[root@localhost data]# cd ..
[root@localhost /]# ll data
total 12
drwxr-xr-x. 2 mysql mysql 4096 May 15 14:24 log-bin
drwxr-x--x 5 mysql mysql 4096 May 15 14:24 mysql_data_3306
drwxr-xr-x. 2 mysql mysql 4096 May 12 15:59 mysql_log
[root@localhost /]#
[root@localhost /]# ll data/mysql_data_3306/
total 677956
-rw-r----- 1 mysql mysql 56 May 13 08:55 auto.cnf
-rw------- 1 mysql mysql 1680 May 13 08:55 ca-key.pem
-rw-r--r-- 1 mysql mysql 1075 May 13 08:55 ca.pem
-rw-r--r-- 1 mysql mysql 1079 May 13 08:55 client-cert.pem
-rw------- 1 mysql mysql 1680 May 13 08:55 client-key.pem
-rw-r----- 1 mysql mysql 302 May 13 21:03 ib_buffer_pool
-rw-r----- 1 mysql mysql 134217728 May 15 14:24 ibdata1
-rw-r----- 1 mysql mysql 10485760 May 13 08:55 ibdata2
-rw-r----- 1 mysql mysql 268435456 May 15 14:24 ib_logfile0
-rw-r----- 1 mysql mysql 268435456 May 13 08:55 ib_logfile1
-rw-r----- 1 mysql mysql 12582912 May 15 14:24 ibtmp1
drwxr-x--- 2 mysql mysql 4096 May 13 08:56 mysql
-rw-rw---- 1 root root 5 May 15 14:24 mysqld_safe.pid
srwxrwxrwx 1 mysql mysql 0 May 15 14:24 mysql.sock
-rw------- 1 mysql mysql 5 May 15 14:24 mysql.sock.lock
drwxr-x--- 2 mysql mysql 4096 May 13 08:56 performance_schema
-rw------- 1 mysql mysql 1676 May 13 08:55 private_key.pem
-rw-r--r-- 1 mysql mysql 452 May 13 08:55 public_key.pem
-rw-r--r-- 1 mysql mysql 1079 May 13 08:55 server-cert.pem
-rw------- 1 mysql mysql 1676 May 13 08:55 server-key.pem
drwxr-x--- 2 mysql mysql 12288 May 13 08:56 sys
#/etc/my.cnf配置好,目录和权限弄好,后面可以开始mysql初始化了
#初始化时最好指定配置文件,其实默认就是/etc/my.cnf,保险一点指定好。
#mysql5.7的初始化命令:
#mysqld --initialize 查看mysqllog日志,初始化时会生成一个临时密码
注意跟踪日志文件:
[root@localhost /]# tail -f data/mysql_log/mysql-error-3306.log
[root@localhost mysql_log]# sudo grep 'temporary password' /var/log/mysqld.log
2016-05-12T07:30:00.664146Z 1 [Note] A temporary password is generated for root@localhost: 2ew%JKh?&;)a
#mysqld --initialize-insecure 初始化时不会生成临时密码
#或者指定配置文件后直接启动mysql,第一次启动时会自动进行初始化的。
[root@localhost /]# ./etc/rc.d/init.d/mysqld start -dafaults-file=/etc/my.cnf
Initializing MySQL database: [ OK ]
Installing validate password plugin: [ OK ]
Starting mysqld: [ OK ]
[root@localhost /]# service mysqld start
Starting mysqld: [ OK ]
[root@localhost /]# /etc/rc.d/init.d/mysqld status
mysqld (pid 2235) is running...
[root@localhost /]# ./etc/rc.d/init.d/mysqld status
mysqld (pid 2235) is running..
#mysql启动
/etc/rc.d/init.d/mysqld start
#mysql状态查看
/etc/rc.d/init.d/mysqld status
#mysql停止
/etc/rc.d/init.d/mysqld stop
#mysql重启
/etc/rc.d/init.d/mysqld stop
#service命令也可以用
[root@localhost /]# service mysqld status
mysqld (pid 2235) is running...
#查看mysql端口
[root@localhost /]# netstat -nat | grep 3306
tcp 0 0 :::3306 :::* LISTEN
[root@localhost /]# netstat -ntlp | grep 3306
tcp 0 0 :::3306 :::* LISTEN 2235/mysqld
#查看mysql进程
[root@localhost /]# ps -ef | grep mysql
root 1605 1 0 14:24 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/data/mysql_data_3306/ --socket=/data/mysql_data_3306/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 2235 1605 0 14:24 ? 00:00:17 /usr/sbin/mysqld --basedir=/usr --datadir=/data/mysql_data_3306/ --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/data/mysql_log/mysql-error-3306.log --open-files-limit=65535 --pid-file=/var/run/mysqld/mysqld.pid --socket=/data/mysql_data_3306/mysql.sock --port=3306
root 3250 2587 0 16:35 pts/0 00:00:00 grep mysql
[root@localhost /]# ps aux |grep mysqld
root 1605 0.0 0.0 108328 1472 ? S 14:24 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/data/mysql_data_3306/ --socket=/data/mysql_data_3306/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 2235 0.2 49.4 12318996 1941060 ? Sl 14:24 0:17 /usr/sbin/mysqld --basedir=/usr --datadir=/data/mysql_data_3306/ --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/data/mysql_log/mysql-error-3306.log --open-files-limit=65535 --pid-file=/var/run/mysqld/mysqld.pid --socket=/data/mysql_data_3306/mysql.sock --port=3306
root 3254 0.0 0.0 103252 796 pts/0 S+ 16:36 0:00 grep mysqld
#kill 进程
sudo kill -9 PID(进程号),这种方法也能停止mysql,Nginx
#查看mysql版本
[root@localhost ~]# mysql -V
mysql Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using EditLine wrapper
#登录mysql
//-------------------出现过的错误------------------------------------//
//前面已经贴出/etc/my.cnf配置内容,正常安装的话应该不会再出现下面问题。
//当然,要注意将/etc/selinux/config中的SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器。还有注意/data的目录创建和授权。
mysql -hlocalhost -uroot -p'2ew%JKh?&;)a'
报错:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
是因为/etc/my.cnf配置文件里面没有给客户端添加:
[mysql ]
socket=/tmp/mysql .sock
//-----------------END----------------------------//
MySQL5.7数据库的初始化方法
http://www.7down.net/article/81736.html
添加[mysql]的参数后,我又重新初始化了mysql数据库:
#mysqld --initialize
日志文件内容 :
2016-05-13
2016-05-13T00:26:44.674290Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
100
100 200
100 200
2016-05-13T00:29:20.881543Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-05-13T00:29:21.430663Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-05-13T00:29:21.582889Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: bcaff746-18a1-11e6-8d1c-080027f6166a.
2016-05-13T00:29:21.591708Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-05-13T00:29:22.816877Z 0 [Warning] CA certificate ca.pem is self signed.
2016-05-13T00:29:23.687314Z 1 [Note] A temporary password is generated for root@localhost: A#Avu_kyi6<l
2016-05-13T00:29:30.464975Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2016-05-13T00:29:30.465808Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2016-05-13T00:29:30.465872Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2016-05-13T00:29:30.465917Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2016-05-13T00:29:30.465997Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
#登录mysql
[root@localhost ~]# mysql -uroot --skip-password
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.12-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
#修改root密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
#用新密码登录
[root@localhost ~]# mysql -uroot -p'新密码'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.12-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql>
mysql> use mysql
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| engine_cost |
| event |
| func |
| general_log |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |s
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
31 rows in set (0.00 sec)
mysql>
创建新用户
GRANT USAGE ON *.* TO 新用户@localhost IDENTIFIED BY '新用户密码' WITH GRANT OPTION;
给用户授权表
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON tablename.* TO 新用户@localhost IDENTIFIED BY '新用户密码';
FLUSH PRIVILEGES;
#mysql安装结束。
#第三部分:PHP安装
PHP的安装还好,问题是后面php与mysql的连接出现点问题,经查是php7.0 的新特性。
PHP的官方文档还是要看的,不过太长了,没有那么多时间一一看过去。后来还是在网上找了解决方法。
参考的资料:
Linux环境PHP7.0安装
http://blog.csdn.net/21aspnet/article/details/47708763
Linux环境Nginx安装与调试以及PHP安装
http://blog.csdn.net/unix21/article/details/8544922
Linux下Nginx+PHP+MySQL配置
http://dedecms.com/knowledge/servers/linux-bsd/2012/0820/10515.html
nginx连接PHP 5.5 – ttlsa教程系列之nginx
http://www.ttlsa.com/nginx/nginx-php-5_5/
linux下nginx+php+mysql环境搭建
http://blog.csdn.net/ihelloworld/article/details/7029796
LNMP(linux+nginx+mysql+php)服务器环境配置
http://www.cnblogs.com/mchina/archive/2012/05/17/2507102.html
PHP,MySQL的安装与配置
http://www.cnblogs.com/janas/archive/2012/08/27/2659240.html
里面有my.cnf的配置说明
PHP7连接MySql错误”Fatal error: Uncaught Error: Call to undefined function mysql_connect()”
http://www.happy3w.com/2016/01/11/php7连接mysql错误fatal-error-uncaught-error-call-to-undefined-function-mysql_connect/
PHP mysqli_select_db() Function - W3Schools
mysqli::select_db
http://php.net/manual/zh/mysqli.select-db.php
#安装
依赖包:
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel
yum -y install curl-devel
yum -y install libxslt-devel
[root@localhost php-7.0.6]#
./configure --prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
directorytreeiterator.inc
pharcommand.inc
directorygraphiterator.inc
clicommand.inc
invertedregexiterator.inc
phar.inc
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP FPM binary: /usr/local/php/sbin/
Installing PHP FPM config: /usr/local/php/etc/
Installing PHP FPM man page: /usr/local/php/php/man/man8/
Installing PHP FPM status page: /usr/local/php/php/php/fpm/
Installing phpdbg binary: /usr/local/php/bin/
Installing phpdbg man page: /usr/local/php/php/man/man1/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.3.0
[PEAR] PEAR - installed: 1.10.1
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/mnt/software/php/php-7.0.6/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
[root@localhost php-7.0.6]#
配置文件
# cp php.ini-development /usr/local/php/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
#启动php的php-fpm
[root@localhost ~]# /usr/local/php/sbin/php-fpm
[root@localhost php-7.0.6]# /etc/init.d/php-fpm
#查看启动进程
[root@localhost php-7.0.6]# ps aux|grep php
root 11008 0.0 0.1 208520 6060 ? Ss 14:50 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody 11009 0.0 0.1 208520 5476 ? S 14:50 0:00 php-fpm: pool www
nobody 11010 0.0 0.1 208520 5476 ? S 14:50 0:00 php-fpm: pool www
root 11012 0.0 0.0 103252 828 pts/5 S+ 14:50 0:00 grep php
[root@localhost php-7.0.6]#
配置nginx支持PHP
nginx的配置文件nginx.conf在
# cd /usr/local/nginx/conf
nginx默认web文件夹在/usr/local/nginx/html
如果需要nginx支持PHP需要修改nginx.conf,加入如下语句:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/www$fastcgi_script_name;
}
本机的web文件夹在/usr/local/nginx/html,需要修改fastcgi_param SCRIPT_FILENAME指向对应目录即可:
所以
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
注意,如果pfp-fpm配置文件侦听9001等端口,需要改对应文件:
# /usr/local/php/etc/php-fpm.conf
如果还需要解析/usr/www下的html文件,需要改配置nginx.conf
location / {
#root html;
root /usr/www;
index index.html index.htm;
}
还有一点需要注意:php-fpm侦听端口范围9000-9999,nginx开启端口800-900比较好。
我的Nginx的nginx.conf配置:
[root@localhost /]# cat /usr/local/nginx/conf/nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
//--------End
重启nginx
# /usr/local/nginx/sbin/nginx -s reload
测试页面info.php
<?php
phpinfo();
?>
[root@localhost conf]# cd /usr/local/nginx/
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ./nginx
[root@localhost sbin]# netstat -antlp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11111/nginx
tcp 0 0 0.0.0.0:42938 0.0.0.0:* LISTEN 1380/rpc.statd
tcp 0 0 :::54305 :::* LISTEN 1380/rpc.statd
[root@localhost sbin]#
第四部分:PHP连Mysql
#php连mysql出现点问题:
然后参考下面的资料,还有查了个国外的论坛,外国人的给出了连接方法。
PHP7连接MySql错误”Fatal error: Uncaught Error: Call to undefined function mysql_connect()”
http://www.happy3w.com/2016/01/11/php7连接mysql错误fatal-error-uncaught-error-call-to-undefined-function-mysql_connect/
PHP mysqli_select_db() Function - W3Schools
mysqli::select_db
http://php.net/manual/zh/mysqli.select-db.php
[root@localhost /]# ll /usr/local/nginx/html
total 28
-rw-r--r--. 1 root root 537 May 11 17:14 50x.html
-rw-r--r--. 1 root root 612 May 11 17:14 index.html
-rw-r--r-- 1 root root 30 May 13 14:58 info.php
-rw-r--r-- 1 root root 285 May 13 15:45 testdb2.php
-rw-r--r-- 1 root root 510 May 13 20:42 testdb3.php
-rw-r--r-- 1 root root 735 May 13 20:46 testdb4.php
-rw-r--r-- 1 root root 164 May 13 15:33 testdb.php
#原先的php连mysql测试库的方法已经无法使用:
[root@localhost /]# cat /usr/local/nginx/html/testdb.php
<?php
$con = mysql_connect("localhost","root","密码");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_close($con);
?>
#网页提示:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /usr/local/nginx/html/testdb.php:4 Stack trace: #0 {main} thrown in/usr/local/nginx/html/testdb.php on line 4
#原来是PHP7.0的新特性
extension=php_mysqli.dll 替代了之前的 extension=php_mysql.dll
[root@localhost /]# cat /usr/local/php/lib/php.ini | grep extension=
; extension=modulename.extension
; extension=msql.dll
; extension=msql.so
; extension=/path/to/extension/msql.so
extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite3.dll
;extension=php_tidy.dll
extension=php_xmlrpc.dll
;extension=php_xsl.dll
#而且mysqlid连mysql的connect已经还要包含sock.....
[root@localhost /]# cat /usr/local/nginx/html/testdb4.php
<?php
$mysqli = new mysqli("localhost", "root", "密码", "mysql",0,'/data/mysql_data_3306/mysql.sock');
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* return name of current default database */
if ($result = $mysqli->query("SELECT DATABASE()")) {
$row = $result->fetch_row();
printf("Default database is %s.\n", $row[0]);
$result->close();
}
/* change db to world db */
$mysqli->select_db("mysql");
/* return name of current default database */
if ($result = $mysqli->query("SELECT DATABASE()")) {
$row = $result->fetch_row();
printf("Default database is %s.\n", $row[0]);
$result->close();
}
$mysqli->close();
?>
#网页显示:
Default database is mysql. Default database is mysql.
——php终于和mysql连上了。
#关机
[root@localhost /]# init 0
启动命令汇总:
//----------启动和查看状态--------------//
#系统启动后,mysql是自动启动的
[root@localhost ~]# /etc/rc.d/init.d/mysqld status
mysqld (pid 2250) is running...
#如果mysql没有启动,就手工启动
[root@localhost ~]# /etc/rc.d/init.d/mysqld start
Starting mysqld: [ OK ]
#查看端口
[root@localhost ~]# netstat -ntlp | grep 3306
tcp 0 0 :::3306 :::* LISTEN 3395/mysqld
#启动nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx
#查看端口
[root@localhost ~]# netstat -antlp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3472/nginx
tcp 0 0 0.0.0.0:44861 0.0.0.0:* LISTEN 1380/rpc.statd
tcp 0 0 :::34557 :::* LISTEN 1380/rpc.statd
#启动php-fpm
[root@localhost ~]# /usr/local/php/sbin/php-fpm
#查看端口,默认端口是9000
[root@localhost ~]# netstat -antlp | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3482/php-fpm
//-------------------------//
总结:
安装新的版本总会有问题,官方的文档还是要看的。
英语还是要多练练,要提高英文文档的阅读速度,官方文档一般东西繁多,一份文档要是看上好几天,工作效率也会是问题。