参考: https://tecadmin.net/install-lamp-apache-mysql-and-php-on-centos-rhel-7/
Apache 2.4
1.安装Apache
yum install httpd
2.设置服务器开机自动启动Apache
systemctl enable httpd.service
若要验证是否自动启动可在重启服务器后在终端键入以下命令来检测Apache是否已经启动systemctl is-enabled httpd.service
如果看到了enable
这样的响应,则表示Apache已经启动成功
3.手动启动Apachesystemctl start httpd.service 在浏览器中输入IP地址即可验证是否启动成功
4.手动重启Apachesystemctl restart httpd.service
5.手动停止Apachesystemctl stop httpd.service
6.安装目录介绍
Apache默认将网站的根目录指向/var/www/html默认的主配置文件/etc/httpd/conf/httpd.conf
配置存储在的/etc/httpd/conf.d/目录
7.开放80端口CentOS升级到7之后,发现无法使用iptables控制Linuxs的端口,google之后发现Centos 7使用firewalld代替了原来的iptables。下面记录如何使用firewalld开放Linux端口:
开启端口
firewall-cmd —zone=public –add-port=80/tcp –permanent
命令含义:
—zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
重启防火墙
firewall-cmd –reload
查看状态
firewall-cmd –state
Php 7.3
sudo yum install epel-release sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm # Install PHP 7 on CentOS yum --enablerepo=remi-php73 install php php -v # Install PHP Modules yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt # example command search for all modules for PHP 7.3 yum --enablerepo=remi-php73 search php | grep php73 参考: https://tecadmin.net/install-php7-on-centos7/
Mysql 8.0
# Step 1 – Setup Yum Repository rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm # Step 2 – Install MySQL Community Server sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo yum --enablerepo=mysql80-community install mysql-community-server # Step 3 – Start MySQL Service systemctl start mysqld.service # Step 4 – Find default root Password grep "A temporary password" /var/log/mysqld.log # Step 5 – MySQL Post Install Setup mysql_secure_installation # Step 6 – Restart and Enable MySQL Service systemctl restart mysqld.service systemctl enable mysqld.service # Step 7 – Working with MySQL mysql -h localhost -u root -p mysql> CREATE DATABASE mydb; mysql> CREATE USER 'dbuser'@'192.168.10.101' IDENTIFIED BY 'secret'; mysql> GRANT ALL ON mydb.* TO 'dbuser'@'192.168.10.101'; mysql> FLUSH PRIVILEGES; # 修改为mysql5之前密码加密方式: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; 参考: https://tecadmin.net/install-mysql-8-on-centos/
Apache 2.4
yum --enablerepo=epel,remi install httpd systemctl start httpd.service systemctl enable httpd.service 参考: