LAMP平台部署与应用一 安装Apache服务1 删除rpm方式安装的httpdrpm -e httpd --nodeps2 安装支持的软件包yum -y install apr apr-devel cyrus-sasl-devel expat-devel libdb-devel openldap-devel apr-util-devel apr-util pcre-devel pcre结果如图:3 源码编译及安装上传 rz httpd……解压 tar zxf httpd…… -C /usr/srccd /usr/src/httpd……配置及编译安装./configure --prefix=/usr/local/httpd –enable-so –enable-rewrite –enable-charset-lite –enable-cgi && make && make install添加系统服务vim /lib/systemd/system/httpd.service[Unit]Description=The Apache HTTP ServerAfter=network.target
[Service]Type=forkingPIDFile=/usr/local/httpd/logs/httpd.pidExecStart=/usr/local/bin/apachectl $OPTIONSExecReload=/bin/kill -HUP $MAINPIDKillMode=processRestart=on-failureRestartSec=42s
[Install]WantedBy=graphical.target4 启动系统服务systemctl start(stop) httpdsystemctl enable httpd 开机自启若出现:Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.查看配置文件,保证无错的情况下,做优化连接ln -s /usr/local/httpd/bin/* /usr/local/bin/结果如图:
Vim /usr/local/httpd/conf/httpd.conf
二 安装启动MySQL1 yum –y install ncurses-devel2 安装cmake编译安装包Rz 上传 Tar zxf cmake.. Cd cmake…./configure && gmake && gmake install3 源码编译及安装创建组用户 groupadd mysql创建用户 useradd –M –s /sbin/nologin mysql –g mysql解压 tar zxf mysql… -C /usr/src配置 cd /usr/src/mysql….cmake –DCMAKE_INSTALL_PREFIX=/usr/local/mysql –DSYSCONFDIR=/etc –DDEFAULT_CHARSET=utf8 –DDEFAULT_COLLATION=utf8_general_ci –DWITH_EXTRA_CHARSETS=all编译安装 make && make install4 安装后的调整权限设置 chown –R mysql:mysql /usr/local/mysql建立配置文件:CentOS 7 默认支持MariaDB数据库,系统默认的/etc/my.cnf为MariaDB的配置文件因此需要将原本的文件替换为MySQL的Rm –rf /etc/my.cnfCp support-files/my-default.cnf /etc/my.cnf初始化数据库/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/设置变量环境Echo “PATH=$PATH:/usr/local/mysql/bin” >> /etc/profile ./etc/profile 生效若出现FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:Data::Dumper解决方法:yum –y install autoconf5 添加系统服务Cp support-files/mysql.server /usr/local/mysql/bin/mysql.shChmod +x /usr/local/mysql/bin/mysql.sh方法一:ln -s /usr/local/mysql/bin/* /usr/local/bin/ 用mysql.sh start 启用方法二:vim /usr/lib/systemd/system/mysqld.service重新加载:systemctl daemon-reload 重启systemctl stop(start) mysqld三 构建PHP运行环境1.查看并卸载rpm包PHPrpm -e php php-cli php-ldap php-common php-mysql --nodeps 2.安装mcrypt加密工具前提:yum -y install zlib-devel xz-devel libxml2-devel
(1)解压Libmcrypt mhash mcrypt (可以从http://sourceforge.net下载)(2)cd /usr/src/libmcypt..../configure && make && make installln -s /usr/local/lib/libmcrypt. /usr/lib(3)cd /usr/src/mhash..../configure && make && make installln -s /usr/local/lib/libmhash /usr/lib(4)cd /usr/src/mcrypt..../configure && make && make install若报错(configure: error: *** libmcrypt was not found),则export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH后重新配置安装
3.编译安装PHP(1)解压: tar zxf php-5... -C /usr/src(2)编译安装cd /usr/src/php-5..../configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring && make && make install4.设置LAMP组建环境(1)php.ini配置调整安装好PHP软件包后,服务器并不会自动创建php.ini的配置文件,但在源码包目录下提供两个样例php.ini-development 开发版php.ini-production 生产版cp /usr/src/php…/php.ini-development /usr/local/php5/php.inivim /usr/local/php5/php.inidefault_charset = "utf-8"short_open_tag = onextension=php_mysqli.dll(2)添加ZendGuardLoader优化模块(http://www.zend.com)tar zxf zend... -C /usr/srccd /usr/src/zend...cp Zend... /usr/local/php5/lib/phpvim /usr/loca/php5/php.inizend_extension=/usr/local/php5/lib/php/ZendGuardLoader.sozend_loader.enable=1(3)httpd.conf配置调整 vim /usr/local/httpd/conf/httpd.confDirectoryIndex index.html index.phpAddType application/x-httpd-php .php/usr/local/httpd/bin/apachectl restart(4)测试①测试PHP网页能否正确显示vim /usr/local/httpd/htdocs/test1.php<?phpphpinfo();?> 结果:②测试PHP网页能否访问MySQL数据库vim /usr/local/httpd/htdocs/test2.php结果:5.安装phpMyadmin(官方地址:http://www.phpadmin.net)(1)解压(2)mv phpMyadmin... /usr/local/httpd/htdocs/phpmyadmin(3)cd /usr/local/httpd/htdocs/phpmyadmincp config.sample.inc.php config.inc.php(4)访问测试 mysqladmin -u root -p password ‘123456’结果: