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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

编译安装openresty+mysql+php7

發(fā)布時間:2024/9/20 数据库 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 编译安装openresty+mysql+php7 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.準(zhǔn)備

1.更新系統(tǒng)

yum makecache && yum -y update
  • 1
  • 1

2.安裝常用基礎(chǔ)軟件

yum -y install bash-completion vim net-tools bind-utils wget screen
  • 1
  • 1

最后別忘了重啟

3.需要下載的源碼

1.openresty

wget https://openresty.org/download/ngx_openresty-1.9.7.1.tar.gz
  • 1
  • 1

2.mariaDB

wget http://sfo1.mirrors.digitalocean.com/mariadb/mariadb-5.5.47/source/mariadb-5.5.47.tar.gz
  • 1
  • 1

3.php7

wget -c --no-check-certificate -O php7-src-master.zip https://github.com/php/php-src/archive/master.zip
  • 1
  • 1

2.openresty

1.依賴關(guān)系

openresty依賴于perl 5.6.1+, libreadline, libpcre, libssl,首先安裝依賴關(guān)系。

yum install readline-devel pcre-devel openssl-devel gcc
  • 1
  • 1

2.下載源碼

使用wget下載

wget https://openresty.org/download/ngx_openresty-1.9.7.1.tar.gz
  • 1
  • 1

博主安裝時最新版為1.9.7.1,可以登錄http://openresty.org查看最新版本,選擇需要的版本進(jìn)行下載。

解壓下載好的壓縮包

tar xzvf ngx_openresty-1.9.7.1.tar.gz
  • 1
  • 1

注意將1.9.7.1替換為你下載的版本號

3. ./configure

進(jìn)入 ngx_openresty-VERSION/ 目錄, 然后輸入以下命令配置:

./configure
  • 1
  • 1

默認(rèn), –prefix=/usr/local/openresty 程序會被安裝到/usr/local/openresty目錄。?
我們可以指定各種選項,比如

./configure --prefix=/opt/openresty \--with-luajit \ --without-http_redis2_module \ --with-http_iconv_module \ --with-http_postgres_module
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

具體用法參考./configure –help 或者官方文檔

4.編譯、安裝

使用make編譯

make
  • 1
  • 1

安裝

make install
  • 1
  • 1

5.將nginx添加到系統(tǒng)變量

PATH=/usr/local/openresty/nginx/sbin:$PATH export PATH
  • 1
  • 2
  • 1
  • 2

6.默認(rèn)項目路徑

/usr/local/openresty/nginx/html
  • 1
  • 1

7.啟動、關(guān)閉、重啟nginx

nginx -c /usr/local/openresty/nginx/conf/nginx.conf //啟動并加載配置文件 nginx -s stop //停止 nginx -s reload //重啟
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

3.mariaDB

1.安裝依賴庫、編譯工具

yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl cmake compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* zlib-devel gd-devel
  • 1
  • 1

2.創(chuàng)建數(shù)據(jù)庫文件夾,用戶組

groupadd mysql && useradd -g mysql mysql -s /bin/false && mkdir -p /data/mysql && chown -R mysql:mysql /data/mysql && mkdir -p /usr/local/mysql
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

3.下載mariaDB 5.5.47

wget http://sfo1.mirrors.digitalocean.com/mariadb/mariadb-5.5.47/source/mariadb-5.5.47.tar.gz
  • 1
  • 1

解壓

tar zxf mariadb-5.5.47.tar.gz
  • 1
  • 1

進(jìn)入目錄

cd mariadb-5.5.47
  • 1
  • 1

4.編譯、安裝mariaDB

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc && make && make install
  • 1
  • 2
  • 1
  • 2

check完之后沒什么事可以去喝個茶,博主低配云主機(jī)編譯了大概12分鐘

5.刪除系統(tǒng)自帶的mariaDB配置文件

mv /etc/my.cnf /etc/my.cnf.bak
  • 1
  • 1

6.初始化數(shù)據(jù)庫,配置啟動腳本

cd /usr/local/mysql && ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql && ln -s /usr/local/mysql/my.cnf /etc/my.cnf && cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld && chmod 755 /etc/init.d/mysqld && chkconfig mysqld on
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

7.配置mariaDB啟動腳本

vim /etc/rc.d/init.d/mysqld
  • 1
  • 1

改動如下:

basedir=/usr/local/mysql #MySQL程序安裝路徑 datadir=/data/mysql #MySQl數(shù)據(jù)庫存放目
  • 1
  • 2
  • 1
  • 2

然后重啟mariaDB

service mysqld restart
  • 1
  • 1

8.將mariaDB加入系統(tǒng)環(huán)境變量

echo 'export PATH=$PATH:/usr/local/mysql/bin'>>/etc/profile && source /etc/profile
  • 1
  • 1

9.把MariaDB的庫文件鏈接到系統(tǒng)默認(rèn)的位置,在編譯PHP等軟件時可以不用指定其庫文件地址

ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql && ln -s /usr/local/mysql/include/mysql /usr/include/mysql && mkdir /var/lib/mysql && ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

10.設(shè)置root賬戶mariaDB密碼

mysql_secure_installation
  • 1
  • 1

