本人将所需要的rpm包都下载完成之后,直接使用脚本的形式安装。
如果需要自己下载rpm包的话,请下载如下包
yum install -y libxml2-devel \
tar \
gcc \
expat-devel \
bzip2-devel \
pcre-devel \
openssl-devel \
perl-devel \
sqlite-devel \
libcurl-devel \
libpng-devel \
libjpeg-devel \
freetype \
freetype-devel \
readline-devel
首先创建一个目录
mkdir lamp
下载
阿里云盘分享
下载到本地的目录中,之后在该目录执行以下的脚本
部署脚本如下
# step1
echo "开始安装lamp所需的依赖包"
yum -y localinstall *.rpm
echo "安装lamp所需的依赖包已完成"# step2
echo "编译安装apr"
tar xf apr-1.7.4.tar.gz
cd apr-1.7.4/
./configure --prefix=/usr/local/apr ; echo $?
make -j2 ; make install ; echo $? ; cd ..
# step3
echo "开始编译安装apr-util"
tar xf apr-util-1.6.3.tar.gz
cd apr-util-1.6.3/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr ; echo $?
make -j2 && make install ; echo $? ; cd ..
echo "编译安装apr-util已完成"# step4
echo "开始编译安装httpd2.4.58"
tar xf httpd-2.4.58.tar.bz2
cd httpd-2.4.58
./configure --prefix=/usr/local/apache \
--enable-so --enable-rewrite --enable-ssl \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util ; echo $?
make -j2 ; echo $?
make install ;echo $? ;cd ..
echo "编译安装httpd2.4.58完成"sed '1s@.*@#!/usr/bin/perl -w@' /usr/local/apache/bin/apxs |head -1
sed -i '1s@.*@#!/usr/bin/perl -w@' /usr/local/apache/bin/apxs# step5
echo "开始编译安装php8.2.12"
tar xf php-8.2.12.tar.gz
cd php-8.2.12
./configure --prefix=/usr/local/php8 \
--with-config-file-path=/usr/local/php8/etc \
--with-mysql=/usr/local/mysql/ \
--with-apxs2=/usr/local/apache/bin/apxs \
--enable-fpm \
--enable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-openssl \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif \
--enable-ftp \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-opcache \
--enable-posix;echo $?
make -j2 ;echo $?
make install ;echo $?
echo "配置php8.2.12完成"# step6
echo "配置php8.2.12"php=$(find / -type f -name php.ini-development)
find / -type f -name php.ini-development
cp -av $php /usr/local/php8/lib/php.ini
cp -av /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf
cp -av /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf
useradd -s /sbin/nologin apache -M
echo "配置php8.2.12完成"
脚本完成之后,修改apache配置文件
vim /usr/local/apache/conf/httpd.conf
将154行的内容注释删掉,该行不一定是154行,请大家注意。
修改AllowOverride none为AllowOverride all
sed -i 's@AllowOverride none@AllowOverride all@' /usr/local/apache/conf/httpd.conf
修改用户和用户组为apache
sed -i 's@User daemon@User apache@' /usr/local/apache/conf/httpd.conf |grep -ni '^user'
sed -i 's@Group daemon@Group apache@' /usr/local/apache/conf/httpd.conf |grep -ni '^Group'
添加首页文件 index.php
sed -i 's/DirectoryIndex/& index.php/' /usr/local/apache/conf/httpd.conf
将php作为apache的模块
sed -i '/AddType application\/x-gzip .gz .tgz/aAddType application\/x-httpd-php .php' /usr/local/apache/conf/httpd.conf
sed -i '/AddType application\/x-httpd-php .php/aAddType application\/x-httpd-php .php .phtml .php3' /usr/local/apache/conf/httpd.conf
sed -i '/x-httpd-php .php .phtml .php3/aAddType application\/x-httpd-php-source .phps' /usr/local/apache/conf/httpd.conf
修改以上内容为
检测配置语法
测试php能否被apche识别
cd /usr/local/apache/htdocs/
cat >index.php<<EOF
<?php
phpinfo();
?>
EOF
启动apache服务
/usr/local/apache/bin/apachectl start
重启服务
/usr/local/apache/bin/apachectl restart
访问192.168.8.160显示可以被识别
配置woedpress
下载latest
解压
unzip latest.zip
备份源访问文件
cp -av index.html index.php /opt
将wprdpress解压后的文件全部放到访问文件夹中
cp -av wordpress/* /usr/local/apache/htdocs/
配置mysql
选择二进制包
mysql-8.2.0-linux-glibc2.17-x86_64.tar
直接执行脚本
<<ldp
服务器配置为初始化状态,并且系统为centos9系统。
执行该脚本的话首先需要将软件包放到/root下面,并且为二进制的tar xf mysql-8.2.0-linux-glibc2.17-x86_64.tar.xz包,并且本机器上面没有部署mysql
版权为LJP
转发请咨询2043565830@qq.comldpecho `cd /root/`
echo `tar xf mysql-8.2.0-linux-glibc2.17-x86_64.tar.xz`
echo `ln -sv /root/mysql-8.2.0-linux-glibc2.17-x86_64 /usr/local/mysql`
echo `groupadd mysql && useradd mysql -g mysql -s /sbin/nologin -M`
echo `mkdir -pv /data/mysql/mysql3316/{data,logs,tmp,conf,run}`
echo `chown -R mysql. /data/mysql/`
echo `chown -R mysql. /data/mysql/ /usr/local/mysql/`
echo `cat >/data/mysql/mysql3316/conf/my3316.cnf<<ldp
[client]
port = 3316
socket = /data/mysql/mysql3316/run/mysql3316.sock
default-character-set=utf8mb4
[mysql]
disable-auto-rehash
#允许通过 TAB 键提示
default-character-set = utf8mb4
connect-timeout = 10
[mysqld]
user=mysql
server-id = 3316
port = 3316
socket = /data/mysql/mysql3316/run/mysql3316.sock
pid-file = /data/mysql/mysql3316/run/mysql3316.pid
basedir = /usr/local/mysql
datadir = /data/mysql/mysql3316/data
#bind_address = 10.10.10.11
autocommit = 1
default_authentication_plugin=mysql_native_password
character-set-server=utf8mb4
explicit_defaults_for_timestamp=true
lower_case_table_names=1
back_log=103
max_connections=10000
max_connect_errors=100000
table_open_cache=512
external-locking=FALSE
max_allowed_packet=32M
sort_buffer_size=2M
join_buffer_size=2M
thread_cache_size=51
transaction_isolation=READ-COMMITTED
tmp_table_size=96M
max_heap_table_size=96M
###***logs
long_query_time = 10
slow_query_log = 1
slow_query_log_file=/data/mysql/mysql3316/logs/my3316-slow.log
#log-warnings = 1
log_error_verbosity=3
log-error = /data/mysql/mysql3316/logs/mysql3316-error.log
log_output = FILE
#参数 log_output 指定了慢查询输出的格式,默认为 FILE
#log-queries-not-using-indexes
#log-slow-slave-statements
max_binlog_size = 1G
#max_relay_log_size = 1G
# replication
log-bin=/data/mysql/mysql3316/logs/mysql-bin
#server-id=1
#binlog_format= ROW
#gtid_mode = on
#enforce_gtid_consistency = 1
#log_slave_updates = 1
#master-info-repository=TABLE
#relay-log-info-repository=TABLE
# innodb storage engine parameters
innodb_buffer_pool_size=500M
innodb_data_file_path=ibdata1:100M:autoextend:max:2G #redo
#innodb_data_file_path=ibdata1:100M:autoextend:max:5G #redo
#innodb_data_file_path=ibdata1:100M:autoextend:max:5G #redo
innodb_temp_data_file_path = ibtemp1:100M:autoextend:max:1G
#innodb_temp_data_file_path = ibtemp1:100M:autoextend:max:10G
#innodb_file_io_threads=4
#默认的是 4
innodb_log_buffer_size=16M
innodb_log_file_size=256M #undo
innodb_log_files_in_group=2
innodb_lock_wait_timeout=50
innodb_file_per_table=1
#独立表空间
ldp`
echo `chown -R mysql. /usr/local/mysql/ /data/mysql/`
echo `cd /usr/local/mysql/`
echo `/usr/local/mysql/bin/mysqld \
--defaults-file=/data/mysql/mysql3316/conf/my3316.cnf \
--datadir=/data/mysql/mysql3316/data --user=mysql \
--initialize-insecure --console ; echo $?`
echo `ln -sv /usr/local/mysql/bin/mysql /usr/bin/`
echo `yum -y install ncurses-devel`
echo `ln -sv /usr/lib64/libncurses.so.6.2 /usr/lib64/libncurses.so.5`
echo `ln -sv /usr/lib64/libtinfo.so.6.2 /usr/lib64/libtinfo.so.5`#执行完成之后,需要重新启动
#cd /usr/local/mysql/
#进入到目录里面启动
# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3316/conf/my3316.cnf &
#mysql -S /data/mysql/mysql3316/run/mysql3316.sock
脚本完成之后,启动服务
cd /usr/local/mysql/
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3316/conf/my3316.cnf &
进入mysql数据库
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3316/conf/my3316.cnf &
mysql -S /data/mysql/mysql3316/run/mysql3316.sock
创建库
在mysql上面创建库wordpress
create database wordpress;
创建wp1用户密码为Aa&%(&123456 此为web服务器登录所用的用户
create user 'wp1'@'%' identified by 'Aa&%(&123456';
创建wp1这个用户对 wordpress库的权限,并且设置所以ip地址都可登录
grant all privileges on wordpress.* to 'wp1'@'%';
刷新权限
flush privileges;
查看库
show databases;
将wordpress配置文件改名
cp -av /usr/local/apache/htdocs/wp-config-sample.php /usr/local/apache/htdocs/wp-config.php
进入/usr/local/apache/htdocs/wp-config.php文件
重启apache服务
/usr/local/apache/bin/apachectl restart
之后直接在浏览器输入地址
输入用户和密码
显示成功
完成部署