M25-13

  1   懒人少语第十三周之通过CentOS7.4实现编译安装LAMP    
  2     🌙实例:
  3         /root/src作为源码文件目录;
  4             准备以下文件:
  5                 apr-1.6.2.tar.gz 
  6                 apr-util-1.6.0.tar.gz
  7                 httpd-2.4.27.tar.bz2
  8                 mariadb-10.2.8-linux-x86_64.tar.gz
  9                 php-7.1.10.tar.xz
 10                 wordpress-4.8.1-zh_CN.tar.gz
 11 
 12         1、源码编译httpd
 13             [root@Centos7 02:30:28 src]#yum group install "development tools"
 14             [root@Centos7 02:38:59 src]#yum install openssl-devel expat-devel pcre-devel
 15                 准备好前提条件
 16             [root@Centos7 02:35:07 src]#tar xvf apr-1.6.2.tar.gz
 17             [root@Centos7 02:36:07 src]#tar xvf apr-util-1.6.0.tar.gz
 18             [root@Centos7 02:36:07 src]#tar xvf httpd-2.4.27.tar.bz2
 19             [root@Centos7 02:36:43 src]#cp -r apr-1.6.2 httpd-2.4.27/srclib/apr
 20             [root@Centos7 02:37:10 src]#cp -r apr-util-1.6.0 httpd-2.4.27/srclib/apr-util
 21             [root@Centos7 02:39:27 src]#cd httpd-2.4.27/
 22             [root@Centos7 02:45:03 httpd-2.4.27]#
 23                 ./configure --prefix=/app/httpd24 \         `在该目录安装相关文件`
 24                 --sysconfdir=/etc/httpd24 \                 `只读单机数据(/etc路径位置)`
 25                 --enable-so \                               `启用动态共享对象`
 26                 --enable-ssl \                              `启用SSL/TLS功能`
 27                 --enable-rewrite \                          `基于规则的URL操作`
 28                 --with-zlib \
 29                 --with-pcre \                               `使用外部PCRE库`
 30                 --with-included-apr \                       `使用zpr/zpr-util功能`
 31                 --enable-modules=most \                     `允许使用空格分隔的模块列表`
 32                 --enable-mpms-shared=all \                  `MPM模块的空间分隔列表,以支持动态加载`
 33                 --with-mpm=prefork                          `指定Apache默认使用的工作模型`
 34             [root@Centos7 03:06:21 httpd-2.4.27]#make -j 2 && make install
 35             [root@Centos7 03:20:44 httpd24]#ls (/app/httpd24/)
 36                 bin(启动路径等)  build  cgi-bin  error  htdocs(主页)  icons  include  lib  logs  man  manual  modules
 37             [root@Centos7 03:20:45 httpd24]#vim /etc/profile.d/lamp.sh
 38                 PATH=/app/httpd24/bin/:$PATH                `环境变量;添加并激活`
 39                     
 40                 [root@Centos7 03:35:32 httpd24]#apachectl   `可用于启动服务并测试`[端口80;ss -tnl;apachectl stop停止服务]
 41                     curl 172.18.252.13                      `Done`
 42             
 43         2、源码编译mariadb
 44             [root@Centos7 03:39:01 httpd24]#cd /root/src/
 45             [root@Centos7 03:40:46 src]#tar xvf mariadb-10.2.8-linux-x86_64.tar.gz -C /usr/local/
 46             安装前需确保本机原先无mysql/mariadb-server等其它版本()  [rpm -qa|grep mariadb]
 47             [root@Centos7 03:44:37 src]#cd /usr/local
 48             [root@Centos7 03:45:39 local]#ln -s mariadb-10.2.8-linux-x86_64/ mysql  `必须`
 49             没有mysql用户的情况下建立用户()
 50             [root@Centos7 03:47:43 local]#useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql
 51             [root@Centos7 03:50:56 mysql]#cd mysql/
 52             利用脚本来安装创建用户叫mysql的数据库()
 53             [root@Centos7 03:50:56 mysql]#scripts/mysql_install_db --datadir=/app/mysqldb --user=mysql
 54             创建好mysql存放数据的目录()
 55             [root@Centos7 03:50:56 mysql]#mkdir /etc/mysql
 56                 /usr/local/mysql/support-files/ `该目录记录者各种类型的模版配置`
 57             拷贝模版文件当作配置文件()
 58             [root@Centos7 03:56:28 mysql]#cp support-files/my-large.cnf /etc/mysql/my.cnf
 59             [root@Centos7 03:57:37 mysql]#vim /etc/mysql/my.cnf
 60                 [mysqld]
 61                 datadir = /app/mysqldb
 62                 innodb_file_per_table = ON      `后两项不是必须`
 63                 skip_name_resolve = ON
 64             将启动脚本拷贝至用于启动服务()
 65             [root@Centos7 04:02:09 mysql]#cp support-files/mysql.server /etc/init.d/mysqld
 66             [root@Centos7 04:05:03 mysql]#chkconfig --add mysqld    [chkconfig --list查结果判断是否已经添加]
 67             建立启动服务时所需的日志文件()
 68             [root@Centos7 04:06:36 mysql]#mkdir /var/log/mariadb/
 69             [root@Centos7 04:07:23 mysql]#chown mysql /var/log/mariadb/ `或手动添加mariadb.log文件`
 70             [root@Centos7 05:47:14 mysql]#service mysqld start
 71             [root@Centos7 05:50:33 mysql]#vim /etc/profile.d/lamp.sh    `给mysql补充环境变量;并激活`
 72                 PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH
 73             [root@Centos7 05:53:16 mysql]#mysql_secure_installation
 74                 PW:centos Y;Y;Y;Y
 75             [root@Centos7 05:54:35 mysql]#mysql -uroot -pcentos
 76                 > create database wpdb;
 77                 > grant all on wpdb.* to wpuser@'172.18.%.%' identified by 'centos';    `或者下一条`
 78                 > grant all on wpdb.* to wpuser@'localhost' identified by 'centos';     `本机登录不需-h繁琐`
 79 
 80         3、源码编译安装php
 81             [root@Centos7 07:43:34 src]#tar xvf php-7.1.10.tar.xz
 82             [root@Centos7 07:58:55 src]#yum install libxml2-devel bzip2-devel libmcrypt-devel
 83             编译php5.6的选择:()
 84                 [root@Centos7 07:52:23 php-5.6]#./configure --prefix=/app/php \
 85                     --with-mysql=/usr/local/mysql \
 86                     --with-openssl \
 87                     --with-mysqli=/usr/local/mysql/bin/mysql_config \
 88                     --enable-mbstring \
 89                     --with-png-dir \
 90                     --with-jpeg-dir \
 91                     --with-freetype-dir \
 92                     --with-zlib \
 93                     --with-libxml-dir=/usr \
 94                     --enable-xml \
 95                     --enable-sockets \
 96                     --with-apxs2=/app/httpd24/bin/apxs \
 97                     --with-mcrypt \
 98                     --with-config-file-path=etc \
 99                     --with-config-file-scan-dir=/etc/php.d \
