安装依赖
yum install -y epel-release
yum install -y gcc gcc-c++ pcre* openssl* gd-devel* zlib-devel pcre-devel wget net-tools
yum install -y bzip2 ncurses-devel cmake boost boost-devel openssl openssl-devel
yum install -y libaio libaio-devel bison bison-devel libcurl-devel libarchive-devel lsof perl kernel-headers kernel-devel
yum install -y libxml2 libxml2-devel bzip2-devel curl-devel php-mcrypt libmcrypt libmcrypt-devel postgresql-devel libxslt-devel autoconf libicu-devel
yum install -y libjpeg-devel libpng-devel freetype-devel libzip-devel
安装Nginx
1.解压:
cd /usr/local/
tar -zxvf nginx-1.8.0.tar.gz
2.配置:
cd /usr/local/nginx-1.8.0
./configure --prefix=/usr/local/nginx --with-pcre --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_auth_request_module --with-http_stub_status_module --with-http_image_filter_module --with-http_gzip_static_module
3.编译安装:
make -j 4 && make install
./configure 配置环境 make 是编译的意思。就是把源码包编译成二进制可执行文件。 make install 就是安装的意思。
make && make install 的意思是: make 与 make install 是两个命令,在你 ./configuration 生成了Makefile之后执行编译安装;与 &&一起的还有||,不过意思不一样,&&是与,||是或;make && make install 的意思就是在执行完 make后,如果没有发生错误就执行make install -j 4 四个CPU编译
3.配置nginx:
#修改nginx配置文件
/usr/local/nginx-1.8.0/conf/nginx.conf
#添加vhost目录
cd /usr/local/nginx/conf/
mkdir vhost
#添加站点配置文件(*.conf)
cd /usr/local/nginx/conf/vhost
添加*.conf配置文件
#添加nginx为系统服务、开机启动
cd /usr/lib/systemd/system/
vi nginx.service
systemctl enable nginx.service (设置nginx服务开机自启动)
#启动nginx服务
systemctl start nginx
#开启防火墙80端口
cd /usr/lib/systemd/system/
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload(更新防火墙规则)
centos7 默认是FirewallD
提供支持网络/防火墙区域(zone)定义网络链接以及接口安全等级的动态防火墙管理工具,利用FirewallD开启80端口操作如下:
开启80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent
出现success表明添加成功 命令含义: –zone #作用域 –add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
systemctl status firewalld
查看firewalld状态,发现当前是dead状态,即防火墙未开启。systemctl start firewalld
开启防火墙,没有任何提示即开启成功。再执行
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload(更新防火墙规则)
提示success成功
安装PHP
1.解决依赖:
yum install -y libsqlite3x-devel
yum install -y oniguruma-devel
dnf config-manager --set-enabled PowerTools
2.编译libzip:
cd /usr/local
yum remove -y libzip
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make -j 4 && make install
3.添加搜索路径到配置文件:
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" 设置 pkg_config_path
环境变量 方法,只是想加上某库的pkg
4.解压
cd /usr/local/
tar -zxvf php-7.4.9.tar.gz
5.配置:
./configure --prefix=/usr/local/php --with-curl --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm --enable-pdo --enable-gd --with-iconv --with-zip --with-jpeg --with-freetype
6.编译安装:
make -j 4 && make install
make test
7.安装PHP扩展:
#intl(一些新框架要求安装)
cd php-7.4.9/ext/intl/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make -j 4 && make install
#配置php
#添加配置文件
/usr/local/php/lib/php.ini
#添加php-fpm配置文件
/usr/local/php/etc/php-fpm-site.conf
#添加pid文件
/usr/local/php/var/run/php-fpm-site.pid
#添加tmp目录,给权限
mkdir /var/php
mkdir /var/php/tmp
chmod 777 /var/php/tmp/
#添加php-fpm服务启动文件
cd /etc/init.d/php
cd /etc/init.d/php-fpm
chmod a+x /etc/init.d/php
chmod a+x /etc/init.d/php-fpm
#添加环境变量
vi /etc/profile
#在文件的最后面加入
#php path
export PATH=$PATH:/usr/local/php/bin
#运行下面语句
source /etc/profile
#添加php用户
useradd webusers
#添加开机启动
chkconfig php on
#启动php
service php start
安装mariadb
1.解压:
cd /usr/local/
tar -zxvf mariadb-10.3.11.tar.gz
2.配置:
cd /usr/local/mariadb-10.3.11
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DENABLE_DOWNLOADS=1 -DEXTRA_CHARSETS=all -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_DEBUG=0 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_USER=mysql -DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DMYSQL_MAINTAINER_MODE=0
#编译安装
make -j 4 && make install
sudo dd if=/dev/zero of=/swapfile bs=64M count=16
chmod 0600 /swapfile
sudo swapon /swapfile
make -j 4 && make install
swapoff -a
#配置mysql
#添加mysql用户
useradd mysql
#添加my.cnf配置文件
/etc/my.cnf
#创建一些必要的目录
mkdir /usr/local/mysql/data
mkdir /usr/local/mysql/logs
mkdir /usr/local/mysql/pids
#把目录权限给mysql用户
chown -R mysql:mysql /usr/local/mysql
#添加服务启动文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
#添加环境变量
vi /etc/profile
#在文件的最后面加入
#mysql path
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
source /etc/profile
#开机自启动
chkconfig mysqld on
#初始化mysql数据
cd /usr/local/mysql/
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/
#启动mysql
service mysqld start
#初始化mysql
/usr/local/mysql/bin/mysql_secure_installation
#开启防火墙3306端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="xxx.xxx.xxx.xxx" port protocol="tcp" port="3306" accept"
firewall-cmd --reload
#安装phpmyadmin
tar -zxvf phpMyAdmin-5.0.2-all-languages.tar.gz
mv phpMyAdmin-5.0.2-all-languages /var/web/phpmyadmin
————————————————小笔记
解决方法 : 把phpmyadmin目录中的配置文件 config.sample.inc.php复制成config.inc.php
打开编辑config.inc.php 找到:
c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[′Servers′][i][‘host’] = ‘localhost’;
改成: c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[′Servers′][i][‘host’] = ‘127.0.0.1’
解决方法: 打开phpmyadmin文件夹下面的config.inc.php文件并打开,找到 c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[′Servers′][i][‘controluser’] = ‘pma’;
c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[′Servers′][i][‘controlpass’] = ‘’; 将其注释去掉,并改成你的数据库用户和密码,保存
c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[′Servers′][i][‘controluser’] = ‘root’;
c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[′Servers′][i][‘controlpass’] = ‘123456’; 刷新或重新打开phpmyadmin