写下来以后少碰点吭
实用命令
//查看端口
netstat -ntpl
//解压
tar -zxvf
//查找文件
whereis
which
find / -name ".conf"
//修改所有者
chown -R nginx /usr/local/nginx
//修改用户组
chgrp -R nginx /usr/local/nginx
//查看某个应用的进程号
ps aux | grep mysql
//添加用户组
useradd -s /sbin/nolgoin nginx
//检测系统是否自带
yum list installed | grep mysql
//删除自带
yum -y remove mysql-libs.x86_64
//查看可用版本
yum repolist all | grep mysql
//nginx启动
/usr/local/nginx/sbin/nginx
//mysql启动
service mysqld start
//php-fpm启动
/usr/sbin/php-fpm
//安装
yum install gcc-c++
//生成临时密码
grep 'temporary password' /var/log/mysqld.log
//mysql修改密码
mysql -uroot -p
use mysql;
update user set authentication_string=password('123456') where user='root';
flush privileges;
SET PASSWORD = PASSWORD('123456');
//mysql添加远程访问权限
use mysql;
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
//查看有效应用
yum list available "php56w-*"
//php查看版本
php -v
//php查看模块
php -m
//查看glibc已安装版本
strings /lib64/libc.so.6 | grep GLIBC
一、安装nginx 1.9.9
环境:阿里云的学生机 Centos 6.8,首先得更新yum源
备份原来的yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Bas.repo.bak
下载新的yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
清除以前的yum源缓存
yum clean all
建立新yum源的缓存
yum makecache
yum源更新成功了
最开始想用下面的命令把依赖都装好,但是很奇怪,更新了yum源下面的命令还是不能运行,依赖只能自己一个一个下载安装了
yum install -y make zlib zlib-devel openssl openssl-devel gcc-c++
1、下载nginx 1.9.9
wget -c https://nginx.org/download/nginx-1.9.9.tar.gz
2、解压
tar -zxvf nginx-1.9.9.tar.gz
3、安装到 /usr/local/nginx,所以在/usr/local下新建文件夹
mkdir nginx
4、分配一个用户组给nginx使用,后面配置访问权限要用到
useradd -s /sbin/nolgoin nginx
5、进入nginx目录
cd /usr/local/nginx
6、配置nginx安装选项,安装到/usr/local/nginx,安装http_stub_status模块,用户和用户组是 nginx
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --user=nginx --group=nginx
7、编译
make
8、开始安装
make install
9、make install三次都报错,因为有依赖模块没装上,分别是 openssl,zlib,pcre,
a.安装openssl
先下载
wget -c https://www.openssl.org/source/openssl-1.0.2p.tar.gz
解压 openssl
tar -zxvf openssl-1.0.2p.tar.gz
安装到/usr/local/openssl,新建文件夹openssl
mkdir openssl
进入解压后的目录配置安装选项
./config --prefix=/usr/local/openssl
编译和安装
make
make install
openssl安装好了
b.安装zlib
先下载 zlib
wget -c http://www.zlib.net/zlib-1.2.11.tar.gz
解压 zlib
tar -zxvf zlib-1.2.11.tar.gz
安装到/usr/local/zlib,新建文件夹zlib
mkdir zlib
进入解压后的目录安装选项,,
./configure --prefix=/usr/local/zlib
然后编译和安装
make
make install
zlib安装好了
c.安装pcre
先下载pcre
wget https://sourceforge.net/projects/pcre/files/pcre/8.42/pcre-8.42.tar.gz/download
下载下来的文件名是download,不是pcre-8.42.tar.gz,试了下,可以直接解压
tar -zxvf download
这里直接配置安装选项了,网上抄的,直接安装到了pcre-8.42文件夹,就是解压后的文件夹
./configure && make && make install && echo $?
pcre安装好了
10、终于回到正题了,安装nginx 1.9.9,重新配置,配置加上三个参数 --with-openssl,--with-zlib,--with-pcre,名字可能不是这个,具体要看报错信息里面的名字,三个参数的值分别就是安装好后的文件夹
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-openssl=/usr/local/openssl --with-zlib=/usr/local/zlib
--with-http_ssl_module --with-pcre=/usr/local/pcre-8.42 --user=nginx --group=nginx
11、编译和安装
make && make install
出来这么一段信息
Configuration summary
+ using PCRE library: /usr/local/pcre-8.42
+ using OpenSSL library: /usr/local/openssl
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using zlib library: /usr/local/zlib
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
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"
不报错了,
nginx 的启动
首先查找nginx的启动文件
whereis nginx
出来/usr/local/nginx/sbin/nginx
这样可以直接运行,运行后,访问
x.x.x.x 如果成功会出现nginx的欢迎页面,这样nginx就算安装好了
由于没有做成服务,怎么关闭nginx呢
查看nginx master主进程号
ps aux | grep nginx
后面标识为 nginx master的就是主进程,找到进程号,比如1273,然后
kill 1273
nginx就被关闭了,傻逼就只会用傻逼的办法~~没办法,谁叫我这么傻逼呢
参考众多大神文档
https://segmentfault.com/a/1190000014485090
二、安装mysql57
1、使用
yum install mysql
,竟然是mysql 5.1的版本,吭
首先查看yum源自带的mysql,把yum 自带的mysql删了
yum list installedd | grep mysql
出来 mysql-libs.x86_64
2、删除这个源
yum -y remove mysql-libs.x86_64
3、使用mysql 5.7的yum源,
rpm -Uvh http://repo.mysql.com/mysql57-community-release-e16.rpm
这里要注意一下,我最开始下载的是e17,但是这是给centos7安装的版本,而我的是centos6,所以要下e16后缀的,
还有其他fc,sb等后缀的,那是给其他linux操作系统使用的,这里浪费好多时间,拿个centos7的版本在centos6上装了好久,真是个大傻逼,
移除那个e17的版本
yum remove "mysql57-community-release-el7.*"
然后还要执行
yum clean all,
不然移除不掉
4、查看mysql5.7 yum里面有哪些包
yum repolist all | grep mysql ,出现一个列表
[root@iZe4vx local]# yum repolist all | grep mysql
mysql-cluster-7.5-community MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-connectors-community MySQL Connectors Community enabled: 65
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community MySQL Tools Community enabled: 69
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql-tools-preview MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community MySQL 5.7 Community Server enabled: 287
mysql57-community-source MySQL 5.7 Community Server - S disabled
mysql80-community MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - S disabled
出来很多版本和包,有5.5,5.6,5.7和8.0的,默认其他版本是关闭的,只有5.7是开放的,就是看后面的disabled和enabled
一定要把其他的版本关闭,不能安装不成功的
5、安装mysql5.7的工具套件等
yum install mysql
6、安装mysql5.7的服务端
yum install mysql-server
mysql5.7安装好了,三分钟写完,装了三个小时还不止,吭
启动mysql
service mysqld start
关闭mysql
service mysqld stop
重启mysql
service mysqld restart
新安装的mysql5.7,使用下面的命令生成临时密码
grep 'temporary password' /var/log/mysqld.log
use mysql;
会报错,所以需要修改临时的密码
a.修改mysql配置文件,使用空密码登录
cd /etc/my.cnf
在[mysqld]下添加
skip-grant-tables
保存,重启mysql
b.使用空密码登陆
mysql -uroot -p
直接回车登录
use mysql;
修改密码,mysql5.6版本以上需要使用下面的命令来修改密码
update user set authentication_string=password('123456') where user='root';
flush privileges;
再将mysql配置文件里面的skip-grant-tables注释掉,
重启mysql
c.使用新密码登录,
use mysql;
这一句还会报错,再执行
SET PASSWORD = PASSWORD('123456');
,什么原因不懂,抄的
d.修改mysql远程登录权限,这样我可以使用工具来操作数据库
use mysql;
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
重启mysql,这样可以远程访问了
mysql安装好了
参考众多大神文档,感恩
三、安装php5.6
同样的方法可以安装7.2,,因为都是同一个yum源
使用yum install php版本好像是5.1的?,吭
1、首先列出yum源自带php并删除
yum list installed | grep php
删除方法和删除自带的mysql一样,出来什么看到就删
2、添加php5.6的yum源
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm
这里也是要注意后面的数字,6的意思就是安装在centos6上面的,7的意思就是安装在centos7上面的,
上面mysql的吭踩过了,这里就不踩了
3、安装yum源配置工具
yum install yum-utils
4、配置要安装的版本,有三个选项
# yum-config-manager --enable remi-php55 [Install PHP 5.5]
# yum-config-manager --enable remi-php56 [Install PHP 5.6]
# yum-config-manager --enable remi-php72 [Install PHP 7.2]
我这里安装php5.6的,就使用
yum-config-manager --enable remi-php56
5、查看php56这个包里面有些什么模块,这里的名字是php56w,不是php5.6,也不是php56
yum list available "php56w-*"
出来了一些东西
php56w-bcmath.x86_64 5.6.37-1.w6 webtatic
php56w-cli.x86_64 5.6.37-1.w6 webtatic
php56w-common.x86_64 5.6.37-1.w6 webtatic
php56w-dba.x86_64 5.6.37-1.w6 webtatic
php56w-devel.x86_64 5.6.37-1.w6 webtatic
php56w-embedded.x86_64 5.6.37-1.w6 webtatic
php56w-enchant.x86_64 5.6.37-1.w6 webtatic
php56w-fpm.x86_64 5.6.37-1.w6 webtatic
php56w-gd.x86_64 5.6.37-1.w6 webtatic
php56w-imap.x86_64 5.6.37-1.w6 webtatic
php56w-interbase.x86_64 5.6.37-1.w6 webtatic
php56w-intl.x86_64 5.6.37-1.w6 webtatic
php56w-ldap.x86_64 5.6.37-1.w6 webtatic
php56w-mbstring.x86_64 5.6.37-1.w6 webtatic
php56w-mcrypt.x86_64 5.6.37-1.w6 webtatic
php56w-mssql.x86_64 5.6.37-1.w6 webtatic
php56w-mysql.x86_64 5.6.37-1.w6 webtatic
php56w-mysqlnd.x86_64 5.6.37-1.w6 webtatic
php56w-odbc.x86_64 5.6.37-1.w6 webtatic
php56w-opcache.x86_64 5.6.37-1.w6 webtatic
php56w-pdo.x86_64 5.6.37-1.w6 webtatic
php56w-pear.noarch 1:1.10.4-1.w6 webtatic
php56w-pecl-apcu.x86_64 4.0.11-2.w6 webtatic
php56w-pecl-apcu-devel.x86_64 4.0.11-2.w6 webtatic
php56w-pecl-gearman.x86_64 1.1.2-1.w6 webtatic
php56w-pecl-geoip.x86_64 1.1.1-1.w6 webtatic
php56w-pecl-igbinary.x86_64 2.0.5-1.w6 webtatic
php56w-pecl-igbinary-devel.x86_64 2.0.5-1.w6 webtatic
php56w-pecl-imagick.x86_64 3.4.3-1.w6 webtatic
php56w-pecl-imagick-devel.x86_64 3.4.3-1.w6 webtatic
php56w-pecl-memcache.x86_64 3.0.8-2.w6 webtatic
php56w-pecl-memcached.x86_64 2.2.0-2.w6 webtatic
php56w-pecl-mongodb.x86_64 1.4.1-1.w6 webtatic
php56w-pecl-redis.x86_64 3.1.6-1.w6 webtatic
php56w-pecl-xdebug.x86_64 2.5.5-2.w6 webtatic
php56w-pgsql.x86_64 5.6.37-1.w6 webtatic
php56w-phpdbg.x86_64 5.6.37-1.w6 webtatic
php56w-process.x86_64 5.6.37-1.w6 webtatic
php56w-pspell.x86_64 5.6.37-1.w6 webtatic
php56w-recode.x86_64 5.6.37-1.w6 webtatic
php56w-snmp.x86_64 5.6.37-1.w6 webtatic
php56w-soap.x86_64 5.6.37-1.w6 webtatic
php56w-tidy.x86_64 5.6.37-1.w6 webtatic
php56w-xml.x86_64 5.6.37-1.w6 webtatic
php56w-xmlrpc.x86_64 5.6.37-1.w6 webtatic
6、开始安装php5.6
yum install php56w
再安装php-fpm,用这个来启动安装好的php
yum install php-fpm
根据上面出现的模块,一个一个安装,一起安装我试过了,有些东西装不上,懒得管了,全部装上
yum install php56w-bcmat
yum install php56w-cli
yum install php56w-devel
yum install php56w-mbstring
yum install php56w-mssql
yum install php56w-pdo
yum install php56w-mysql
yum install php56w-mysqlnd
yum install php56w-...全部装上..
但是最后有几个报错
Error: Package: php56w-pecl-imagick-devel-3.4.3-1.w6.x86_64 (webtatic)
Requires: php56w-pecl-imagick = 3.4.3-1.w6
Available: php56w-pecl-imagick-3.4.3-1.w6.x86_64 (webtatic)
php56w-pecl-imagick = 3.4.3-1.w6
Error: Package: php56w-pecl-igbinary-devel-2.0.5-1.w6.x86_64 (webtatic)
Requires: php56w-pecl-igbinary(x86-64) = 2.0.5-1.w6
Available: php56w-pecl-igbinary-2.0.5-1.w6.x86_64 (webtatic)
php56w-pecl-igbinary(x86-64) = 2.0.5-1.w6
Error: Package: php56w-pecl-apcu-devel-4.0.11-2.w6.x86_64 (webtatic)
Requires: php56w-pecl-apcu = 4.0.11-2.w6
Available: php56w-pecl-apcu-4.0.11-2.w6.x86_64 (webtatic)
php56w-pecl-apcu = 4.0.11-2.w6
Error: Package: php56w-phpdbg-5.6.37-1.w6.x86_64 (webtatic)
Requires: php56w-common(x86-64) = 5.6.37-1.w6
Available: php56w-common-5.6.33-1.w6.x86_64 (webtatic)
php56w-common(x86-64) = 5.6.33-1.w6
Available: php56w-common-5.6.34-1.w6.x86_64 (webtatic)
php56w-common(x86-64) = 5.6.34-1.w6
Available: php56w-common-5.6.35-1.w6.x86_64 (webtatic)
php56w-common(x86-64) = 5.6.35-1.w6
Available: php56w-common-5.6.36-1.w6.x86_64 (webtatic)
php56w-common(x86-64) = 5.6.36-1.w6
Available: php56w-common-5.6.37-1.w6.x86_64 (webtatic)
php56w-common(x86-64) = 5.6.37-1.w6
Error: Package: php56w-pecl-imagick-devel-3.4.3-1.w6.x86_64 (webtatic)
Requires: php56w-devel
Available: php56w-devel-5.6.33-1.w6.x86_64 (webtatic)
php56w-devel = 5.6.33-1.w6
Available: php56w-devel-5.6.34-1.w6.x86_64 (webtatic)
php56w-devel = 5.6.34-1.w6
Available: php56w-devel-5.6.35-1.w6.x86_64 (webtatic)
php56w-devel = 5.6.35-1.w6
Available: php56w-devel-5.6.36-1.w6.x86_64 (webtatic)
php56w-devel = 5.6.36-1.w6
Available: php56w-devel-5.6.37-1.w6.x86_64 (webtatic)
php56w-devel = 5.6.37-1.w6
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
不知道什么原因,后来发现不影响php的使用,就先不管了
7、安装好了之后查看 php版本
php -v
查看安装了哪些模块
php -m
这样php5.6就安装好了,呵呵,三分钟写完,又装了不止三个小时,幸好翻了墙~
四、整合nginx和php5.6
安装的时候默认用户和用户组全是root,改成前面的nginx
修改所有者
chown -R nginx /usr/local/nginx
修改用户组
chgrp -R nginx /usr/local/nginx
1、找到nginx的配置文件
/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 kor-i;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#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 wxcard.qlm.im;
# ssl on;
# ssl_certificate /usr/local/nginx/cert/1_wxcard.qlm.im_bundle.crt;
# ssl_certificate_key /usr/local/nginx/cert/2_wxcard.qlm.im.key;
# root html;
# index index.html index.htm index.php;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm index.php;
# }
# }
}
第一行的#user nobody注释去掉,改成
user nginx;但是改成user root好像也可以
将 #charset kor-i;注释去掉,改为
charset utf-8; 解决中文乱码问题
location / {
root html
index index.php index.html index.htm;
}
这个里面把 index index.html index.htm 改为 index index.html index.htm index.php
加上一个 index.php
配置的时候注意大括号和任何内容之间要有空隔,或者换行,不然解析会出错,nginx不能启动了
接着将server下面的这段去掉注释
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;
}
把 /scripts/改成 $document_root,像这样
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
这样nginx就能解析 .php文件了,如果这段注释没有去掉,访问php文件会提示下载,或者直接下载下来,...
这样就算配置好了,但是我发现访问php文件的时候会提示没有权限,报一个错误
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0
这个意思是说 /var/lib/php/session 没有权限,导致php文件还是不能被解析,所以添加权限,修改所有者和用户组为 nginx,然后将/var/lib/php 权限改为 777
chown -R nginx /var/lib/ph
chgrp -R nginx /var/lib/php
chmod -R 777 /var/lib/php
这样就可以正常访问和解析php了,配置结束了,写个 test.php
<?php
phpinfo();
?>
访问 x.x.x.x/test.php x.x.x.x是你的服务器ip,如果正常显示说明成功了,如果不行,说明还有哪个环节出错了
接下来是nginx配置域名和SSL的问题
我的nginx的默认web根目录是在 /usr/local/nginx/html下面的
如果是配置普通的http站点,可以这么配
server {
listen 80;
server_name localhost;
charset utf-8;
location / {
root html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
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;
}
}
每 一对 server大括号都代表了一个子站点,可以把里面的root html 改为 root html/aaa或者html/bbb,
把server_name localhost改为 server_name www.xxx.com
如果有很多子站点,全部配置在 nginx.conf里面会显得很臃肿,可以为每个子站点写一个conf文件
比如 在 /usr/local/nginx/conf 下面新建一个vhosts文件夹现在要配置A站点和B站点,
那么可以写一个a.conf和b.conf,每个conf里面的内容
server {
listen 80;
server_name localhost;//修改为你的域名
charset utf-8;
location / {
root html;//修改为你的路径
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
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;
}
}
然后在 nginx.conf文件下面使用 include,include语句要写在 http{}大括号里面,不要写在其他的括号里面,不然不生效
http {
.
.
.
gzip on;
.
include /usr/local/nginx/conf/vhosts/a.conf;
include /usr/local/nginx/conf/vhosts/b.conf;
.
.
server {
}
}
这样就很好看,多站点就是这样配置,
如果是配置SSL,先去申请收费或免费的SSL证书,顺便说一句,阿里云的免费证书申请非常快,几分钟就下来
不像某个北极动物,两三天没反应,吭
证书下来后,在 nginx 文件夹下新建cert文件夹,将证书放在这个文件夹下,然后只需这样配置
server{
listen 443 ssl;
server_name www.xxx.com;
ssl on;
ssl_certificate /usr/local/nginx/cert/xxx.crt; //证书位置
ssl_certificate_key /usr/local/nginx/cert/xxx.key; //key文件位置
root html;
index index.html index.htm index.php;
# ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.php index.htm;
}
}
这样完成了SSL的配置,但是如果是配置多域名(也就是多站点),每个域名都要配置SSL,这个就没研究了,好像是nginx还需要装一个插件 tls 才行
如果已经安装好了nginx,但是没有开启http_ssl_model模块,那么需要为nginx加上ssl模块:
参考大神原贴,讲的非常详细
https://www.cnblogs.com/ghjbk/p/6744131.html
nginx和php就这样整合完成了,三分钟写完,又搞了不止三个小时
五、整合php5.6和mysql5.7,就是将php5.6和mysql5.7连接起来
1、查看mysql.sock的位置,后面要用到
[root@iZe4v ~]# find / -name "mysql.sock"
/var/lib/mysql/mysql.sock
2、查看php.ini的位置
whereis php.ini
vim /etc/php.ini
3、编辑配置文件
php.ini里面有这么一段,vim打开后可以使用
/mysql来找到这么一段
[Pdo_mysql]
; If mysqlnd is used: Number of cache slots for the internal result set cache
; http://php.net/pdo_mysql.cache_size
pdo_mysql.cache_size = 2000
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
这个 pdo_mysql.default_socket 的值就是刚才找到的 mysql.sock 的位置
这样php就和mysql连接在一起了,写一个 test.php
<?php
$mysql_server = "localhost";
$mysql_username = "root";
$mysql_password = "123456";
$mysql_database="test";
$conn = mysql_connect($mysql_server,$mysql_username,$mysql_password) or die("conn fail");
?>
运行后如果什么都没有,说明成功了,
php和mysql就整合完成,感觉有点累