摘要:和的問題連接數(shù)據(jù)庫有兩種方式一般理解的端口的那種和套接字一般叫或者。解決首先要看本機的套接字文件在哪里,查看命令是輸出結(jié)果顯示套接字文件的位置,比如這臺服務(wù)器顯示的是然后修改的配置文件與之對應(yīng)起來就好了。
操作系統(tǒng):linux Mint 18.2
編譯安裝php7.2
1.先安裝編譯工具 sudo apt install gcc automake autoconf libtool g++ #在centos下,是yum install gcc automake autoconf libtool gcc-c++ 2.安裝基礎(chǔ)庫 sudo apt install libxml2-dev openssl libssl-dev curl libcurl4-gnutls-dev libjpeg-dev libpng12-dev libfreetype6 libfreetype6-dev libmcrypt4 libmcrypt-dev #在centos下:yum install gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel 2.下載php7.2.tar.gz源碼 3.解壓 tar -xzvf php7.2.tar.gz
4.編譯安裝
./configure --prefix=/usr/local/php7/ --with-pcre-regex=/opt/pcre-8.39/ --with-pcre-dir=/opt/pcre-8.39/ --with-openssl-dir=/opt/openssl-1.0.2h/ --with-openssl=/opt/openssl-1.0.2h/ --with-zlib-dir=/opt/zlib-1.2.8/ --with-zlib=/opt/zlib-1.2.8/ --with-curl=/opt/curl-7.50.1/ --with-mcrypt=/opt/libmcrypt-2.5.7/ --with-bz2 --with-ldap=/opt/openldap-2.4.30/ --with-gd --with-pdo-mysql=shared,mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-gettext --with-iconv-dir --with-kerberos --with-libxml-dir --with-mhash --with-zlib-dir --without-pdo-sqlite --with-pear --with-xmlrpc --with-xsl --enable-opcache --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-zip --enable-ftp --enable-fpm --enable-mbstring --enable-gd-native-ttf --enable-gd-jis-conv --enable-calendar --enable-fpm --enable-pcntl --enable-shmop --enable-exif --enable-pcntl --enable-wddx --enable-intl --enable-libgcc
./buildconf ./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-openssl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --without-gdbm --enable-fileinfo --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-pcntl --enable-maintainer-zts --enable-pthreads
configure: WARNING: unrecognized options: --with-mcrypt, --with-mhash--with-openssl, --enable-gd-native-ttf, --enable-pthreads
Please check your libxml2 installation
然后修改fpm配置文件
cd /usr/local/php7/etc
sudo cp php-fpm.conf.default php-fpm.conf
但是執(zhí)行php-fpm時報錯:
../sbin/php-fpm
[23-Jul-2017 15:24:07] WARNING: Nothing matches the include pattern "/usr/local/php7/etc/php-fpm.d/*.conf" from /usr/local/php7/etc/php-fpm.conf at line 125.
[23-Jul-2017 15:24:07] ERROR: failed to open error_log (/usr/local/php7/var/log/php-fpm.log): Permission denied (13)
[23-Jul-2017 15:24:07] ERROR: failed to post process the configuration
[23-Jul-2017 15:24:07] ERROR: FPM initialization failed
添加用戶和用戶組(ubuntu,mint)
sudo addgroup www
sudo adduser www
對deepin 來說 sudo adduser www 就可以創(chuàng)建www用戶和www用戶組了。
然后改變php目錄的用戶和用戶組
sudo chown -R www:www /usr/local/php7/
拷貝源碼中的php.ini-develop文件到/usr/local/php7/etc/php.ini
把/usr/local/php7/etc/php-fpm.conf.default 復(fù)制為php-fpm.conf
把/usr/local/php7/etc/php-fpm.d/www.conf.default 復(fù)制為www.conf
然后再執(zhí)行php-fpm
sudo ./php-fpm
執(zhí)行成功,ps axu | grep php如下:
wm@wm-Lenovo /usr/local/php7/sbin $ ps axu | grep php root 11492 0.0 0.1 177576 11420 ? Ss 15:40 0:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf) www 11493 0.0 0.1 177576 8748 ? S 15:40 0:00 php-fpm: pool www www 11494 0.0 0.1 177576 8744 ? S 15:40 0:00 php-fpm: pool www wm 11496 0.0 0.0 15964 1016 pts/1 S+ 15:41 0:00 grep --color=auto php
nginx編譯安裝
1.下載nginx源碼,并解壓
2.下載zlib和pcre源碼,并解壓。
3.configure的參數(shù),參考nginx官方
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.40 --with-zlib=../zlib-1.2.11 --user=www --group=www
make && make install
與php安裝一樣,也修改/usr/local/nginx的用戶和用戶組為www:www
mysql編譯安裝
https://dev.mysql.com/downloads/mysql/ https://dev.mysql.com/downloads/file/?id=471659 -- https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19.tar.gz 編譯安裝需要參考如下: https://dev.mysql.com/doc/refman/5.7/en/source-installation.html https://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html http://www.cnblogs.com/goozgk/p/5645041.html
# mkdir -p /usr/local/mysql /mydata/data # groupadd -r mysql # useradd -g mysql -r -d /data/mydata mysql # chown -R mysql.mysql /usr/local/mysql /mydata/data # wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz # tar xf mysql-boost-5.7.13.tar.gz # cd mysql-5.7.13 # yum install -y openssl openssl-devel # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_BOOST=/home/alex/Downloads/boost_1_59_0 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
localhost 和127.0.0.1的問題
連接MySQL數(shù)據(jù)庫有兩種方式:TCP/IP(一般理解的端口的那種)和Unix套接字(一般叫socket或者sock)。大部分情況下,可以用localhost代表本機127.0.0.1,但是在MySQL連接時,二者不可混用,而且MySQL中權(quán)限設(shè)置中l(wèi)ocalhost與127.0.0.1也是分開設(shè)置的。當設(shè)置為127.0.0.1時,系統(tǒng)通過TCP/IP方式連接數(shù)據(jù)庫;當設(shè)置為localhost時,系統(tǒng)通過socket方式連接數(shù)據(jù)庫。
解決:首先要看本機MySQL的socket套接字文件在哪里,查看命令是:
mysqld --verbose --help | grep socket
輸出結(jié)果顯示套接字文件的位置,比如:這臺服務(wù)器顯示的是
socket /var/run/mysqld/mysqld.sock
然后修改php的配置文件php.ini與之對應(yīng)起來就好了。
找到這一項:
mysql.default_socket =
一般來說這一項都是空的,改成:
mysql.default_socket = /var/run/mysqld/mysqld.sock
這里應(yīng)寫上一步查詢到的文件,根據(jù)你的情況設(shè)置。至此php配置就修改好了,如果是CLI(命令行)方式或者CGI方式的話,立即就生效,如果是FASTCGI方式,需要重啟一下fastcgi進程。
php-fpm服務(wù)啟動腳本
先創(chuàng)建自啟動文件:/etc/init.d/php-fpm
內(nèi)容如下:
#! /bin/sh ### BEGIN INIT INFO # Provides: php-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO prefix=/usr/local/php exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm php_fpm_CONF=${prefix}/etc/php-fpm.conf php_fpm_PID=${prefix}/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in "created") if [ -f "$2" ] ; then try="" break fi ;; "removed") if [ ! -f "$2" ] ; then try="" break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; status) if [ ! -r $php_fpm_PID ] ; then echo "php-fpm is stopped" exit 0 fi PID=`cat $php_fpm_PID` if ps -p $PID | grep -q $PID; then echo "php-fpm (pid $PID) is running..." else echo "php-fpm dead but pid file exists" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload|status}" exit 1 ;; esac
修改php-fpm的權(quán)限,設(shè)置啟動
# 設(shè)置權(quán)限 chmod 755 /etc/init.d/php-fpm # php-fpm加入服務(wù) chkconfig --add php-fpm # php-fpm 234級別下設(shè)置為啟動 chkconfig php-fpm on # 查看php-fpm服務(wù)當前配置 chkconfig --list php-fpm php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off 如果是ubuntu下( chkconfig 已經(jīng)不能在ubuntu下使用,應(yīng)該:) # 設(shè)置權(quán)限 chmod 755 /etc/init.d/php-fpm sudo update-rc.d php-fpm defaults // 添加 update-rc.d ServiceName defaults // 刪除 update-rc.d ServiceName remove 最后應(yīng)該是sudo service php-fpm force-stop一下,不然直接service php-fpm restart 可能會報錯:
service 控制nginx
#!/bin/sh ### BEGIN INIT INFO # Provides: nginx # Required-Start: # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: nginx # Description: nginx server ### END INIT INFO . /lib/lsb/init-functions # ubuntu # . /etc/lib/functions # centos PROGRAM=/usr/local/nginx/nginx test -x $PROGRAM || exit 0 case "$1" in start) log_begin_msg "Starting Nginx server" /usr/local/nginx/nginx log_end_msg 0 ;; stop) PID=`cat /usr/local/nginx/nginx.pid` log_begin_msg "Stopping Nginx server" if [ ! -z "$PID" ]; then kill -15 $PID fi log_end_msg 0 ;; restart) $0 stop $0 start ;; *) log_success_msg "Usage: service nginx {start|stop|restart}" exit 1 esac exit 0
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/23292.html
摘要:如果不用我們可能將上述講的命令每搭建一次就需要執(zhí)行一遍,有沒有能統(tǒng)一管理的有,就是在環(huán)境搭建中的作用快速創(chuàng)建鏡像,快速創(chuàng)建并運行容器,實現(xiàn)統(tǒng)一管理。 前言 初學(xué)者在dcoker學(xué)習(xí)過程中,可能不太清楚docker中那么多的命令,參數(shù),工具在lnmp環(huán)境搭建中起了什么作用,下面跟著我來熟悉一下。(本文面向的是不怎么熟悉linux的:phper) 鏡像,容器,倉庫 鏡像:Docker 鏡像...
摘要:學(xué)習(xí)心得前言耗時一周零三天,終于用搭建起自己的開發(fā)環(huán)境。來搭建一下環(huán)境,然后,桌面沒了。作為過來人,我只想說,一定要只做一件事,不要過多的去研究,我們只是想搭建本地運行環(huán)境。 docker學(xué)習(xí)心得 前言 耗時一周零三天,終于用docker搭建起自己的開發(fā)環(huán)境。詳細過程:請參考分解docker在lnmp環(huán)境搭建中的作用showImg(https://segmentfault.com/im...
摘要:博客搬家原地址原發(fā)表時間本文討論使用安裝包構(gòu)建網(wǎng)站底層服務(wù)后,包括域名解析,的管理等的一系列填坑歷程。域名解析問題相關(guān)首先將本人的網(wǎng)站信息公布如下域名地址主機提供方搬瓦工域名托管及解析阿里云萬網(wǎng)本文之后的內(nèi)容均是基于以上信息。 「博客搬家」 原地址: CSDN 原發(fā)表時間: 2016-11-16 本文討論使用 LNMP 安裝包構(gòu)建網(wǎng)站底層服務(wù)后,包括域名解析,MySQL 的管理等...
閱讀 2665·2021-11-24 10:44
閱讀 1920·2021-11-22 13:53
閱讀 1948·2021-09-30 09:47
閱讀 3712·2021-09-22 16:00
閱讀 2443·2021-09-08 09:36
閱讀 2321·2019-08-30 15:53
閱讀 2795·2019-08-30 15:48
閱讀 990·2019-08-30 15:44