100                     --with-bz2
101                 [root@Centos7 08:01:45 php-7.1.10]#make -j 2 && make install
102             编译php7.1.10的选择:()`区别在7版本将--with-mysql取消,需使用--enable-mysqlnd和--with-mysqli=mysqlnd`
103                 [root@Centos7 08:12:06 php-7.1.10]#./configure --prefix=/app/php \
104                     --enable-mysqlnd \
105                     --with-mysqli=mysqlnd \
106                     --with-openssl \
107                     --with-pdo-mysql=mysqlnd \
108                     --enable-mbstring \
109                     --with-freetype-dir \
110                     --with-jpeg-dir \
111                     --with-png-dir \
112                     --with-zlib \
113                     --with-libxml-dir=/usr \
114                     --enable-xml \
115                     --enable-sockets \
116                     --with-apxs2=/app/httpd24/bin/apxs \
117                     --with-mcrypt \
118                     --with-config-file-path=/etc \
119                     --with-config-file-scan-dir=/etc/php.d \
120                     --enable-maintainer-zts \c
121                     --disable-fileinfo
122                 [root@Centos7 08:01:45 php-7.1.10]#make -j 2 && make install
123                 [root@Centos7 08:17:15 php-7.1.10]#cp php.ini-production /etc/php.ini   `给php提供模版现成的当作模版使用`
124                 [root@Centos7 08:20:41 ~]#vim /etc/httpd24/httpd.conf   
125                     AddType application/x-httpd-php .php    `添加两行使apache支持识别php文件功能`
126                     AddType application/x-httpd-php-source .phps
127                     再定位到👇
128                     DirectoryIndex index.php index.html     `调整首页顺序问题`
129                 [root@Centos7 08:29:36 ~]#apachectl restart
130          4、网页测试
131                 [root@Centos7 08:30:01 ~]#cd /app/httpd24/htdocs/
132                 [root@Centos7 08:30:32 htdocs]#vim index.php
133                     <?php
134                         echo date("Y/m/d h:i:s");
135                         $mysqli=new mysqli("localhost","root","centos");    //面向对象的连接方式
136                             if(mysqli_connect_errno()){
137                                 echo "连接数据库失败!";
138                                 $mysqli=null;
139                                 exit;
140                             }
141                         echo "连接数据库成功!";
142                         $mysqli->close();
143                         phpinfo();
144                     ?>
145                     (^U^)ノ~YO访问网页地址
   补充:👇
 1         5、配置wordpress:
 2             [root@Centos7 08:55:45 src]#cd /root/src
 3             [root@Centos7 08:56:08 src]#tar xvf wordpress-4.8.1-zh_CN.tar.gz -C /app/httpd24/htdocs
 4             [root@Centos7 08:58:18 wordpress]#cp wp-config-sample.php wp-config.php  `选择需要的配置模版`
 5             [root@Centos7 08:58:36 wordpress]#vim wp-config.php                      `配置相应的数据库账户`
 6                 /** WordPress数据库的名称 */
 7                 define('DB_NAME', 'wpdb');
 8 
 9                 /** MySQL数据库用户名 */
10                 define('DB_USER', 'wpuser');
11 
12                 /** MySQL数据库密码 */
13                 define('DB_PASSWORD', 'centos');
14 
15                 /** MySQL主机 */
16                 define('DB_HOST', 'localhost');

  搭建完成,最后访问网页进行配置即可http://172.18.252.13/wordpress

 


 

posted @ 2017-10-14 20:49  illinux  阅读(136)  评论(0编辑  收藏  举报