centos6.5 安装PHP7+nignx+msyql

前端之家收集整理的这篇文章主要介绍了centos6.5 安装PHP7+nignx+msyql前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

安装PHP

安装PHP相关依赖

yum install enchant enchant-devel gmp-devel libc-client libc-client-devel pam-devel firebird-devel libicu-devel openldap openldap-devel libmcrypt-devel unixODBC-devel freetds freetds-devel
yum install -y gcc gcc-c++ make cmake bison autoconf wget lrzsz
yum install -y libtool libtool-ltdl-devel 
yum install -y freetype-devel libjpeg.x86_64 libjpeg-devel libpng-devel gd-devel
yum install -y python-devel  patch  sudo 
yum install -y openssl* openssl openssl-devel ncurses-devel
yum install -y bzip* bzip2 unzip zlib-devel
yum install -y libevent*
yum install -y libxml* libxml2-devel
yum install -y libcurl* curl-devel 
yum install -y readline-devel

make && make install && make clean

源码安装

wget http://cn2.PHP.net/distributions/PHP-7.0.12.tar.gz
tar xzf PHP-7.0.12.tar.gz 
cd cd PHP-7.0.12


./configure --prefix=/usr/local/PHP --with-config-file-scan-dir=/usr/local/PHP/etc/ --enable-inline-optimization --enable-session --enable-fpm --with-MysqL=MysqLnd --with-MysqLi=MysqLnd --with-pdo-MysqL=MysqLnd --with-pdo-sqlite --with-sqlite3 --with-gettext --enable-mbregex --enable-mbstring --enable-xml --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-xmlrpc --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-curlwrappers --with-zlib --enable-zip --with-bz2 --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-readline

make

make install && make clean

 ln -s /usr/local/PHP/bin/PHP /usr/local/bin/PHP
 ln -s /usr/local/PHP/sbin/PHP-fpm /usr/local/bin/PHP-fpm
 
 PHP -v
PHP 7.0.12 (cli) (built: Oct 24 2016 22:29:41) ( NTS )

PHP 5.6及以上已经内置了PHP-fpm,不需要再使用外挂的方式安装PHP-fpm。只需要编译时加上“--enable-fpm”参数即可。

以上为只标注了部份PHP扩展,如需打开全部扩展,可以使用"--enable-all",如若需要查看具体参数说明,可通过如下命令查看:

> ./configure --help

错误处理

ext/date/php_date.lo' is not a valid libtool object

./configure 后,直接make可能会出现libtool: link: 'ext/date/PHP_date.lo' is not a valid libtool object 的错误。 make clean 一下然后再make,即可。原因未知,可能是某些脚本执行顺序的问题?做个标记~

配置PHP

A,配置PHP.ini文件

cp /root/PHP-7.0.12/PHP.ini-production /usr/local/PHP/etc/PHP.ini

vim /usr/local/PHP/etc/PHP.ini

> display_errors=Off

> default_time_zone=Asia/Chongqing

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


#### B,启动PHP-fpm

> # /usr/local/PHP/sbin/PHP-fpm -D

安装 Nginx

安装依赖

yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel

源码安装

wget http://Nginx.org/download/Nginx-1.11.5.tar.gz
tar xzf Nginx-1.11.5.tar.gz
cd Nginx-1.11.5

./configure \
--prefix=/usr/local/Nginx \
--sbin-path=/usr/sbin/Nginx  \
--conf-path=/usr/local/Nginx/Nginx.conf   \
--error-log-path=/var/log/Nginx/error.log  \
--http-log-path=/var/log/Nginx/access.log   \
--pid-path=/var/run/Nginx.pid   \
--lock-path=/var/run/Nginx.lock  \
--http-client-body-temp-path=/var/cache/Nginx/client_temp  \
--http-proxy-temp-path=/var/cache/Nginx/proxy_temp  \
--http-fastcgi-temp-path=/var/cache/Nginx/fastcgi_temp  \
--http-uwsgi-temp-path=/var/cache/Nginx/uwsgi_temp  \
--http-scgi-temp-path=/var/cache/Nginx/scgi_temp  \
--user=Nginx  \
--group=Nginx   \
--with-http_ssl_module  \
--with-http_realip_module  \
--with-http_addition_module  \
--with-http_sub_module  \
--with-http_dav_module  \
--with-http_flv_module  \
--with-http_mp4_module  \
--with-http_gunzip_module  \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module  \
--with-file-aio  \
--with-ipv6  \
--with-pcre  

make

make install && make clean

Nginx -v
    Nginx version: Nginx/1.11.5

vim /usr/local/Nginx/Nginx.conf


#/usr/sbin/groupadd -f Nginx
#/usr/sbin/useradd -g Nginx Nginx

错误处理

Nginx安装 Nginx: [emerg] getpwnam(“www”) Failed 错误 参考

linux 64系统中安装Nginx1.3时如果出现错误Nginx: [emerg] getpwnam(“www”) Failed

#/usr/sbin/groupadd -f Nginx
#/usr/sbin/useradd -g Nginx Nginx

安装 MysqL

安装依赖

yum -y install make gcc-c++ cmake bison-devel ncurses-devel perl


wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
tar xzf boost_1_59_0.tar.gz
cd boost_1_59_0
./bootstrap.sh

./b2 install --prefix=/usr/local/boost


# 创建用户,组

groupadd MysqL
mkdir /home/MysqL  #自定义位置
mkdir /home/MysqL/data  #自定义位置
useradd -g MysqL -d /home/MysqL MysqL

下载安装

安装5.7*版本没有搞好

wget https://github.com/MysqL/MysqL-server/archive/MysqL-5.6.34.tar.gz
tar xzf MysqL-5.7.15.tar.gz 
cd MysqL-server-MysqL-5.7.15

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DMysqL_DATADIR=/home/MysqL/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMysqL_TCP_PORT=3306 -DMysqL_USER=MysqL -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost

make && make install

初始化数据库

进入安装补录下的bin目录下,执行

/usr/local/MysqL/scripts/MysqL_install_db --user=MysqL --basedir=/usr/local/MysqL --datadir=/home/MysqL/data

注:默认密码为空

调整配置文件和环境变量参数

将默认生成的my.cnf备份

> mv /etc/my.cnf /etc/my.cnf.bak
> cp /usr/local/MysqL/support-files/my-default.cnf /etc/my.cnf

# 如下是我修改配置文件/etc/my.cnf, 用于设置编码为utf8以防乱码

[MysqLd]

character_set_server=utf8

init_connect='SET NAMES utf8'

[client]

default-character-set=utf8

# 复制启动脚本到init.d下
> cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqLd

# 增加执行权限
> chmod 755 /etc/init.d/MysqLd

# 创建MysqL命令文件
> ln -s /usr/local/MysqL/bin/MysqL /usr/sbin/MysqL 
注:没有这个文件就没有MysqL命令,不能在任意位置使用MysqL 访问数据库

启动MysqL

service MysqLd start

访问数据库

MysqL -uroot -p

修改默认密码

use MysqL; update user set password=PASSWORD("123456") where user='root';

创建超级用户

GRANT ALL PRIVILEGES ON . TO 'admin'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON pengshi_develop.* TO 'admin'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON pengshi_develop.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '123456' WITH GRANT OPTION;

配置开机启动

vim /etc/rc.d/rc.local

# 添加如下参数
/usr/sbin/Nginx

/usr/local/bin/PHP-fpm -D

service MysqLd start

# 然后
chmod +x /etc/rc.d/rc.local
原文链接:https://www.f2er.com/centos/380229.html

猜你在找的CentOS相关文章