- A+
所属分类:linux技术
1. 安装Mysql-5.6.40
软件包存放目录:
/usr/local/src/
1.切换到软件包目录操作
cd /usr/local/src/
使用wget命令下载所需的编译包
2.解压操作
tar zxvf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
mkdir /usr/local/mysql #创建
- 注:查看是否有 /usr/local/mysql这个文件夹,
- 如果没有请创建这个文件夹 mkdir /usr/local/mysql
cd mysql-5.6.43-linux-glibc2.12-x86_64
mv * /usr/local/mysql
将解压出来的文件移到/usr/local/mysql文件夹内
mkdir -p /data/mysql
创建数据库存放位置的文件夹
useradd -s /sbin/nologin mysql
3.创建mysql用户,更改文件夹权限
useradd mysql groupadd mysql
chown -R mysql:mysql /data/mysql #更换所有者操作
4.安装依赖操作
yum -y install perl-Module-Install
5.开始安装mysql操作
cd /usr/local/mysql ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql #如果成功/data/mysql目录下将会有文件和目录
1.2 配置mysql
1.将mysql源码包内的默认配置文件放入并命名 /etc/my.cnf
cd /usr/local/mysql cp support-files/my-default.cnf /etc/my.cnf
2.进入并修改/etc/my.cnf文件
vim /etc/my.cnf basedir = /usr/local/mysql # 源码存放目录 datadir = /data/mysql # 上文数据库存放目录 port = 3306 # 端口 server_id = 128 # 服务id socket = /tmp/mysql.sock # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M
3.复制文件,修改权限,修改配置
cp support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld vim /etc/init.d/mysqld
修改:
datadir=/data/mysql
4.设置开机自启和启动服务
chkconfig --add mysqld chkconfig mysqld on service mysqld on
2. Apache-2.4.54
软件包存放目录:
/usr/local/src/
1.获取并解压源码包
cd /usr/local/src wget http://....httpd-2.4.54.tar.gz wget http://....apr-1.7.0.tar.gz wget http://....apr-util-1.6.1.tar.gz tar zxvf httpd-2.4.54.tar.gz tar zxvf apr-1.7.0.tar.gz tar zxvf apr-util-1.6.1.tar.gz
2.安装依赖包
yum -y install expat-devel libxml2-devel pcre pcre-devel
3.编译并安装apr
cd /usr/local/src/apr-1.7.0 ./configure --prefix=/usr/local/apr make && make install
4.编译并安装apr-util
cd /usr/local/src/apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install
5.编译并安装apache,如果安装成功那么/usr/local/apache2.4目录下将会有文件和目录
cd /usr/local/src/httpd-2.4.54 ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most make && make install
- 注:如果需要重新编译,需要使用
- make clean
- 清除之前的缓存
3.PHP-5.6.40
软件包存放目录:
/usr/local/src/
1.获取并解压php源码包
cd /usr/local/src wget http://...php-5.6.40.tar.gz tar zxvf php-5.6.40.tar.gz
获取下面的依赖包
yum -y install libxml2 openssl openssl-devel bzip2 bzip2-devel yum -y install libjpeg libjpeg-devel libpng libpng-devel
2.安装依赖包
rpm -ivh freetype-2.8-14.el7_9.1.x86_64.rpm rpm -ivh freetype-devel-2.8-14.el7_9.1.x86_64.rpm rpm -ivh libmcrypt-2.5.8-13.el7.x86_64.rpm rpm -ivh libmcrypt-devel-2.5.8-13.el7.x86_64.rpm
3. 编译并安装
./configure -prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysq1=/usr/1ocal/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif make && make install
复制配置文件
cd /usr/local/src/php-5.6.40 cp php.ini-production /usr/local/php/etc/php.ini
4.进行结合
配置httpd支持php
修改
vim /usr/local/apache2.4/conf/httpd.conf
修改
#ServerName www.example.com:80 -> ServerName www.example.com:80 #去除注释
进行删除、添加、修改操作,并开启apache
#添加 <Directory /> AllowOverride none Require all denied </Directory> -> <Directory /> AllowOverride none Require all granted </Directory> #修改 (在AddType application/x-gzip .gz .tgz 下) AddType application/x-httpd-php .php # 1.进入apache的配置文件并修改 <IfModule dir_module> DirectoryIndex index.html </IfModule> -> <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> # 2.检验apache配置文件是否正确,正确会显示Syntax OK /usr/local/apache2.4/bin/apachectl -t # 3.开启apache /usr/local/apache2.4/bin/apachectl start
检测LAMP环境是否正确
1.检查apache是否正确
curl localhost
2.检查php是否正确
vim /usr/local/apache2.4/htdocs/test.php <?php echo"php 123";?>
输出结果应为 123
curl localhost/test.php
3.检查mysql是否正确
cd /usr/local/mysql/bin/ ./mysql
lamp部署完毕