本文共 4395 字,大约阅读时间需要 14 分钟。
lnmp分离部署 目录目录.... 1版权声明:.... 2文档信息:.... 21.在192.168.200.101上安装nginx. 32.在192.168.200.102上安装mysql. 53.在192.168.200.103上安装php. 7 文档信息:文档作者:amun文档版本:Version 1.1修改记录:2017-04-18系统环境:CentOS 6.8 64 bit 环境:一、在三台机器上分别部署:Nginx 192.168.200.101Mysql 192.168.200.102Php 192.168.200.103 1.在192.168.200.101上安装nginxyum -y installpcre-devel zlib-develuseradd -M -s/sbin/nologin nginxtar xfnginx-1.6.0.tar.gz -C /usr/src/cd/usr/src/nginx-1.6.0/ ./configure--prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module--with-http_stub_status_module --with-http_gzip_static_module --with-pcre && make &&make install ln -s/usr/local/nginx/sbin/nginx /usr/local/sbin/ 修改nginx配置文件,把server段的以下内容去掉注释vim/usr/local/nginx/conf/nginx.conf65行左右location ~ \.php${ fastcgi_pass 192.168.200.103:9000; ##PHP服务器的IP地址,及监听端口 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; include fastcgi_params; }检查语法及启动:nginx –tnginx使用浏览器访问http://192.168.200.101能正常访问Nginx服务安装完毕 创建与PHP、mysql结合的结合页面cd /var/www/htmlvim index.php ##添加测试页面 2.在192.168.200.102上安装mysql安装前准备:yum -y install gcccmakeuseradd -M -s/sbin/nologin mysqltar xfmysql-5.5.22.tar.gzcd mysql-5.5.22cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all-DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1-DWITH_INNOBASE_STORAGE_ENGINE=1make &&make install配置mysqlcd/usr/local/mysql/chown -Rmysql.mysql /usr/local/mysql/初始化数据库:./scripts/mysql_install_db--user=mysql --datadir=/usr/local/mysql/data调整mysql:cd/usr/local/mysql/cpsupport-files/my-medium.cnf /etc/my.cnf cpsupport-files/mysql.server /etc/init.d/mysqldchmod +x/etc/init.d/mysqld chkconfig mysqldon环境变量设置:vim /etc/profile在最后一行添加PATH=/bin:/usr/local/mysql/bin/:$PATHsource /etc/profile vim/etc/ld.so.conf添加以下内容:includeld.so.conf.d/*.conf/usr/local/mysql/lib/启用配置Ldconfig创建mysql数据库用户mysqladmin -urootpassword '123456'数据库授权:grant allprivileges on *.* to 'root'@'%' identified by '123456';grant allprivileges on *.* to 'root'@'localhost' identified by '123456';flush privileges; 3.在192.168.200.103上安装phpPHP所需依赖及添加用户yum -y install gccopenssl-devel pcre pcre-devel zlib-devel libxml2-devel curl-devel libjpeg-devellibpng-devel freetype-devel bzip2-develuseradd -M -s/sbin/nologin www 安装php扩展工具源代码安装libmcrypttar zxflibmcrypt-2.5.8.tar.gzcdlibmcrypt-2.5.8/./configure &&make && make installln -s/usr/local/lib/libmcrypt.* /usr/lib/源代码安装mhashtar zxfmhash-0.9.9.9.tar.gz cd mhash-0.9.9.9/./configure&& make && make installln -s /usr/local/lib/libmhash*/usr/lib/ 源代码安装mcrypttar zxfmcrypt-2.6.8.tar.gzcd mcrypt-2.6.8/./configure编译时候报错:configure: error:*** libmcrypt was not found解决办法:ln-s /usr/local/bin/libmcrypt_config /usr/bin/libmcrypt_configexportLD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH重新执行./configure后安装make &&make install 安装phptar xfphp-5.3.28.tar.gz cd php-5.3.28./configure--prefix=/usr/local/php5 --with-gd --with-zlib --with-mysql=mysqlnd--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-config-file-path--enable-mbsrting --enable-fpm --with-jpeg-dir=/usr/lib --enable-sockets&& make && make install 调整php、php-fpm加入系统服务:cpphp.ini-development /usr/local/php5/php.iniln -s/usr/local/php5/bin/* /usr/local/bin/ln -s/usr/local/php5/sbin/* /usr/local/sbin/cpsapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x/etc/init.d/php-fpm chkconfig --addphp-fpmchkconfig php-fpmon修改php-fpm配置文件:cd/usr/local/php5/etc/cpphp-fpm.conf.default php-fpm.confvim/usr/local/php5/etc/php-fpm.conf修改以下内容:[global]pid =run/php-fpm.piderror_log =log/php-fpm.loglog_level = errordaemonize = yes[www]user = wwwgroup = wwwlisten = 127.0.0.1.:9000pm = dynamic ## 进程管理方式为dynamic,static为静态pm.max_children =32 ##子进程最大数根据官方建议,小于2GB内存的服务器, ##可以只开启64个进程,4GB以上内存的服务器可以开启200个进程。pm.start_servers =15 ##动态方式下的起始php-fpm进程数量。pm.min_spare_servers= 5 ##动态方式下的最小php-fpm进程数量pm.max_spare_servers= 32 ##动态方式下的最大php-fpm进程数量 启动php-fpmservice php-fpmstartcd /var/www/html vim index.php ##添加测试页面,必须和nginx的测试页面在相同路径下 最后使用客户端浏览器访问http://192.168.200.101/index.php end
转载于:https://blog.51cto.com/amunlinux/1946774