源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

ubuntu14.04LTS安装nginx+mariaDB+php7+YAF的方法

  • 时间:2020-02-16 03:31 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:ubuntu14.04LTS安装nginx+mariaDB+php7+YAF的方法
本文讲述了ubuntu14.04LTS安装nginx+mariaDB+php7+YAF的方法。分享给大家供大家参考,具体如下: [b]ubuntu apt-get方式安装nginx[/b] 参考: [url=http://nginx.org/en/linux_packages.html]http://nginx.org/en/linux_packages.html[/url] 首先 in order to authenticate the nginx repository signature and to eliminate warnings about missing PGP key during installation of the nginx package, it is necessary to add the key used to sign the nginx packages and repository to the apt program keyring. 下载密钥
wget http://nginx.org/keys/nginx_signing.key

然后添加
sudo apt-key add nginx_signing.key

加入nginx的repository
cd /etc/apt/sources.list.d/
sudo vim nginx.list

若安装稳定版本,则输入以下内容
deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx

若最新版本,则输入以下内容:
deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx

然后安装
apt-get update
apt-get install nginx

安装完成
nginx -v
nginx version: nginx/1.8.0

[b]MariaDB数据库安装[/b] MariaDB是一个开源数据库且100%与MySQL兼容,目标是替代MySQL数据库。 MariaDB的背景 : 2008年,MySQL被后来被Oracle在2010年收购的Sun Microsystems收购了。 最初被Sun公司的收购由于符合项目的需要而受到MySQL社区的欢呼,但是这种情绪并没有持续太久,接下来被Oracle的收购,不幸期望远远低于预 期。许多MySql的开发者离开了Sun和Oracle公司开始新的项目。在他们中间就有MySQL的创建者以及项目长期技术带头人之一的Michael 'Monty' Widenius。Monty和他的团队创建了MySQL的一个fork版本并且命名它为MariaDB。 默认上MariaDB的包并没有在Ubuntu仓库中。要安装MariaDB,我们首先要设置MariaDB仓库。 设置 MariaDB 仓库
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.3GolFM9PZ5 --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
gpg: requesting key 1BB943DB from hkp server keyserver.ubuntu.com
gpg: key 1BB943DB: public key "MariaDB Package Signing Key <package-signing-key@mariadb.org>" imported
gpg: Total number processed: 1
gpg:        imported: 1
sudo add-apt-repository 'deb http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main'

安装 MariaDB :
sudo apt-get update
sudo apt-get install mariadb-server

在安装中,你会被要求设置MariaDB的root密码。 从命令行连接到MariaDB :
keyun@ubuntu-server:~$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 43
Server version: 10.0.23-MariaDB-1~trusty-log mariadb.org binary distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

MariaDB 服务
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

以上只是在Ubuntu上装完MariaDB,下面要设置MariaDB允许远程访问 1、如果Ubuntu有设置防火墙或者iptables规则的话,请自行打开 2、3306端口是不是没有打开? 使用nestat命令查看3306端口状态:
~# netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

从结果可以看出3306端口只是在IP 127.0.0.1上监听,所以拒绝了其他IP的访问。 解决方法:修改/etc/mysql/my.cnf文件。打开文件,找到下面内容:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

把上面这一行注释掉或者把127.0.0.1换成合适的IP,建议注释掉。 重新启动后,重新使用netstat检测:
~# netstat -an | grep 3306
tcp    0   0 0.0.0.0:3306      0.0.0.0:*        LISTEN

1. 把用户权限分配各远程用户。 登录到mysql服务器,使用grant命令分配权限
[url=http://www.1sucai.cn/article/85491.htm]http://www.1sucai.cn/article/85491.htm[/url] 再次测试,QPS偶尔能彪上10000 [b]安装YAF[/b]
sudo wget http://pecl.php.net/get/yaf-3.0.2.tgz
sudo tar -zvxf yaf-3.0.2.tgz

解压缩以后, 进入Yaf的源码目录, 依次执行(其中PHP_BIN是PHP的bin目录):
sudo /usr/local/php/bin/phpize

报错: Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. 解决办法:
sudo apt-get install m4
sudo apt-get install autoconf
sudo apt-get install libpcre3 libpcre3-dev 

phpize执行后:
sudo ./configure --with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make install
Installing shared extensions:   /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/

安装成功,修改php.ini,加入yaf扩展
extension=yaf.so

重启php-fpm,查看phpinfo()  [img]http://files.jb51.net/file_images/article/201605/2016531111410823.png?2016431111428[/img] 安装yaf成功 [b]PS:使用PDO过程中,出现 SQLSTATE[HY000] [2002] No such file or directory 错误[/b] 经查,是mysql.sock找不到 在phpinfo()中,看到pdo_mysql.default_socket的值是/tmp/mysql.sock  [img]http://files.jb51.net/file_images/article/201605/2016531111725644.png?2016431111741[/img] 但是在服务器上并没有这个文件 通过sudo service mysql status 命令
* /usr/bin/mysqladmin Ver 9.1 Distrib 10.0.23-MariaDB, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Server version     10.0.23-MariaDB-1~trusty-log
Protocol version    10
Connection       Localhost via UNIX socket
UNIX socket       /var/run/mysqld/mysqld.sock
Uptime:         3 min 28 sec

找到sock文件的位置在/var/run/mysqld/mysqld.sock 于是在/tmp下 做个软链接
sudo ln -s /var/run/mysqld/mysqld.sock mysql.sock

问题解决 通过localhost无法访问到数据库,但是通过IP可以 分析:这是典型的socket没有正确设置的情况。 连接MySQL数据库有两种方式:TCP/IP(一般理解的端口的那种)和Unix套接字(一般叫socket或者sock)。大部分情况下,可以用localhost代表本机127.0.0.1,但是在MySQL连接时,二者不可混用,而且MySQL中权限设置中localhost与127.0.0.1也是分开设置的。当设置为127.0.0.1时,系统通过TCP/IP方式连接数据库;当设置为localhost时,系统通过socket方式连接数据库。 根据上面的sudo service mysql status命令 得到sock文件的位置在/var/run/mysqld/mysqld.sock 于是,修改php.ini
pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock

重启php-fpm 问题解决 希望本文所述对大家ubuntu服务器配置有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部