1、编译安装apache
先安装依赖:
#yum -y install gcc* make* apr apr-util pcre apr-devel apr-util-devel pcre-devel expat-devel libxml2-devel expat-devel openssl-devel oniguruma oniguruma-devel systemd-devel sqlite-devel libcurl-devel libpng-devel
安装apr
tar zxvf apr-1.7.0.tar.gz
cd apr-1.7.0
./configure --prefix=/usr/local/apr
make && make install
安装apr-util
tar zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
安装pcre
tar zxvf pcre-8.44.tar.gz
cd pcre-8.44
./configure --prefix=/usr/local/pcre
make && make install
安装httpd
tar zxvf httpd-2.4.46.tar.gz
cd httpd-2.4.46
ls
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-mpm=prefork --enable-so --enable-rewite --enable-charset-lite
make && make install
配置httpd脚本
[root@T1 httpd]# cp bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd
#!/bin/sh
#chkconfig:35 50 50
……
chkconfig --add httpd
2、安装mysql
useradd -M -s /sbin/nologin mysql
tar zxvf mysql-5.7.32-el7-x86_64.tar.gz
mv mysql-5.7.32-el7-x86_64 /usr/local/mysqld
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb/mariadb.log
vi /etc/profile
在最后行加入:
PATH=$PATH:/usr/local/mysqld/bin
. /etc/profile
cd /usr/local/mysqld/
cp support-files/mysql.server /etc/init.d/mysql
vi /etc/init.d/mysql
……
basedir=/usr/local/mysqld
datadir=/mysql
mysql_pid_file_path=/tmp
……
vi /etc/my.cnf
[mysqld]
datadir=/mysql
socket=/tmp/mysql.sock
mysqld --initialize -b /usr/local/mysqld -h /mysql -u mysql
chkconfig --add mysql
systemctl start mysql
修改mysql初始密码:
[root@T1 mysqld]# mysqladmin -u root -p password 123456
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
3、安装PHP
# tar xvfj php-7.4.16.tar.bz2
# cd php-7.4.16/
./configure --prefix=/usr/local/php --enable-mysqlnd --with-pdo-mysql --with-mysqli --with-openssl --enable-gd --with-zlib-dir --with-curl --with-pear --enable-inline-optimization --enable-soap --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=mysql --with-fpm-group=mysql --with-fpm-systemd --with-apxs2=/usr/local/httpd/bin/apxs && make && make install
4、修改httpd.conf
vi httpd.conf
……
<IfModule dir_module>
DirectoryIndex index.html index.php #添加PHP首页
</IfModule>
……
AddType application/x-httpd-php .php
……
5、创建测试页面
[root@localhost ~]# vim /usr/local/httpd/htdocs/index.php
<?php
$link = mysqli_connect(
'localhost',
'root', /*账户*/
'root', /*密码*/
'mysql'); /*数据库*/
if($link){
printf("Congratulations!");
}
?>
6、配置phpMyAdmin
cd php-7.4.16/ext/openssl/
ln config0.m4 config.m4
/usr/local/php/bin/phpize
./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config &&make && make install
cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/openssl.so /usr/local/php/etc/
拷贝php配置文件并编辑php.ini文件:
cp php-7.4.16/php.ini-development /usr/local/php/php.ini
在文件最后添加
extension=openssl.so
重启httpd
# systemctl restart httpd
解压phpMyAdmin到httpd网页根目录
unzip -d /usr/local/httpd/htdocs/ phpMyAdmin-5.1.0-all-languages.zip
mv /usr/local/httpd/htdocs/phpMyAdmin-5.1.0-all-languages /usr/local/httpd/htdocs/php
7、测试

Leave a Reply