您好,登錄后才能下訂單哦!
php mysql源碼安裝是怎樣的,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
php mysql源碼安裝的方法:1、通過yum安裝依賴包并編譯安裝mysql源碼;2、通過“yum install”命令安裝PHP源碼并修改配置;3、安裝nginx源碼并測試安裝結果即可。
本文操作環境:redhat6.5系統、PHP5.6、Dell G3電腦。
php mysql源碼安裝教程
mysql和php的源碼編譯安裝
yum install cmake-2.8.12.2-4.el6.x86_64.rpm gcc-c++ ncurses-devel gcc -y
[root@server2 ~]# lsanaconda-ks.cfg haproxy-1.6.11.tar.gz lamp nginx drbd-8.4.3 heartbeat-3.0.4-2.el6.x86_64.rpm mysql-5.7.11 php-5.6.20.tar.bz2 drbd-8.4.3.tar.gz heartbeat-libs-3.0.4-2.el6.x86_64.rpm mysql-boost-5.7.11.tar.gz rpmbuild [root@server2 ~]# tar zxf mysql-boost-5.7.11.tar.gz [root@server2 ~]# cd mysql-5.7.11/
編譯參數:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #安裝目錄 -DMYSQL_DATADIR=/usr/local/mysql/data \#數據庫存放目錄 -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \ #Unix socket 文件路徑-DWITH_MYISAM_STORAGE_ENGINE=1 \#安裝 myisam 存儲引擎 -DWITH_INNOBASE_STORAGE_ENGINE=1 \#安裝 innodb 存儲引擎 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \#安裝 archive 存儲引擎 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \#安裝 blackhole 存儲引擎 -DWITH_PARTITION_STORAGE_ENGINE=1 \#安裝數據庫分區 -DENABLED_LOCAL_INFILE=1 \#允許從本地導入數據 -DWITH_READLINE=1 \#快捷鍵功能 -DWITH_SSL=yes \#支持 SSL -DDEFAULT_CHARSET=utf8 \#使用 utf8 字符 -DDEFAULT_COLLATION=utf8_general_ci \#校驗字符 -DEXTRA_CHARSETS=all \#安裝所有擴展字符集 -DMYSQL_TCP_PORT=3306 \#MySQL 監聽端口
[root@server2mysql-5.7.11]#cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_ARCHIVE_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DENABLED_LOCAL_INFILE=1 \-DWITH_READLINE=1 -DWITH_SSL=yes \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=all -DMYSQL_TCP_PORT=3306 \-DWITH_BOOST=boost/boost_1_59_0/[root@server2mysql-5.7.11]make [root@server2mysql-5.7.11]make install
[root@server1 support-files]# cp /etc/my.cnf /etc/my.cnf.bak #備份[root@server1 support-files]# cp my-default.cnf /etc/my.cnf #創建新的my.cnf文件[root@server1 support-files]# vim /etc/my.cnf 18 basedir = /usr/local/lnmp/mysql 19 datadir = /usr/local/lnmp/mysql/data 20 port = 3306 21 # server_id = ..... 22 socket = /usr/local/lnmp/mysql/data/mysql.sock [root@server1 support-files]# cp mysql.server /etc/init.d/mysqld #將腳本復制到啟動腳本目錄下[root@server1 mysql]# chmod +x /etc/init.d/mysqld #給與腳本執行權限[root@server1 mysql]# groupadd -g 27 mysql #創建mysql組[root@server1 mysql]# useradd -M -s /sbin/nologin -d /usr/local/lnmp/mysql/data -u 27 mysql -g mysql #創建mysql用戶[root@server1 mysql]# chown mysql:mysql -R . #更改目錄下的所有文件所有者為nysql[root@server1 mysql]# mysqld --verbose --help | grep 'insecure' #過濾初始化需要用到的參數 --initialize-insecure insecure transport will be rejected. Secure transports initialize-insecure FALSE [root@server1 mysql]# mysqld --initialize-insecure --user=mysql2017-09-26T03:54:01.520645Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2017-09-26T03:54:01.521056Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_pISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.2017-09-26T03:54:01.521075Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.2017-09-26T03:54:01.528325Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. #報錯data目錄下有數據2017-09-26T03:54:01.529162Z 0 [ERROR] Aborting [root@server1 mysql]# cd data/[root@server1 data]# lsauto.cnf client-cert.pem ibdata1 ibtmp1 mysql.sock private_key.pem server1.pid sys ca-key.pem client-key.pem ib_logfile0 mysql mysql.sock.lock public_key.pem server-cert.pem ca.pem ib_buffer_pool ib_logfile1 mysqld_safe.pid performance_schema server1.err server-key.pem [root@server1 data]# rm -fr * #刪除data下數據[root@server1 mysql]# mysqld --initialize-insecure --user=mysql #初始化數據庫[root@server1 data]# vim ~/.bash_profile #給數據庫添加環境變量 8 # User specific environment and startup programs 9 10 PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin [root@server1 data]# /etc/init.d/mysqld start #啟動數據庫Starting MySQL. SUCCESS! [root@server1 data]# mysql_secure_installation #第一次進入數據庫的安全工作,設定mysql密碼,匿名用戶登陸。。。等等的設定[root@server2 data]# mysql[root@server2 data]# chown root:root data/ -R #為了安全經mysql數據目錄權限給root用戶Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2Server version: 5.7.11 Source distribution 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.00 sec) mysql> quit
注意:如發現以下錯誤是因為mysql沒有進行初始化的結果,mysqld –initialize-insecure –user=mysql 之后重新啟動數據庫就沒有這樣的問題了。
[root@server2 bin]# /etc/init.d/mysqld startStarting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data//server2.pid).
yum install libxml2-devel -yyum reinstall libcurl -yyum install libcurl-devel.x86_64 -ylibjpeg-turbo-devel-1.2.1-1.el6.x86_64 -yyum install gd-devel-2.0.35-11.el6.x86_64.rpm -yyum install gmp-devel -yyum install libmcrypt-2.5.8-9.el6.x86_64.rpm -yyum install libmcrypt-devel-2.5.8-9.el6.x86_64.rpm -yyum install net-snmp-devel -yyum install re2c-0.13.5-1.el6.x86_64.rpm -y
編譯安裝
root@server1 lamp]# tar jxf php-5.6.20.tar.bz2 [root@server1 php-5.6.20]# ./configure \ --prefix=/usr/local/lnmp/php \--with-config-file-path=/usr/local/lnmp/php/etc \--with-mysql=mysqlnd \--with-openssl \--with-snmp \--with-gd \--with-zlib \--with-curl \--with-libxml-dir \--with-png-dir \--with-jpeg-dir \--with-freetype-dir \--with-pear \--with-gettext \--with-gmp \--enable-inline-optimization \--enable-soap \--enable-ftp \--enable-sockets \--enable-mbstring \--with-mysqli=mysqlnd \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--with-mcrypt \--with-mhash[root@server1 php-5.6.20]# useradd -M -s /sbin/nologin -d /usr/local/lnmp/mysql/ -u 1500 nginx [root@server1 php-5.6.20]# make && make install
[root@server1 php-5.6.20]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini[root@server1 php-5.6.20]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm [root@server1 php-5.6.20]# chmod +x /etc/init.d/php-fpm [root@server1 php-5.6.20]# cd /usr/local/lnmp/php/[root@server1 php]# lsbin etc include lib php sbin var [root@server1 php]# vim etc/php.ini 923 ; Defines the default timezone used by the date functions 924 ; http://php.net/date.timezone 925 date.timezone = Asia/Shanghai #時區 926 [root@server1 etc]# vim php-fpm.conf 24 ; Default Value: none 25 pid = run/php-fpm.pid #開啟pid 26 [root@server1 etc]# vim php.ini 1000 ; http://php.net/pdo_mysql.default-socket1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock ...1149 ; http://php.net/mysql.default-socket1150 mysql.default_socket =/usr/local/lnmp/mysql/data/mysql.sock ...1209 mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock1210 [root@server1 etc]# /etc/init.d/php-fpm startStarting php-fpm done
nginx源碼安裝
[root@server1 ~]# cd nginx-1.12.0[root@server1 nginx-1.12.0]# lsauto CHANGES.ru configure html Makefile objs src CHANGES conf contrib LICENSE man README [root@server1 nginx-1.12.0]# ./configure --prefix=/usr/local/lnmp/nginx \--with-threads \ --with-http_ssl_module \ --with-file-aio \ --with-http_stub_status_module [root@server1 nginx-1.12.0]# make && make install[root@server1 nginx-1.12.0]# ln -s /usr/local/lnmp/nginx/sbin/nginx /usr/local/sbin/[root@server1 nginx-1.12.0]# vim /usr/local/lnmp/nginx/conf/nginx.conf 42 location / { 43 root html; 44 index index.php index.html index.htm; 45 } #添加php的發布頁面 64 location ~ \.php$ { 65 root html; 66 fastcgi_pass 127.0.0.1:9000; 67 fastcgi_index index.php; 68 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 69 include fastcgi.conf; #修改成這個 70 } [root@server1 html]# cat index.php #php發布頁面<?php phpinfo() ?> [root@server1 html]# nginx -s reload[root@server1 html]# /etc/init.d/php-fpm reloadReload service php-fpm done
測試:
瀏覽器中172.25.32.1
看完上述內容,你們掌握php mysql源碼安裝是怎樣的的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。