@khan-lau
2017-05-23T09:18:35.000000Z
字数 8811
阅读 1894
LAMP
系统平台:CentOS release 6.6(基础服务安装)
Apache版本:2.4.25
Php版本:5.5.38
Mysql版本:5.7.18
服务器:testweb (192.168.5.40)
公网映射IP:218.240.48.180
端口映射:12204-->22、12205-->3306、8888-->80
这里使用本地YUM源配置
[root@localhost ~]# mount -o loop /root/CentOS-* /media
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Media.repo
[local]
name=this is my server
baseurl=file:///media # 修改为光盘挂载点
enabled=1 * 改为1意为启用
gpgcheck=0
[root@localhost ~]# yum install make gcc gcc-c++
关闭selinux
[root@localhost ~]# setenforce 0
[root@localhost ~]# vi /etc/selinux/config
将enforce
改为disabled
即可
[root@localhost ~]# getenforce # 验证 enforce结果
关闭iptables
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# service iptables stop
此次安装采用源码安装部署;
[root@localhost ~]# wget http://mirror.bit.edu.cn/apache//apr/apr-1.5.2.tar.gz
如果wget没有安装, 可以用yum源安装
[root@localhost ~]# tar zxvf apr-1.5.2.tar.gz
[root@localhost ~]# cd apr-1.5.2
[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.5.2]# make && make install
注意:如果报出错误:
[apr] rm: cannot remove `libtoolT’: No such file or directory
处理方法:打开configure文件
找到30055(不同的版本可能位置不一样)
将这行代码注释掉
# $RM "$cfgfile"
然后重新编译,问题可以解决
[root@localhost ~]# wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
[root@localhost ~]# tar zxvf apr-util-1.5.4.tar.gz
[root@localhost ~]# cd apr-util-1.5.4
[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#编译安装apr-util必须指定apr的安装位置
[root@localhost apr-util-1.5.4]# make && make install
[root@localhost ~]# wget https://sourceforge.net/projects/pcre/files/pcre/8.40/pcre-8.40.tar.gz
[root@localhost ~]# tar zxvf pcre-8.40.tar.gz
[root@localhost ~]# cd pcre-8.40
[root@localhost pcre-8.40]# ./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.40]# make && make install
[root@localhost ~]# wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.25.tar.gz
[root@localhost ~]# tar zxvf httpd-2.4.25.tar.gz
[root@localhost ~]# cd httpd-2.4.25
[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/apache \
--sysconfdir=/etc/httpd \
--enable-so --enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre=/usr/local/pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--enable-mods-shared=most \
--enable-mpms-shared=all \
--with-mpm=event
[root@localhost httpd-2.4.25]# make && make install
#选项解释:
--prefix=/usr/local/apache # 指定安装目录
--enable-so #允许运行时加载DSO模块
--enable-cgi --enable-rewrite # 启用cgi协议 #启用URL重写功能
--with-zlib --with-pcre # 指定pcre的安装路径
--with-apr=/usr/local/apr #指定apr的安装路径
--with-apr-util=/usr/local/apr-util # 指定apr-util的安装路径
--enable-modules=most # 启用大多数共享模块
--enable-mpms-shared=most #启用MPM大多数参数
--with-mpm=event #指定使用的MPM的类型
[root@localhost ~]# /usr/local/apache/bin/apachectl start -f /etc/httpd/httpd.conf
[root@localhost ~]# curl http://localhost # 验证apache是否可以正常访问
注意:在启动过程中会有警告域名的问题,可以不理会,需要配置服务器名称,此次只是测试系统。
vim /etc/httpd/httpd.conf
添加
ServerName localhost:80
[root@localhost ~]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar
[root@localhost ~]# tar xvf mysql-*
[root@localhost ~]# yum install perl-Time-HiRes numactl ncurses-devel
[root@localhost ~]# yum remove mysql-libs
[root@localhost ~]# rpm -ivh mysql-commu* #(主要是安装server、client、common、devel即可)
[root@localhost ~]# mysqld_safe --skip-grant-tables --skip-networking & --无密码启动mysqld
[root@localhost ~]# mysql -uroot -p
update mysql.user set authentication_string=password('xxxxxxxx') where user='root' and Host = 'localhost';
flush privileges; --刷新权限;(很重要)
quit --退出
[root@localhost ~]# service mysqld restart 重启mysqld
set password for 'root'@'localhost'=password('xxxxxxxxx'); 重新登录后需要再次重置密码,至此成功设置完mysql密码;
[root@localhost ~]# mysql -uroot -p
use mysql;
set global validate_password_policy=0; --*变更密码复杂策略,否则修改密码会不成功
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'zhongjinshuju' WITH GRANT OPTION;
flush privileges; --刷新权限;(很重要)
create database zhongjin; 注意:mysql的字符集为默认的字符集,如果需要指定字符集需要带参数
use zhongjin;
source /root/zhongjin.sql *导入数据按实际目录;
[root@localhost ~]# yum -y install libtool libtool-libs kernel-devel \
libjpeg libjpeg-devel libpng libpng-devel libtiff libtiff-devel \
gettext gettext-devel \
libxml2 libxml2-devel \
zlib-devel net-snmp file glib2 glib2-devel bzip2 \
diff* openldap-devel bzip2-devel ncurses ncurses-devel \
curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel \
libidn libidn-devel openssl openssl-devel vim-minimal unzip \
freetype freetype-devel png jpeg zlib gd php-gd* libiconv libevent
安装顺序( libmcrypt –> mhash –> mcrypt )
[root@localhost ~]# wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
[root@localhost ~]# tar zxvf libmcrypt-2.5.8.tar.gz
[root@localhost ~]# cd libmcrypt-2.5.8
[root@localhost libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt
[root@localhost libmcrypt-2.5.8]# make && make install
[root@localhost ~]# vim /etc/ld.so.conf.d/libmcrypt.conf # 此选项为将libmcrypt的库文件能让系统找到,不然后面编译安装mcrypt会报错
添加
/usr/local/libmcrypt/lib
[root@localhost ~]# ldconfig -v # 重新加载库文件
[root@localhost ~]# wget https://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
[root@localhost ~]# tar -zxvf mhash-0.9.9.9.tar.gz
[root@localhost ~]# cd mhash-0.9.9.9
[root@localhost mhash-0.9.9.9]# ./configure --prefix=/usr/local/mhash
[root@localhost mhash-0.9.9.9]# make && make install
[root@localhost ~]# vim /etc/ld.so.conf.d/mhash.conf # 做添加mhash的库文件让系统找到,不然后面编译安装mcrypt会报错
添加:
/usr/local/mhash/lib
[root@server1 mhash-0.9.9.9]# ldconfig -v # 重新加载库文件
[root@localhost ~]# wget https://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
[root@localhost ~]# tar zxvf mcrypt-2.6.8.tar.gz
[root@localhost ~]# cd mcrypt-2.6.8
[root@localhost mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/libmcrypt/lib/:/usr/local/mhash/lib/
[root@localhost mcrypt-2.6.8]# export LDFLAGS="-L/usr/local/mhash/lib/ -I/usr/local/mhash/include/"
[root@localhost mcrypt-2.6.8]# export CFLAGS="-I/usr/local/mhash/include/"
[root@localhost mcrypt-2.6.8]# ./configure --with-libmcrypt-prefix=/usr/local/libmcrypt/
[root@localhost mcrypt-2.6.8]# make && make install
[root@localhost ~]# wget http://cn2.php.net/distributions/php-5.5.38.tar.gz
[root@localhost ~]# tar -zxvf php-5.5.38.tar.gz
[root@localhost ~]# cd php-5.5.38
[root@localhost php-5.5.38]# ./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-maintainer-zts \
--with-apxs2=/usr/local/apache/bin/apxs \
--enable-fpm \
--with-mcrypt=/usr/local/libmcrypt \
--enable-mbstring \
--enable-pdo \
--with-curl \
--disable-debug \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-mysql \
--with-mysqli \
--with-gd \
--with-jpeg-dir \
--with-freetype-dir \
--enable-calendar \
--enable-opcache=no
[root@localhost php-5.5.38]# make && make install
[root@localhost ~]# wget http://pecl.php.net/get/pthreads-2.0.5.tgz
[root@localhost ~]# tar zxvf pthreads-2.0.5.tgz
[root@localhost ~]# cd pthreads-2.0.5
[root@localhost pthreads-2.0.5]# /usr/local/php/bin/phpize
[root@localhost pthreads-2.0.5]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@localhost pthreads-2.0.5]# make && make install
[root@localhost php-5.5.38]# cp -a php.ini-production /usr/local/php/etc/php.ini #php.ini在源码的目录里面有
[root@localhost php-5.5.38]# cp -a /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #默认没有php-fpm.conf 需要copy默认配置
[root@localhost ~]# vim /usr/local/php/etc/php.ini
添加
extension=pthreads.so;
然后看看扩展安装是否成功
[root@localhost ~]# /usr/local/php/bin/php -i |grep pthreads
[root@localhost ~]# vim /etc/httpd/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
修改为:
DirectoryIndex index.php index.html
将模块行首的注释去掉
默认为/usr/local/apache/htdocs
直接可以将生产的default目录直接复制到该目录下,然后调整目录为
DocumentRoot "/usr/local/apache/htdocs/default/zhongjin"
<Directory "/usr/local/apache/htdocs/default/zhongjin">
[root@localhost ~]# cd /usr/local/apache/htdocs/default/zhongjin/web/
[root@localhost web]# mkdir -p ./runtime/logs
[root@localhost ~]# cd /usr/local/apache/htdocs/default/zhongjin/admin/
[root@localhost web]# mkdir -p ./runtime/logs
[root@localhost ~]# cd /usr/local/apache
[root@localhost apache]# chown -R daemon:daemon ./htdocs
至此整个安装过程结束。