LAMP - CentOS7+Apache2.4+MySQL8+PHP7.3環(huán)境搭建

YUM源配置 & 更新

yum -y install epel-release

yum -y install yum-utils

yum update

Apache安裝

yum -y install httpd

systemctl enable httpd

systemctl start httpd

firewall-cmd --permanent --zone=public --add-service=http

firewall-cmd --permanent --zone=public --add-service=https

firewall-cmd --reload

# 隱藏版本號

vim /etc/httpd/conf.d/secure.conf

TraceEnable off

ServerSignature Off

ServerTokens Prod

# 配置vhost

vim /etc/httpd/conf.d/vhosts.conf

DocumentRoot "/var/www/html"

ServerName example.com

ServerAlias www.example.com

ErrorLog "logs/example.com-error_log"

CustomLog "logs/example.com-access_log" combined

# HTTPS證書安裝

yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

yum install certbot python2-certbot-apache

certbot --apache

systemctl restart httpd

MySQL8安裝

# 安裝MySQL8 YUM源

rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

yum install mysql-community-server

systemctl enable mysqld

systemctl start mysqld

# 查看自動生成的MySQL密碼

grep "password" /var/log/mysqld.log

# 登錄MySQL后修改密碼

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密碼';

# 刷新MySQL權(quán)限表

FLUSH PRIVILEGES;

PHP7.3安裝

yum-config-manager --disable remi-php54

yum-config-manager --enable remi-php73

yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-opcache php-redis php-soap

# 隱藏php版本號

vim /etc/php.ini

expose_php = off

系統(tǒng)參數(shù)設(shè)置

# 文件打開數(shù)設(shè)置

ulimit -n 65535

vim /etc/security/limits.d/nofile.conf

* soft nofile 65535

* hard nofile 65535

# 內(nèi)核網(wǎng)絡(luò)優(yōu)化

vim /etc/sysctl.conf

# 啟用timewait 快速回收

net.ipv4.tcp_tw_recycle = 1

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容