nginx与mysql安装
Posted 代码家园
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx与mysql安装相关的知识,希望对你有一定的参考价值。
yum install -y wget vim gcc-c++ bash-completion
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar xf nginx-1.14.0.tar.gz -C /root
cd /root/nginx-1.14.0
useradd -s /sbin/nologin nginx
yum -y install gcc pcre-devel openssl-devel
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-stream --with-http_v2_module --with-http_gzip_static_module --with-http_gunzip_module --with-stream_ssl_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module
BT
--user=nginx --group=nginx --prefix=/www/server/nginx --with-openssl=/www/server/nginx/src/openssl --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --add-module=/www/server/nginx/src/nginx-http-concat --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-stream --with-stream_ssl_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-ld-opt=-Wl,-E --with-ld-opt=-ljemalloc
make && make install
pkill httpd
ln -s /usr/local/nginx/sbin/nginx /sbin/
nginx
nginx -s reload
firewall-cmd --zone=public --add-port=80/tcp --permanent
------------------------------------------------------------------
server {
listen 80; //端口
server_name www.b.com; //域名
charset utf-8; //支持所有编码utf-8 万国编码
location / {
root www; //指定网站根路径
index index.html index.htm;
}
}
-----------------------------------------------------------------反向代理
http {
.. ..
upstream webserver { //定义集群 //注意位置 upstream 定义服务器名字 webserver 集群服务器名字
server 192.168.2.100:80; //集群的第一台机
server 192.168.2.200:80; //集群的第二台机
}
.. ..
server {
listen 80; //监听80端口
server_name localhost; //定义域名
location / {
proxy_pass http://webserver; //跳转到webserver
root html; //可有可无
index index.html index.htm; //可有可无
}
}
-----------------------------------------------------------------百度跳转
server {
listen 80;
server_name 88.88.218.1;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://www.baidu.com;
root html;
index index.html index.htm;
}
-----------------------------------------------------------------
/usr/local/nginx/conf/proxy.conf
echo `curl http://www.baidu.com` > /usr/local/nginx/html/index.html
#############################################################################################################################mysql5.7安装
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
yum -y install mysql57-community-release-el7-8.noarch.rpm
yum -y install mysql-server
systemctl start mysqld
systemctl enable mysqld #设置开机自动启动
ps -C mysqld #检查是否有进程
netstat -utnlp | grep mysqld #看服务端口是否启动
grep password /var/log/mysqld.log #查询初始化密码C8&rp/gN#ijd
mysql -hlocalhost -uroot -p‘系统产生的随机密码‘
mysql>set global validate_password_policy=0; 只检查密码的长度
mysql>set global validate_password_length=6; 密码长度不能小于6个
mysql>alter user [email protected]"localhost" identified by "weilai"; #用于改密码
mysql>alter user [email protected]"localhost" identified by "Hdug&34dg1Gd";
]#vim /etc/my.cnf
[mysqld]#这个不放进去,以下如果不放,你用简短密码后期还是无法登陆,长密码无所谓
validate_password_policy=0
validate_password_length=6
lower_case_table_names=1 //忽略大小写
:wq
]#systemctl restart mysqld
//防火墙配置
[[email protected] ~]# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT //centOS6 版本的端口放行
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcp
success
mysql> grant all on *.* to [email protected]"%" identified by "Hdug&34dg1Gd";
select user,host,authentication_string from mysql.user; //查看授权列表
drop user ‘root‘@‘192.168.12.1‘; //删除用户授权
以上是关于nginx与mysql安装的主要内容,如果未能解决你的问题,请参考以下文章
CentOS6.3上安装与配置nginx+php+mysql环境
Ubuntu 16.04 LTS 安装 Nginx/PHP 5.6/MySQL 5.7 (LNMP) 与Laravel
PHP安装 (结合之前的nginx安装与mysql安装组合为lnmp)