#Linux阶段学习重点
1.Linux常用命令
2.Linux系统管理
3.Linux网络应用
4.LAMP产品级环境搭建
5.Apache服务器配置
6.LNMP环境快速部署-Nginx服务器配置
##目标
1.具有使用Linux系统进行开发的能力
2.进行Linux服务器常规管理运维
##第四天 LAMP产品级环境搭建
1.辅助型软件包安装
2.Apache服务安装
3.MySQL服务安装
4.PHP软件安装
5.收尾工作
###一.辅助型软件包安装
1.安装前准备:1)恢复快照 初始化安装 2)设置IP 关闭SELINUX
2.配置yum源 安装gcc gcc-c++
yum -y install gcc gcc-c++
3.关闭防火墙 setup
4.传输源码包到Linux系统 解压缩
vim tar.sh
chmod 777 tar.sh
./tar.sh
cd /lamp
5.查看磁盘空间
df -h
安装libxml2
yum -y install python-devel
cd /lamp/libxml2-2.9.1
./configure --prefix=/usr/local/libxml2/
make
make install
安装libmcrypt
cd /lamp/libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt/
make
make install
安装libltdl,也在libmcrypt源码目录中,非新软件
cd /lamp/libmcrypt-2.5.8/libltdl
./configure --enable-ltdl-install
make
make install
安装mhash
cd /lamp/mhash-0.9.9.9
./configure
make
make install
安装mcrypt
cd /lamp/mcrypt-2.6.8
LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib \
./configure --with-libmcrypt-prefix=/usr/local/libmcrypt
make
make install
安装zlib
cd /lamp/zlib-1.2.3
./configure
make
make install
安装libpng
cd /lamp/libpng-1.2.31
./configure --prefix=/usr/local/libpng
make
make install
安装jpeg6
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man/man1
cd /lamp/jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
安装freetype
cd /lamp/freetype-2.3.5
./configure --prefix=/usr/local/freetype/
make
make install
###二. Apache服务安装
安装Apache
cp -r /lamp/apr-1.4.6 /lamp/httpd-2.4.7/srclib/apr
cp -r /lamp/apr-util-1.4.1 /lamp/httpd-2.4.7/srclib/apr-util
cd /lamp/pcre-8.34
./configure && make && make install
cd /lamp/httpd-2.4.7
./configure --prefix=/usr/local/apache2/ --sysconfdir=/usr/local/apache2/etc/ --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared
make && make install
启动 测试
/usr/local/apache2/bin/apachectl start
ps aux | grep httpd
netstat –tlun | grep :80
浏览器 192.168.184.252 It works!
开机自启动
vim /etc/rc.local
/usr/local/apache2/bin/apachectl start
###三. MySQL服务安装
安装ncurses
yum -y install ncurses-devel
安装cmake和bison
yum -y install cmake bison
安装MySQL
1. 编译安装
groupadd mysql
useradd -g mysql mysql
cd /lamp/mysql-5.5.48
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
make && make install
2.配置
cd /usr/local/mysql/
chown -R mysql .
chgrp -R mysql .
/usr/local/mysql/scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql
3.启动
/usr/local/mysql/bin/mysqld_safe --user=mysql &
vim /etc/rc.local
/usr/local/mysql/bin/mysqld_safe --user=mysql &
/usr/local/mysql/bin/mysqladmin -uroot password 123456
/usr/local/mysql/bin/mysql -u root -p
###四. PHP软件安装
yum -y install "libtool*"
安装php
cd /lamp/php-7.0.7
./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets --with-pdo-mysql=/usr/local/mysql --with-gd --without-pear
make && make install
配置php.ini文件
mkdir /usr/local/php/etc/
cp /lamp/php-7.0.7/php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/apache2/etc/httpd.conf
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start
vim /usr/local/apache2/htdocs/test.php
浏览器测试 192.168.184.252/test.php
环境变量
vim /etc/profile
export PATH="/usr/local/php/bin:$PATH"
export PATH="/usr/local/mysql/bin:$PATH"
export PATH="/usr/local/apache2/bin:$PATH"
source /etc/profile
安装openssl (扩展模块编译安装方法)
yum -y install openssl-devel 必须安装
cd /lamp/php-7.0.7/ext/openssl
mv config0.m4 config.m4 否则报错:找不到config.m4
/usr/local/php/bin/phpize
./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config
make
make install
vim /usr/local/php/etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20151012/"
extension="openssl.so";
apachectl stop
apachectl start
浏览器 192.168.184.252/test.php 查看openssl 模块
安装phpMyAdmin
cp -r /lamp/phpMyAdmin-4.1.4-all-languages /usr/local/apache2/htdocs/phpmyadmin
cd /usr/local/apache2/htdocs/phpmyadmin
cp config.sample.inc.php config.inc.php
vim config.inc.php
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'http';
测试 192.168.184.252/phpmyadmin/index.php
###作业
1.安装LAMP环境 至少成功一次
2.安装Memcache扩展和服务
3.写程序 PHP 连接数据库 写表单
4.搭建Samba服务 共享/usr/local/apache2/htdocs/目录
5.预习Apache服务配置 看一遍
6.课外 项目迁移 1.源代码复制到Linux服务器网站根目录
2.数据库迁移 导入到Linux MySQL里面
3.修改配置文件
vim /usr/local/php/etc/php.ini
display_errors=on
网站配置文件修改
define('ROOT','http://192.168.184.174/bbsV0.1');
...
define('PWD','123456');