接下來屏幕會出現(xiàn)一系列代碼,代碼及操作記錄如下

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not foundNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we’ll need the current password for the root user. If you’ve just installed MariaDB, and you haven’t set the root password yet, the password will be blank, so you should just press enter here.Enter current password for root (enter for none):<– 回車 OK, successfully used password, moving onSetting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.Set root password? [Y/n] <– y 回車 New password: <– 設(shè)置用戶名為root的mysql密碼 Re-enter new password: <– 密碼確認(rèn) Password updated successfully! Reloading privilege tables.. … Success!By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.Remove anonymous users? [Y/n] <– y 回車 … Success!Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] <– y 回車 … Success!By default, MariaDB comes with a database named ‘test’ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.Remove test database and access to it? [Y/n] <– y 回車 - Dropping test database… … Success! - Removing privileges on test database … Success!Reloading the privilege tables will ensure that all changes made so far will take effect immediately.Reload privilege tables now? [Y/n] <– y 回車 … Success!Cleaning up…All done! If you’ve completed all of the above steps, your MariaDB installation should now be secure.Thanks for using MariaDB!
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60

至此,mariaDB設(shè)置完畢

4.php7

1.下載php7

wget -c --no-check-certificate -O php7-src-master.zip https://github.com/php/php-src/archive/master.zip
  • 1
  • 1

解壓

unzip -q php7-src-master.zip
  • 1
  • 1

進(jìn)入目錄

cd php-src-master
  • 1
  • 1

2.安裝依賴包

yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
  • 1
  • 1

3.編譯、安裝

./buildconf
  • 1
  • 1

此時會生成configure文件,然后

export LD_LIBRARY_PATH=/usr/local/libgd/lib && ./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-mysql=/usr/local/mysql \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-mysql-sock=/tmp/mysql.sock \ --with-pdo-mysql=/usr/local/mysql \ --with-gd \ --with-png-dir=/usr/local/libpng \ --with-jpeg-dir=/usr/local/jpeg \ --with-freetype-dir=/usr/local/freetype \ --with-xpm-dir=/usr/ \ --with-vpx-dir=/usr/local/libvpx/ \ --with-zlib-dir=/usr/local/zlib \ --with-t1lib=/usr/local/t1lib \ --with-iconv \ --enable-libxml \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --enable-opcache \ --enable-mbregex \ --enable-fpm \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --with-openssl \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-mcrypt \ --with-curl \ --enable-exif \ --enable-ctype && make && make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

在check完之后沒什么事再去喝個茶吧,博主大概也用了12分鐘?

安裝完成后提示信息

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: phpizeprogram: php-config Installing man pages: /usr/local/php/php/man/man1/page: phpize.1page: php-config.1 /root/down/php-src-master/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/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

恭喜你,成功了

4.復(fù)制php配置文件到安裝目錄:

cp php.ini-production /usr/local/php/etc/php.ini
  • 1
  • 1

5.備份系統(tǒng)自帶配置文件:

mv /etc/php.ini /etc/php.ini.bak
  • 1
  • 1

6.添加軟鏈接到 /etc目錄:

ln -s /usr/local/php/etc/php.ini /etc/php.ini
  • 1
  • 1

7.拷貝模板文件為php-fpm配置文件:

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
  • 1
  • 1

8.添加軟連接到 /etc目錄:

ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf
  • 1
  • 1

#####4-8合并操作
cp php.ini-production /usr/local/php/etc/php.ini && mv /etc/php.ini /etc/php.ini.bak && ln -s /usr/local/php/etc/php.ini /etc/php.ini && cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf && ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

9.修改php配置文件

vim /usr/local/php/etc/php.ini
  • 1
  • 1

1.將disable_functions =?(禁用掉某些比較“危險”函數(shù),大概在298行),改為

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
  • 1
  • 1

2.將expose_php = On(禁止顯示php版本的信息,大概在359行),修改為

expose_php = Off
  • 1
  • 1

3.將;date.timezone =(大概在912行),修改為

date.timezone = Asia/Shanghai
  • 1
  • 1

4.將

;short_open_tag; Default Value: On; Development Value: Off; Production Value: Off
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

(支持PHP短標(biāo)簽,大概在151行),修改為


short_open_tag?
Default Value: On?
Development Value: Off?
Production Value: Off?

5.將?;opcache.enable=0?(支持opcode緩存,大概在1732行),修改為

opcache.enable=1
  • 1
  • 1

6.將;opcache.enable_cli=0(支持opcode緩存,大概在1735行),修改為

opcache.enable_cli=1
  • 1
  • 1

然后配置opcode緩存,取消以下配置項的注釋(從1732行向下)

opcache.memory_consumption=64 opcache.interned_strings_buffer=4 opcache.max_accelerated_files=2000 opcache.revalidate_freq=2 opcache.fast_shutdown=1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

10.修改php-fpm配置項

vim /usr/local/php/etc/php-fpm.conf
  • 1
  • 1

取消注釋

pid = run/php-fpm.pid
  • 1
  • 1

新增

user = www group = www
  • 1
  • 2
  • 1
  • 2

11.拷貝php-fpm腳本到啟動目錄,給予執(zhí)行權(quán)限, 設(shè)置開機(jī)啟動

cp /usr/local/src/php-7.1.0/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm && chmod +x /etc/rc.d/init.d/php-fpm && chkconfig php-fpm on
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

12.配置nginx支持php

location ~ \.php\$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/openresty/nginx/html$fastcgi_script_name; include fastcgi_params; }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

5.配置匯總

根目錄: /usr/local/openresty/nginx/html/?
Nginx配置文件: /usr/local/openresty/nginx/conf/nginx.conf?
php配置文件: /usr/local/php/etc/php.ini?
PHP默認(rèn)拓展文件夾:/usr/lib64/php/modules/?
PHP拓展可放置于:/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012?
MySQL配置文件: /etc/my.cnf?
mysql程序安裝路徑: basedir=/usr/local/mysql?
MySQl數(shù)據(jù)庫存放目錄: datadir=/data/mysql


來源:http://blog.csdn.net/leiflyy/article/details/50497931

總結(jié)

以上是生活随笔為你收集整理的编译安装openresty+mysql+php7的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。