准备环境,搭建yum,连接xshell,rz命令传送到虚拟机。
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ls
httpd-2.2.17.tar.gz libmcrypt-2.5.8.tar.gz mediawiki-1.30.0.tar.gz.gz mysql-5.5.22.tar.gz php-7.2.0.tar.gz
[root@localhost src]# mkdir -p /data/server
[root@localhost src]# yum -y install gcc gcc-c++
[root@localhost src]# tar zxf httpd-2.2.17.tar.gz -C /data/server/
[root@localhost src]# cd /data/server/httpd-2.2.17/
[root@localhost httpd-2.2.17]# ./configure --prefix=/data/server/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
[root@localhost httpd-2.2.17]# make && make install
做路径优化。
[root@localhost httpd-2.2.17]# cd /data/server/httpd/bin/
[root@localhost bin]# ln -s /data/server/httpd/bin/* /usr/local/bin/
启动Apache,关闭防火墙。
[root@localhost bin]# apachectl start
[root@localhost bin]# systemctl stop firewalld
安装依赖环境。
[root@localhost src]# yum -y install ncurses-devel
[root@localhost src]# yum -y install cmake
创建用户。
[root@localhost src]# groupadd mysql
[root@localhost src]# useradd -s /sbin/nologin -M -g mysql mysql
编译安装mysql。
[root@localhost src]# tar zxf mysql-5.5.22.tar.gz -C /data/server/
[root@localhost src]# cd /data/server/mysql-5.5.22/
[root@localhost mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/data/server/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
[root@localhost mysql-5.5.22]# make -j4 && make install
设置数据库目录的权限并建立配置文件
[root@localhost mysql-5.5.22]# chown -R mysql:mysql /data/server/mysql/
[root@localhost mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@localhost mysql-5.5.22]# /data/server/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/server/mysql --datadir=/data/server/mysql/data/
添加系统服务
[root@localhost mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.5.22]# chmod a+x /etc/init.d/mysqld
[root@localhost mysql-5.5.22]# chkconfig --add mysqld
设置环境变量
[root@localhost mysql-5.5.22]# vim /etc/profile
echo "PATH=$PATH:/data/server/mysql/bin" /etc/profile
[root@localhost mysql-5.5.22]# . /etc/profile
[root@localhost mysql-5.5.22]# systemctl start mysqld
登录mysql数据库验证
[root@localhost mysql-5.5.22]# cd /data/server/mysql/bin/
[root@localhost bin]# ./mysql
mysql> create database wikidb;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on wikidb.* to root;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on wikidb.* to root@localhost;
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on wikidb.* to wikiuser;
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on wikidb.* to wikiuser@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> set password for wikiuser@localhost=password('123');
Query OK, 0 rows affected (0.00 sec)
mysql> quit
安装依赖环境。
[root@localhost bin]# cd /usr/local/src/
[root@localhost src]# yum -y install bzip2-devel libcurl-devel readline-devel openssl-devel libxml2-devel
[root@localhost src]# tar zxf libmcrypt-2.5.8.tar.gz -C /data/server/
[root@localhost src]# cd /data/server/libmcrypt-2.5.8/
[root@localhost libmcrypt-2.5.8]# ./configure
[root@localhost libmcrypt-2.5.8]# make && make install
编译安装php。
[root@localhost libmcrypt-2.5.8]# cd /usr/local/src/
[root@localhost src]# tar zxf php-7.2.0.tar.gz -C /data/server/
[root@localhost src]# cd /data/server/php-7.2.0/
[root@localhost php-7.2.0]# ./configure --prefix=/data/server/php --enable-fpm --with-apxs2=/data/server/httpd/bin/apxs --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache=no --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear
[root@localhost php-7.2.0]# make && make install
复制配置文件
[root@localhost php-7.2.0]# cp php.ini-development /data/server/php/etc/php.ini
[root@localhost php-7.2.0]# cp /data/server/php/etc/php-fpm.conf.default /data/server/php/etc/php-fpm.conf
[root@localhost php-7.2.0]# cp /data/server/php/etc/php-fpm.d/www.conf.default www.conf
创建用户。
[root@localhost php-7.2.0]# groupadd www
[root@localhost php-7.2.0]# useradd -s /sbin/nologin -M -g www www
添加系统服务
[root@localhost php-7.2.0]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.2.0]# chmod +x /etc/init.d/php-fpm
启动服务。
[root@localhost php-7.2.0]# cd /data/server/php/etc/php-fpm.d/
[root@localhost php-fpm.d]# ls
www.conf.default
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# /etc/init.d/php-fpm start
Starting php-fpm done
修改配置文件
[root@localhost php-fpm.d]# vim /data/server/httpd/conf/httpd.conf
53 #LoadModule php7_module modules/libphp7.so 注释掉此行
54 LoadModule php7_module modules/libphp7.so 添加此行
98 ServerName www.example.com:80 删除#号
166
167 DirectoryIndex index.php index.html 添加index.php
308 AddType application/x-compress .Z
309 AddType application/x-gzip .gz .tgz
310 AddType application/x-httpd-php .php 添加此行
编辑一个lnmp环境测试页面
[root@localhost ~]# vim /data/server/httpd/htdocs/zx.php
[root@localhost ~]# cd /data/server/httpd/bin/
[root@localhost bin]# apachectl restart
[root@localhost src]# tar zxf mediawiki-1.30.0.tar.gz.gz -C /data/server/
[root@localhost src]# cd /data/server/
[root@localhost server]# mv mediawiki-1.30.0 /data/server/httpd/htdocs/wiki2