日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Centos7+nginx1.12+mysql5.7+php7环境安装

發布時間:2024/9/30 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Centos7+nginx1.12+mysql5.7+php7环境安装 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.?下載nginx:http://nginx.org/en/download.html

?

?

2.?usr/local文件夾中新建一個lnmp的文件夾,下載nginx壓縮包并解壓

[root@VM_48_141_centos ~]# cd usr/local

[root@VM_48_141_centos local]# mkdir lnmp

[root@VM_48_141_centos local]# cd lnmp

[root@VM_48_141_centos lnmp]# wget http://nginx.org/download/nginx-1.12.2.tar.gz

?

?[root@VM_48_141_centos nginx-1.12.2]# ./configure --prefix=/usr/local/lnmp/nginx

出錯

?

?

原因:沒有gcc的編譯庫

解決辦法:[root@VM_48_141_centos nginx-1.12.2]# yum install gcc gcc-c++ kernel-devel

?

繼續,又出錯

?

原因:沒有正則庫

?

解決辦法:[root@VM_48_141_centos nginx-1.12.2]# yum install pcre-devel

?

繼續,又出錯

?

原因:沒有zlib

?

解決辦法:?[root@VM_48_141_centos nginx-1.12.2]# yum install -y zlib-devel

?

?

繼續,OK

?

?

3.編譯并安裝 [root@VM_48_141_centos nginx-1.12.2]# make && make install

?

?

?

4啟動nginx

[root@VM_48_141_centos lnmp]# cd Nginx

進入剛才自定義的安裝目錄Nginx 4個文件愛夾

conf:配置文件 ??html:網頁文件 ????logs:日志文件 ???sbin:主要進程文件

[root@VM_48_141_centos Nginx]# ./sbin/nginx

?

?

在瀏覽器中訪問:

?

?

?

關閉Nginx[root@VM_48_141_centos Nginx]# kill -INT 28024

查看nginx主進程號:[root@VM_48_141_centos Nginx]# ps aux|grep nginx

?

中間用到的命令

grep 'nginx' /etc/group

awk -F":" '{print $1"\t\t"$4}' /etc/passwd | grep '1000'

Nginx.Conf

?

?

#user ?nobody;

//全局區

work_processes 1 ; ??//有一個工作的子進程,可以自行修改,但太大無益,因為要爭奪CPU,一般設置為CPU*核數

?

#error_log ?logs/error.log;

#error_log ?logs/error.log ?notice;

#error_log ?logs/error.log ?info;

?

#pid ???????logs/nginx.pid;

?

?

events {

//一般是配置nginx連接的特性

//如一個word能同時允許多少連接

????worker_connections ?1024; ??//這里指一個子進程最大允許1024個連接

}

?

?

http { ?//這是配置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 ?ab.html 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 ?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;

????# ???}

????#}

?

}

?

?

?

?

?

二.?安裝mysql

[root@VM_48_141_centos logs]# yum -y install mysql-server mysql mysql-devel

?

然后花了一下午在改mysql,裝的不是mysql,而是mariadb

?

1.卸載:yum autoremove ?mysql -y


?

2.wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

?

?

3.yum localinstall mysql57-community-release-el7-11.noarch.rpm

?

?4.yum repolist enabled | grep "mysql.*-community.*"

?

5.yum install mysql-community-server -y

?

6. 啟動mysql并查看其狀態

命令:systemctl start mysqld

命令:systemctl status mysqld

?

7. 設置mysql為系統服務,隨系統啟動而啟動

命令:systemctl enable mysqld

命令:systemctl daemon-reload

?

8. 查看mysqlroot賬號的默認密碼

mysql5.7安裝完成之后,在/var/log/mysqld.log文件中給root生成了一個默認密碼。通過下面的方式找到root默認密碼,然后登錄mysql

命令:grep 'temporary password' /var/log/mysqld.log

其中Jb2h<%lp9itY部分就是默認密碼

9.2. 修改my.cnf文件(/etc/my.cnf)

9.2.1. 修改密碼策略

mysql的密碼策略分為三種:

0LOWLength

1MEDIUMLength; numeric, lowercase/uppercase, and special characters

2STRONGLength; numeric, lowercase/uppercase, and special characters; dictionary file

?

在mysql的配置文件my.cnf文件中增加如下設置

#如果不需要密碼策略,禁用密碼策略
validate_password = off

# 密碼選擇策略 0-LOW1-MEDIUM2-STRONG需要提供密碼字典文件
validate_password_policy = 0

9.2.2. 修改字符編碼為utf8

在my.cnf中的[mysqld]下增加如下配置

character_set_server = utf8
init_connect = 'SET NAMES utf8'

命令:systemctl restart mysqld

10. 登錄mysql

命令:mysql -uroot -p

輸入密碼:默認為剛才查到的Jb2h<%lp9itY

11. 修改密碼

命令:ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
或命令:set password for 'root'@'localhost'=password('12345678');

12. 添加遠程賬戶

命令:GRANT ALL PRIVILEGES ON *.* TO 'remote'@'%' IDENTIFIED BY '12345678' WITH GRANT OPTION;

命令:FLUSH PRIVILEGES; 使設置生效

?

?

?

三.安裝PHP

1.?下載地址:http://cn2.php.net/distributions/php-7.1.11.tar.gz

?

?

?

?

?

wget http://cn2.php.net/distributions/php-7.1.11.tar.gz

tar -zxvf php-7.1.11.tar.gz

?

?

..安裝php依賴包 

?yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

?

./configure --prefix=/usr/local/lnmp/PHP ?\--with-config-file-path=/etc \--enable-fpm \--with-fpm-user=nginx ?\--with-fpm-group=nginx \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared ?\--enable-soap \--with-libxml-dir \--with-xmlrpc \--with-openssl \--with-mcrypt \--with-mhash \--with-pcre-regex \--with-sqlite3 \--with-zlib \--enable-bcmath \--with-iconv \--with-bz2 \--enable-calendar \--with-curl \--with-cdb \--enable-dom \--enable-exif \--enable-fileinfo \--enable-filter \--with-pcre-dir \--enable-ftp \--with-gd \--with-openssl-dir \--with-jpeg-dir \--with-png-dir \--with-zlib-dir ?\--with-freetype-dir \--enable-gd-native-ttf \--enable-gd-jis-conv \--with-gettext \--with-gmp \--with-mhash \--enable-json \--enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--with-libmbfl \--with-onig \--enable-pdo \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-zlib-dir \--with-pdo-sqlite \--with-readline \--enable-session \--enable-shmop \--enable-simplexml \--enable-sockets ?\--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-wddx \--with-libxml-dir \--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear \--enable-opcache

?

?

?

?

.編譯與安裝

# make && make install

這里要make好久,要耐心一下

?.添加 PHP命令到環境變量

# vim /etc/profile

在末尾加入

PATH=$PATH:/usr/local/php/bin

export PATH

要使改動立即生效執行

# source /etc/profile

查看環境變量

# echo $PATH

查看php版本

# php -v

配置php-fpm

# cp php.ini-production /etc/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 sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

# chmod +x /etc/init.d/php-fpm

啟動php-fpm

# /etc/init.d/php-fpm start

?

.重啟nginx

# service nginx reload

<?php

phpinfo();

可以查看到如下信息

?

?

?

總結

以上是生活随笔為你收集整理的Centos7+nginx1.12+mysql5.7+php7环境安装的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。