centos 7
vmware
mysql-5.6.31
httpd-2.4.37
php-7.2.17
删除原来的yum源
[root@centos7 ~]#cd /pos.d/[root@pos.d]#po po po po po po po[root@pos.d]#mkdir repo.bak[root@pos.d]#mv *.repo repo.bak/[root@pos.d]#lsrepo.bak
下载阿里云的centos源和epel源
镜像站
wget -O /pos.po .repo
wget -O /pos.po .repo
配置完成之后查看一下是这样的
[root@pos.d]#ls
po po repo.bak
安装编译需要的工具包
yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel net-tools vim -y
yum install cmake make pcre-devel ncurses-devel openssl-devel libcurl-devel -y
yum install libxml2-devel libjpeg-devel libpng-devel freetype-devel libcurl-devel wget -y
linux很多软件的运行,依赖于操作系统本身的一些软件支持 yum groupinstall "Development tools" -y 桌面开发工具包(图形化相关包) yum groupinstall "Desktop Platform Development" -y
关闭firewalld,selinux
systemctl stop firewalld
systemctl disable firewalld
关闭selinux
查看是否关闭,如下是关闭
grep -i 'selinux=' /etc/selinux/config
# SELINUX= can take one of these three values:
SELINUX=disabled
如果没有关闭
关于压缩的报错
是一个tar进行归档的归档文件,调用gzip命令压缩
tar -zxvf 解压缩的时候
前提是机器有tar命令 -x参数调用tar命令
而且得有gzip命令才能去解压缩gz后缀 -z参数调用gzip命令
解压缩xxx.tar.bz2
tar -xf xxx.tar.bz2
报错了,提示找不到bzip2这个命令
解决办法是,安装bzip2这个命令
yum install bzip2-devel
【先装好工具包,再去编译安装】
yum install openssl-devel ncurses-devel
mysql的安装版本
软件版本 安装目录 数据目录 端口
mysql-5.6.31 /usr/local/mysql /usr/local/mysql/data 3306
创建mysql用户,用于给mysql的数据,进程,设置相关的user属主
useradd -r -s /sbin/nologin mysql
查看一下
id mysql
uid=998(mysql) gid=996(mysql) groups=996(mysql)
创建一个指定的源码目录,下载对应软件
[root@pos.d]#cd /usr/local ; mkdir software-mysql;cd software-mysql[root@centos7 software-mysql]#wget -c .6/mysql-5.6.
查看源码,解压缩
[root@centos7 software-mysql]#ls
mysql-5.6.
解压缩,进入mysql源代码目录
[root@centos7 software-mysql]#tar -zxf mysql-5.6.
创建 数据库文件存储路径,这里设置为
mkdir -p /usr/local/mysql/data
进行编译配置
[root@centos7 mysql-5.6.50]#vim cmake.sh[root@centos7 mysql-5.6.50]#cat cmake.sh
cmake .
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/
-DMYSQL_DATADIR=/usr/local/mysql/data
-DENABLED_LOCAL_INFILE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DMYSQL_TCP_PORT=3306
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DWITH_EXTRA_CHARSETS=all
-DMYSQL_USER=mysql
这些配置参数是用于编译和安装MySQL数据库的选项,每个参数的含义如下:
- `CMAKE_INSTALL_PREFIX=/usr/local/mysql/`:指定安装路径,这里设置为`/usr/local/mysql/`。
- `MYSQL_DATADIR=/usr/local/mysql/data`:指定数据库文件存储路径,这里设置为`/usr/local/mysql/data`。
- `ENABLED_LOCAL_INFILE=1`:启用本地加载文件功能,允许从客户端加载本地文件到MySQL服务器。
- `WITH_INNOBASE_STORAGE_ENGINE=1`:启用InnoDB存储引擎,InnoDB是MySQL的默认存储引擎,提供了事务支持和行级锁等功能。
- `MYSQL_TCP_PORT=3306`:指定MySQL服务器的TCP端口号,这里设置为`3306`。
- `DEFAULT_CHARSET=utf8mb4`:设置默认字符集为`utf8mb4`,支持存储更广泛的Unicode字符。
- `DEFAULT_COLLATION=utf8mb4_general_ci`:设置默认排序规则为`utf8mb4_general_ci`,适用于大小写不敏感的比较。
- `WITH_EXTRA_CHARSETS=all`:启用所有附加字符集,包括ascii、big5、cp1250等等。
- `MYSQL_USER=mysql`:指定MySQL服务器运行所使用的用户为`mysql`。通过设置这些配置参数,可以根据特定的需求编译和安装MySQL,并配置一些基本的数据库设置。
执行这个脚本,或者直接输入命令
如果执行该脚本 使用 bash cmake.sh 即可!
编译安装mysql
make && make install
配置myql的PATH变量即可
[root@centos7 ~]#vim /etc/profile#最底行写入export PATH=$PATH:/usr/local/mysql/bin/[root@centos7 ~]#tail -1 /etc/profile
export PATH=$PATH:/usr/local/mysql/bin/
使其生效,重新登录,或者手动source读取该文件配置
[root@centos7 ~]#source /etc/profile[root@centos7 ~]#echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin/
关于MySQL的客户端登陆命令
总结报错
[lamp-server root ~]$ mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
linux的软件启动后,可以有2种形式,提供客户端去访问
ip:port形式,如0.0.0.0:3306,网络连接方式
socket本地套接字文件形式, 本地进程套接字文件,启动mysql,提供它的本地连接进程文件,/tmp/mysql.sock,只要这个文件存在,mysql就是启动的
使用客户端命令
mysql -uroot -p
修改MySQL的文件权限,属主,属组
[root@centos7 ~]#chown -R mysql:mysql /usr/local/mysql/[root@centos7 ~]#ll /usr/local/mysql/
total 224
drwxr-xr-x. 2 mysql mysql 4096 Mar 14 12:33 bin
drwxr-xr-x. 3 mysql mysql 18 Mar 14 12:33 data
drwxr-xr-x. 2 mysql mysql 55 Mar 14 12:33 docs
drwxr-xr-x. 3 mysql mysql 4096 Mar 14 12:33 include
drwxr-xr-x. 3 mysql mysql 4096 Mar 14 12:33 lib
-rw-r--r--. 1 mysql mysql 198041 Sep 23 2020 LICENSE
drwxr-xr-x. 4 mysql mysql 30 Mar 14 12:33 man
drwxr-xr-x. 10 mysql mysql 4096 Mar 14 12:33 mysql-test
-rw-r--r--. 1 mysql mysql 587 Sep 23 2020 README
drwxr-xr-x. 2 mysql mysql 30 Mar 14 12:33 scripts
drwxr-xr-x. 28 mysql mysql 4096 Mar 14 12:33 share
drwxr-xr-x. 4 mysql mysql 4096 Mar 14 12:33 sql-bench
drwxr-xr-x. 2 mysql mysql 136 Mar 14 12:33 support-files
对数据库初始化,生成一些必备的数据文件
mysql设置账号密码需要一个库,数据表需要存储,
检查是否有旧的mysql数据文件残留
移除当前的mysql配置文件。/etc/myf
mv /etc/myf /etc/myf.bak
使用初始化mysql数据命令操作
进入到mysql的安装目录,找到他的初始化数据,执行如下安装命令
[root@centos7 mysql]#cd /usr/local/mysql/
[root@centos7 mysql]#./scripts/mysql_install_db --user=mysql
手动创建启动脚本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
此时使用service命令,会去读取/etc/init.d目录下的脚本文件,启动mysql
[root@centos7 mysql]#service mysql start
Starting MySQL. SUCCESS!
查看状态和启动的端口
[root@centos7 mysql]#service mysql statusSUCCESS! MySQL running (78285)[root@centos7 mysql]#netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1302/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3008/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1073/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1359/master
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 57625/sshd: root@pt
tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN 57813/sshd: root@pt
tcp 0 0 0.0.0.0:10086 0.0.0.0:* LISTEN 3008/sshd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 645/rpcbind
tcp6 0 0 :::22 :::* LISTEN 3008/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1073/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1359/master
tcp6 0 0 ::1:6011 :::* LISTEN 57625/sshd: root@pt
tcp6 0 0 ::1:6012 :::* LISTEN 57813/sshd: root@pt
tcp6 0 0 :::10086 :::* LISTEN 3008/sshd
tcp6 0 0 :::3306 :::* LISTEN 78285/mysqld
tcp6 0 0 :::111 :::* LISTEN 645/rpcbind
udp 0 0 0.0.0.0:5353 0.0.0.0:* 596/avahi-daemon: r
udp 0 0 0.0.0.0:808 0.0.0.0:* 645/rpcbind
udp 0 0 192.168.122.1:53 0.0.0.0:* 1302/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 1302/dnsmasq
udp 0 0 0.0.0.0:33373 0.0.0.0:* 596/avahi-daemon: r
udp 0 0 0.0.0.0:111 0.0.0.0:* 645/rpcbind
udp6 0 0 :::808 :::* 645/rpcbind
udp6 0 0 :::111 :::* 645/rpcbind
修改mysql的密码.
mysql登陆语法注意事项 | |
-u -p | 参数后面不得有空格,是直接跟上用户名或者密码的 |
-p | 不写密码的话,会让你交互式输入密码 |
password | 跟上新的mysql密码 |
修改root密码为 yuanlai0224
/usr/local/mysql/bin/mysqladmin -u root -p password
为了不让别人看到你的密码,请清空历史记录
history -c
history -w
登陆mysql
[root@centos7 mysql]#mysql -u root -pyuanlai0224
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 9
Server version: 5.6.50 Source distributionCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or 'h' for help. Type 'c' to clear the current sql> select version();
+-----------+
| version() |
+-----------+
| 5.6.50 |
+-----------+
1 row in set (0.01 sec)mysql>
创建并进入目录
[root@centos7 mysql]#cd /usr/local/[root@centos7 local]#mkdir software-apache[root@centos7 local]#cd software-apache
下载源码,且解压缩,然后编译安装
wget -c .5.2.tar.bz2
[root@centos7 software-apache]#tar -xf apr-1.5.2.tar.bz2 [root@centos7 software-apache]#ls
apr-1.5.2 apr-1.5.2.tar.bz2
可能由于其1.5.2的bug,存在一个配置错误,需要修改如下的一个配置参数
并且这里需要修改一个配置
进入目录
[root@centos7 software-apache]#cd apr-1.5.2/[root@centos7 apr-1.5.2]#ls
apr-config.in buildconf dso NOTICE support
apr.dep f emacs-mode LICENSE NWGNUmakefile tables
apr.dsp build-outputs.mk encoding locks passwd test
apr.dsw CHANGES file_io Makefile.in poll threadproc
apr.mak helpers Makefile.win random time
apr.pc.in config.layout include memory README tools
apr.spec configure libapr.dep misc ake user
atomic configure.in libapr.dsp mmap shmem
build docs libapr.mak network_io strings
修改参数
[root@centos7 apr-1.5.2]#vim configure
29605 RM='$RM -f'
29605 代表29605行 进入vim之后使用底线,,模式输入该数字即可找到该行,参考修改
为 RM='$RM -f'
执行配置脚本
[root@centos7 apr-1.5.2]# ./configure
开始编译安装
[root@centos7 apr-1.5.2]# make
[root@centos7 apr-1.5.2]# make install
==必须的基础库apr-util==
until 意思就是工具包的意思
下载,解压,配置,编译,编译且安装
1 切换目录并下载
[root@centos7 apr-1.5.2]#cd ..[root@centos7 software-apache]#wget -c .5.4.tar.bz2
解压
tar -xf apr-util-1.5.4.tar.bz2
2 进入目录 配置
cd apr-util-1.5.4./configure --with-apr=/usr/local/apr/bin/apr-1-config
3 编译
mkae
4 安装
make install
5 此时apr和apr-util这俩工具,就生成了一些基础的linux文件,需要告诉linux系统,多了一些这些工具,linux才能够读取到他们的信息,然后apache才能用
把编译安装的apr工具,写入系统的动态库配置文件中,然后更新这些基础动态库即可
echo "/usr/local/apr/lib/" >> /etc/f
执行ldconfig命令,让linux能找到你安装的这个apr即可
ldconfig
下载,解压,配置,编译,编译且安装
1 切换目录并下载
[root@centos7 software-apache]#cd /usr/local/software-apache[root@centos7 software-apache]# wget -c .4.37.tar.bz2
解压缩
tar -xf httpd-2.4.37.tar.bz2
2 配置脚本,由于参数过多,写成sh文件
apache或者nginx都提供了模块的概念,所有的功能都是以模块,插件的形式提供的
如果你不装插件,就缺少某个功能
[root@centos7 httpd-2.4.37]#vim config.sh[root@centos7 httpd-2.4.37]#cat config.sh
./configure
--enable-modules=all
--enable-mods-shared=all
--enable-so
--enable-rewrite
--with-pcre
--enable-ssl
--with-mpm=prefork
--with-apr=/usr/local/apr/bin/apr-1-config
--with-apr-util=/usr/local/apr/bin/apu-1-config[root@centos7 httpd-2.4.37]#chmod +x config.sh
这些配置参数是用于编译和安装Apache HTTP Server的选项,每个参数的含义如下:- `--enable-modules=all`:启用所有模块,包括标准模块和第三方扩展模块。- `--enable-mods-shared=all`:启用所有共享模块,允许在运行时动态加载模块。- `--enable-so`:启用动态共享对象(DSO)支持,允许在运行时加载模块。- `--enable-rewrite`:启用URL重写模块,该模块允许在Apache服务器上执行URL重写规则,通常用于重定向和URL重写。- `--with-pcre`:使用Perl兼容正则表达式库(PCRE)支持,用于处理正则表达式匹配。- `--enable-ssl`:启用SSL支持,允许使用HTTPS协议进行安全的加密通信。- `--with-mpm=prefork`:指定使用prefork MPM(Multi-Processing Module),这是Apache服务器的一种处理请求的方式。- `--with-apr=/usr/local/apr/bin/apr-1-config`:指定APR(Apache Portable Runtime)的路径,APR是Apache项目提供的跨平台库。- `--with-apr-util=/usr/local/apr/bin/apu-1-config`:指定APR-util的路径,APR-util是一组提供了对APR的额外功能支持的库。通过设置这些配置参数,可以编译和安装具有特定模块和功能的Apache HTTP Server,以满足个性化的需求。
3 执行该脚本,开始配置
./config.sh
4 编译且安装
注意先后顺序
make
make install
5 检查apache的安装路径
[root@centos7 httpd-2.4.37]#ls /usr/local/apache2/
bin build cgi-bin conf error htdocs icons include logs man manual modules[root@centos7 httpd-2.4.37]#ls /usr/local/apache2/bin
ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve
apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs[root@centos7 httpd-2.4.37]#
6 修改apache的配置文件,加载php的模块
[root@centos7 httpd-2.4.37]#ls /usr/local/apache2/conf/
extra f magic pes original
记录下目录地址
/usr/local/software-apache/httpd-2.4.37
因此你是缺少php的模块的!!!
==进行4.0==在进行如下步骤
==---------------------------------------------------------------------------==
:red_circle:注意,先装好php,再来修改apache配置文件
==----------------------------------------------------------------------==
cd /usr/local/software-php/php-7.2.17
vim /usr/local/apache2/f
#1.修改apache配置文件,找到你的安装路径
配置语言支持
159 LoadModule negotiation_module modules/mod_negotiation.so #去掉这一行的注释
482 Include conf/f #打开此选项,扩展配置文件就生效了#让apache支持php语言的插件,当有用户访问php程序时,apache自动转发给php程序去解析。
166 LoadModule php7_module modules/libphp7.so #找到这一行,然后在下面添加语句#添加以下两行意思是以.php结尾的文件都认为是php程序文件,注意两句话的.php前面都是有一个空格的
#也就是长这样
166 LoadModule php7_module modules/libphp7.so
167 AddHandler php7-script .php
168 AddType text/html .php#添加一个默认的网站首页,添加为php的文件
263 #
264 # DirectoryIndex: sets the file that Apache will serve if a directory
265 # is requested.
266 #
267 <IfModule dir_module>
268 DirectoryIndex index.php index.html
269 </IfModule>
270#关于网站默认的首页html文件,存放的目录路径,由以下参数控制
230 # DocumentRoot: The directory out of which you will serve your
231 # documents. By default, all requests are taken from this directory, but
232 # symbolic links and aliases may be used to point to other locations.
233 #
234 DocumentRoot "/usr/local/apache2/htdocs"
235 <Directory "/usr/local/apache2/htdocs">212 ample:80 #注释掉改行,应该就是在212附近,找找就OK了
5.修改apache 的子配置文件,语言conf
vim /usr/local/apache2/conf/f
19 DefaultLanguage zh-CN75 # Just list the languages in decreasing order of preference. We have76 # more or less alphabetized them here. You probably want to change this.77 #78 LanguagePriority zh-CN en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv tr zh-CN zh-TW
6 启动apache即可
1.生成apache的执行命令
cp /usr/local/apache2/bin/apachectl /etc/init.d/apache2.启动即可
service apache start3.如果你要创建apache的systemctl管理脚本,可以用如下技巧用另一台机器,yum install httpd 查看yum给你生成的httpd.service脚本,然后模仿该脚本写法,修改你编译的http路径即可
会报错
[root@centos7 php-7.2.17]# service apache start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:febe:8baa. Set the 'ServerName' directive globally to suppress this message httpd (pid 46516) already running
这个可以启动,不知道什么错误
[root@centos7 php-7.2.17]# netstat -tunlp|grep 80 tcp6 0 0 :::80
7 查看apache是否支持php
vim /usr/local/apache2/htdocs/index.php
冲冲冲
<?phpphpinfo();
?>
8 至此,lamp的linux环境就准备好了
网页访问IP地址就可以访问页面了
==----------------------------------------------------------------------------==
:red_circle:注意,先装好php,再去修改apache配置文件
==----------------------------------------------------------------------==
1 进入安装目录
cd /usr/local/
2 创建php软件安装目录文件夹
mkdir software-php
3 安装php
wget -c .2.
4 解压
tar -xf php-7.2.
5 进入 解压后的目录
cd php-7.2.17/
6 配置编译过程
./configure
--with-apxs2=/usr/local/apache2/bin/apxs
--with-mysqli
--with-pdo-mysql
--with-zlib
--with-curl
--enable-zip
--with-gd
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--enable-sockets
--with-xmlrpc
--enable-soap
--enable-opcache
--enable-mbstring
--enable-mbregex
--enable-pcntl
--enable-shmop
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--enable-calendar
--enable-bcmath
--with-apxs2=/usr/local/apache2/bin/apxs
:指定Apache可执行文件的路径,用于与Apache服务器进行模块的关联和加载。
--with-mysqli
:启用MySQLi扩展,用于与MySQL数据库进行交互。
--with-pdo-mysql
:启用PDO MySQL驱动,用于使用PHP的PDO扩展与MySQL数据库进行交互。
--with-zlib
:启用Zlib支持,用于对数据进行压缩和解压缩。
--with-curl
:启用cURL库支持,用于进行URL的数据传输和通信。
--enable-zip
:启用Zip扩展,用于创建和操作Zip存档文件。
--with-gd
:启用GD库支持,用于处理图像操作,如缩放、裁剪、旋转等。
--with-freetype-dir
:指定FreeType字体库的路径,用于支持GD库中的TrueType字体渲染。
--with-jpeg-dir
:指定JPEG库的路径,用于支持GD库中的JPEG图像格式处理。
--with-png-dir
:指定PNG库的路径,用于支持GD库中的PNG图像格式处理。
--enable-sockets
:启用Socket扩展,允许使用PHP进行网络套接字通信。
--with-xmlrpc
:启用XML-RPC支持,允许使用PHP进行XML-RPC协议通信。
--enable-soap
:启用SOAP支持,允许使用PHP进行SOAP协议通信。
--enable-opcache
:启用Zend OpCache扩展,用于提高PHP脚本的性能和执行速度。
6 编译
make
7 安装
make install
1 下载博客源码
cd /opt
wget -c .7.3-zh_
mkdir wordpress ; cd wordpress
mv ../wordpress-4.7.3-zh_ .
2 解压缩
tar -zxvf wordpress-4.7.3-zh_
放入到httpd的网页根目录中去
mv wordpress/* /usr/local/apache2/htdocs/
3 修改wordpress源码文件的属主、属组,防止权限有问题
由于是静态文件做了更改,你不需要重启httpd,直接访问该网站即可
chown -R daemon.daemon /usr/local/apache2/htdocs/
1 发现该博客需要写入数据库,wordpress,需要你先创建这个数据库
登录数据库,操作
[root@centos7 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.6.50 Source distributionCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or 'h' for help. Type 'c' to clear the current sql> create database wordpress default charset utf8;
Query OK, 1 row affected (0.01 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| wordpress |
+--------------------+
5 rows in set (0.00 sec)mysql> exit
Bye
2 浏览器访问IP
3 点击提交后 进行安装
4 填写信息
5 进入wordpress
写文章并发布
点击查看文章后会出现
未知的bug,没有搞明白
6 重新访问ip
本文发布于:2024-02-03 01:54:06,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170689644247865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |