centos6.5 安装PHP7+nignx+msyql

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

安装PHP

安装PHP相关依赖

  1. 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
  2. yum install -y gcc gcc-c++ make cmake bison autoconf wget lrzsz
  3. yum install -y libtool libtool-ltdl-devel
  4. yum install -y freetype-devel libjpeg.x86_64 libjpeg-devel libpng-devel gd-devel
  5. yum install -y python-devel patch sudo
  6. yum install -y openssl* openssl openssl-devel ncurses-devel
  7. yum install -y bzip* bzip2 unzip zlib-devel
  8. yum install -y libevent*
  9. yum install -y libxml* libxml2-devel
  10. yum install -y libcurl* curl-devel
  11. yum install -y readline-devel
  12.  
  13. make && make install && make clean

源码安装

  1. wget http://cn2.PHP.net/distributions/PHP-7.0.12.tar.gz
  2. tar xzf PHP-7.0.12.tar.gz
  3. cd cd PHP-7.0.12
  4.  
  5.  
  6. ./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
  7.  
  8. make
  9.  
  10. make install && make clean
  11.  
  12. ln -s /usr/local/PHP/bin/PHP /usr/local/bin/PHP
  13. ln -s /usr/local/PHP/sbin/PHP-fpm /usr/local/bin/PHP-fpm
  14. PHP -v
  15. 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",如若需要查看具体参数说明,可通过如下命令查看:

  1. > ./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文件

  1. cp /root/PHP-7.0.12/PHP.ini-production /usr/local/PHP/etc/PHP.ini
  2.  
  3. vim /usr/local/PHP/etc/PHP.ini
  4.  
  5. > display_errors=Off
  6.  
  7. > default_time_zone=Asia/Chongqing
  8.  
  9. cp /usr/local/PHP/etc/PHP-fpm.conf.default /usr/local/PHP/etc/PHP-fpm.conf
  10. cp /usr/local/PHP/etc/PHP-fpm.d/www.conf.default /usr/local/PHP/etc/PHP-fpm.d/www.conf
  11.  
  12.  
  13. #### B,启动PHP-fpm
  14.  
  15. > # /usr/local/PHP/sbin/PHP-fpm -D

安装 Nginx

安装依赖

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

源码安装

  1. wget http://Nginx.org/download/Nginx-1.11.5.tar.gz
  2. tar xzf Nginx-1.11.5.tar.gz
  3. cd Nginx-1.11.5
  4.  
  5. ./configure \
  6. --prefix=/usr/local/Nginx \
  7. --sbin-path=/usr/sbin/Nginx \
  8. --conf-path=/usr/local/Nginx/Nginx.conf \
  9. --error-log-path=/var/log/Nginx/error.log \
  10. --http-log-path=/var/log/Nginx/access.log \
  11. --pid-path=/var/run/Nginx.pid \
  12. --lock-path=/var/run/Nginx.lock \
  13. --http-client-body-temp-path=/var/cache/Nginx/client_temp \
  14. --http-proxy-temp-path=/var/cache/Nginx/proxy_temp \
  15. --http-fastcgi-temp-path=/var/cache/Nginx/fastcgi_temp \
  16. --http-uwsgi-temp-path=/var/cache/Nginx/uwsgi_temp \
  17. --http-scgi-temp-path=/var/cache/Nginx/scgi_temp \
  18. --user=Nginx \
  19. --group=Nginx \
  20. --with-http_ssl_module \
  21. --with-http_realip_module \
  22. --with-http_addition_module \
  23. --with-http_sub_module \
  24. --with-http_dav_module \
  25. --with-http_flv_module \
  26. --with-http_mp4_module \
  27. --with-http_gunzip_module \
  28. --with-http_gzip_static_module \
  29. --with-http_random_index_module \
  30. --with-http_secure_link_module \
  31. --with-http_stub_status_module \
  32. --with-http_auth_request_module \
  33. --with-file-aio \
  34. --with-ipv6 \
  35. --with-pcre
  36.  
  37. make
  38.  
  39. make install && make clean
  40.  
  41. Nginx -v
  42. Nginx version: Nginx/1.11.5
  43.  
  44. vim /usr/local/Nginx/Nginx.conf
  45.  
  46.  
  47. #/usr/sbin/groupadd -f Nginx
  48. #/usr/sbin/useradd -g Nginx Nginx

错误处理

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

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

  1. #/usr/sbin/groupadd -f Nginx
  2. #/usr/sbin/useradd -g Nginx Nginx

安装 MysqL

安装依赖

  1. yum -y install make gcc-c++ cmake bison-devel ncurses-devel perl
  2.  
  3.  
  4. wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
  5. tar xzf boost_1_59_0.tar.gz
  6. cd boost_1_59_0
  7. ./bootstrap.sh
  8.  
  9. ./b2 install --prefix=/usr/local/boost
  10.  
  11.  
  12. # 创建用户,组
  13.  
  14. groupadd MysqL
  15. mkdir /home/MysqL #自定义位置
  16. mkdir /home/MysqL/data #自定义位置
  17. useradd -g MysqL -d /home/MysqL MysqL

下载安装

安装5.7*版本没有搞好

  1. wget https://github.com/MysqL/MysqL-server/archive/MysqL-5.6.34.tar.gz
  2. tar xzf MysqL-5.7.15.tar.gz
  3. cd MysqL-server-MysqL-5.7.15
  4.  
  5. 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
  6.  
  7. make && make install

初始化数据库

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

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

注:默认密码为空

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

将默认生成的my.cnf备份

  1. > mv /etc/my.cnf /etc/my.cnf.bak
  2. > cp /usr/local/MysqL/support-files/my-default.cnf /etc/my.cnf
  3.  
  4. # 如下是我修改配置文件/etc/my.cnf, 用于设置编码为utf8以防乱码
  5.  
  6. [MysqLd]
  7.  
  8. character_set_server=utf8
  9.  
  10. init_connect='SET NAMES utf8'
  11.  
  12. [client]
  13.  
  14. default-character-set=utf8
  15.  
  16. # 复制启动脚本到init.d下
  17. > cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqLd
  18.  
  19. # 增加执行权限
  20. > chmod 755 /etc/init.d/MysqLd
  21.  
  22. # 创建MysqL命令文件
  23. > ln -s /usr/local/MysqL/bin/MysqL /usr/sbin/MysqL
  24. 注:没有这个文件就没有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;

配置开机启动

  1. vim /etc/rc.d/rc.local
  2.  
  3. # 添加如下参数
  4. /usr/sbin/Nginx
  5.  
  6. /usr/local/bin/PHP-fpm -D
  7.  
  8. service MysqLd start
  9.  
  10. # 然后
  11. chmod +x /etc/rc.d/rc.local

猜你在找的CentOS相关文章