CentOS 7 安装 LAMP

2023-08-27 6296阅读 0评论
Kdatacenter:$17.1/月/1G内存/100GB SSD空间/1TB流量/1Gbps端口/KVM/韩国SK/直连;原生IP

1、清除、升级系统
yum clean all
yum -y update
hostname localhost
systemctl stop firewalld
systemctl disable firewalld

CentOS 7 安装 LAMP 第1张
(图片来源网络,侵删)

2、安装CSF
cd /usr/src
rm -fv csf.tgz
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

3、配置CSF
nano /etc/csf/csf.conf

输入
csf -r

保存,退出。

4、更改OpenSSH默认端口(也可不做更改)
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
nano /etc/ssh/sshd_config
找到Port 22,更改为其他端口,并在CSF中放行。

保存,推出。
重启服务
systemctl restart sshd.service

5、安装Apache

a、清除旧的服务:
yum -y install httpd

b、设置域名目录(把example.com改为自己的域名)
mkdir -p /var/www/example.com/public_html
chown -R $USER:$USER /var/www/example.com/public_html
chmod -R 755 /var/www
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled

c、编辑配置文件
nano /etc/httpd/conf/httpd.conf
把 IncludeOptional sites-enabled/*.conf 放到文件底部

d、保存,退出。
nano /etc/httpd/sites-available/example.com.conf

e、把以下添加到网站配置文件(把example.com改为自己的域名)

ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/requests.log combined

f、保存,退出。
ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf
apachectl restart

6、安装CertBot (使用lets-encrypt创建ssl证书)
yum install epel-release
yum install certbot
certbot certonly

下面是安装命令:
certbot renew –dry-run
certbot renew –quiet

7、安装PHP 5.6
yum -y update
yum -y install epel-release
wget https://dl.fedoraproject.org/pub/epe…t-7.noarch.rpm
wget https://centos7.iuscommunity.org/ius-release.rpm
rpm -Uvh ius-release*.rpm
yum -y update
yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath

8、安装MySQL
yum -y install mariadb-server mariadb
systemctl start mariadb
mysql_secure_installation

9、安装phpMyAdmin
yum -y install phpmyadmin
nano /etc/httpd/conf.d/phpMyAdmin.conf
把127.0.0.1改为你的独立IP
Alias /phpMyAdmin /usr/share/phpMyAdmin(把 /phpMyAdmin 改为 /usr/share/phpMyAdmin)

10、重启服务
systemctl restart httpd.service

via:http://www.webhostingtalk.com/showthread.php?t=1588551


免责声明
1、本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明。
2、本网站转载文章仅为传播更多信息之目的,凡在本网站出现的信息,均仅供参考。本网站将尽力确保所
提供信息的准确性及可靠性,但不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何
损失或损害承担责任。
3、任何透过本网站网页而链接及得到的资讯、产品及服务,本网站概不负责,亦不负任何法律责任。
4、本网站所刊发、转载的文章,其版权均归原作者所有,如其他媒体、网站或个人从本网下载使用,请在
转载有关文章时务必尊重该文章的著作权,保留本网注明的“稿件来源”,并白负版权等法律责任。

手机扫描二维码访问

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
评论列表 (暂无评论,6296人围观)

还没有评论,来说两句吧...

目录[+]