centOs下的php+mysql+apache+ftp配置,centosapache_PHP教程
centOs下的php+mysql+apache+ftp配置,centosapache
在安装服务器时做了相应的笔记,这个方法是亲身经验成功的,随着版本的不断更新,也许会有一些地方不同,但是基本原理都是一样的。
1.安装CentOS 6 ,可以选择最小安装,也可以安装桌面
2.升级系统
yum update
3.安装mysql,并设置mysql开机自启动,同时启动mysql
yum install mysql
yum install mysql-server
chkconfig --levels 35 mysqld on
service mysqld start
4.配置mysql的root密码
mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
设置mysql密码还可以用:mysql_secure_installation 命令
mysql_secure_installation
Enter current password for root (enter for none): ( 回车)
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] (Y)
New password: (123456)
Re-enter new password: (123456)
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n]
(是否移出数据库的默认帐户,如果移出,那么在终端中直接输入mysql是会提示连接错误的)Y
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n]
(是否禁止root的远程登录)Y
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
**后来设置是否允许远程登录
mysql -u root -p
Enter Password:
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
完成后就能用mysql-front远程管理mysql了。
设为开机启动
chkconfig mysqld on
5.安装apache,并设置开机启动
yum install httpd
chkconfig --levels 35 httpd on
service httpd start
这时候可以测试apache是否正常工作
直接浏览器访问localhost应该没问题,但是如果别的机子访问不了的话,是因为防火墙的关系,配置防火墙
(后面的ssl还会有这个问题的)
6.安装php
如果安装php53以下的版本的话,可能会导致项目放在这个环境中不能运行的情况,当时装的是php5.2结果发
现项目根本运行不起来,找了好久的原因才发现是php版本太低了(在这之前一直是以为json的原因,因为
php5.2没有json扩展),所以在安装前一定要看好版本在安装,否则以后项目出现问题不好找出原因。
yum install php53
yum install php53-mysql php53-gd php53-imap php53-ldap php53-odbc php53-pear php53-xml php53-
xmlrpc
这个时候php就安装完成拉,写个脚本测试一下
vi /var/www/html/info.php
输入
phpinfo();?>
访问localhost/info.php即可~
7.安装phpMyAdmin
首先先给系统安装epel 和rpmfushion两个软件大仓库
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/6/i386/rpmfusion-free-release-
6-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/6/i386/rpmfusion-
nonfree-release-6-0.1.noarch.rpm
如果是centos 5 的话执行下面
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/5/i386/rpmfusion-free-release-
5-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/5/i386/rpmfusion-
nonfree-release-5-0.1.noarch.rpm
接着安装起来就很方便拉,~根本不需要去下载就可以获得最新的版本
yum install phpmyadmin
安装完成后还需要配置一下访问权限,使得出了本机外,其他机子也能访问phpMyAdmin
vi /etc/httpd/conf.d/phpMyAdmin.conf
找到两个directory的权限设置,Allow from 改成All
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from All
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from All
重启服务器
service httpd restart
测试localhost/phpMyAdmin
用户名密码:root 123456
OK~ LAMP搭建完毕,
8.搭建SSL,让apache支持https
yum install mod_ssl
其实安装完这个模块后,重启完apache 就可以用https://localhost测试了,因为他创建了默认的证书
在/etc/pki/tls下
当然我们也可以用openssl创建自己的证书
yum install openssl
生成证书文件
创建一个rsa私钥,文件名为server.key
openssl genrsa -out server.key 1024
Generating RSA private key, 1024 bit long modulus
............++++++
............++++++
e is 65537 (0x10001)
用 server.key 生成证书签署请求 CSR
openssl req -new -key server.key -out server.csr
Country Name:两个字母的国家代号
State or Province Name:省份名称
Locality Name:城市名称
Organization Name:公司名称
Organizational Unit Name:部门名称
Common Name:你的姓名
Email Address:地址
至于 'extra' attributes 不用输入.直接回车
生成证书CRT文件server.crt。
openssl x509 -days 365 -req -in server.csr -signkey server.key -out server.crt
修改ssl.conf指定我们自己生成的证书
vi /etc/httpd/conf.d/ssl.conf
找到如下位置,修改路径
# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill -HUP will prompt again. A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
OK
service httpd restart
yum install vsftpd
2.启动/重启/关闭vsftpd服务器
/sbin/service vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]
OK表示重启成功了.
启动和关闭分别把restart改为start/stop即可.
如果是源码安装的,到安装文件夹下找到start.sh和shutdown.sh文件,执行它们就可以了.
根据下面修改
vi /etc/vsftpd/vsftpd.conf
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
local_root=/
vi /etc/vsftpd/ftpusers
# Users that are not allowed to login via ftp
#root
vi /etc/vsftpd/user_list
# for users that are denied.
#root
防火墙配置
a.添加.允许访问端口{80: http}.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
b.关闭防火墙{不推荐}.
service iptables stop
c.重置加载防火墙
service iptables restart

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











CentOS 시스템 하에서 Gitlab의 백업 및 복구 정책 데이터 보안 및 복구 가능성을 보장하기 위해 CentOS의 Gitlab은 다양한 백업 방법을 제공합니다. 이 기사는 완전한 GITLAB 백업 및 복구 전략을 설정하는 데 도움이되는 몇 가지 일반적인 백업 방법, 구성 매개 변수 및 복구 프로세스를 자세히 소개합니다. 1. 수동 백업 gitlab-rakegitlab : 백업 : 명령을 작성하여 수동 백업을 실행하십시오. 이 명령은 gitlab 저장소, 데이터베이스, 사용자, 사용자 그룹, 키 및 권한과 같은 주요 정보를 백업합니다. 기본 백업 파일은/var/opt/gitlab/backups 디렉토리에 저장됩니다. /etc /gitlab을 수정할 수 있습니다

CentOS에서 HDFS 성능 향상 : CentOS에서 HDFS (Hadoop 분산 파일 시스템)를 최적화하기위한 포괄적 인 최적화 안내서에는 하드웨어, 시스템 구성 및 네트워크 설정에 대한 포괄적 인 고려가 필요합니다. 이 기사는 HDFS 성능을 향상시키는 데 도움이되는 일련의 최적화 전략을 제공합니다. 1. 하드웨어 업그레이드 및 선택 리소스 확장 : 서버의 CPU, 메모리 및 저장 용량을 최대한 많이 늘립니다. 고성능 하드웨어 : 고성능 네트워크 카드 및 스위치를 채택하여 네트워크 처리량을 개선합니다. 2. 시스템 구성 미세 조정 커널 매개 변수 조정 : TCP 연결 번호, 파일 핸들 번호 및 메모리 관리와 같은 커널 매개 변수를 최적화하기 위해 /etc/sysctl.conf 파일을 수정합니다. 예를 들어 TCP 연결 상태 및 버퍼 크기를 조정하십시오

Centos는 2024 년에 상류 분포 인 RHEL 8이 종료 되었기 때문에 폐쇄 될 것입니다. 이 종료는 CentOS 8 시스템에 영향을 미쳐 업데이트를 계속받지 못하게합니다. 사용자는 마이그레이션을 계획해야하며 시스템을 안전하고 안정적으로 유지하기 위해 Centos Stream, Almalinux 및 Rocky Linux가 포함됩니다.

CentOS 종료 명령은 종료이며 구문은 종료 [옵션] 시간 [정보]입니다. 옵션은 다음과 같습니다. -H 시스템 중지 즉시 옵션; -P 종료 후 전원을 끕니다. -R 다시 시작; -대기 시간. 시간은 즉시 (현재), 분 (분) 또는 특정 시간 (HH : MM)으로 지정할 수 있습니다. 추가 정보는 시스템 메시지에 표시 될 수 있습니다.

CentOS 시스템에서 HDFS 구성 확인에 대한 완전한 안내서이 기사에서는 CentOS 시스템에서 HDF의 구성 및 실행 상태를 효과적으로 확인하는 방법을 안내합니다. 다음 단계는 HDF의 설정 및 작동을 완전히 이해하는 데 도움이됩니다. Hadoop 환경 변수 확인 : 먼저 Hadoop 환경 변수가 올바르게 설정되어 있는지 확인하십시오. 터미널에서 다음 명령을 실행하여 Hadoop이 올바르게 설치되고 구성되었는지 확인하십시오. Hadoopversion Check HDFS 구성 파일 : HDFS의 Core 구성 파일은/etc/hadoop/conf/directory에 있으며 Core-Site.xml 및 HDFS-Site.xml이 중요합니다. 사용

Centos에 MySQL을 설치하려면 다음 단계가 필요합니다. 적절한 MySQL Yum 소스 추가. mysql 서버를 설치하려면 yum install mysql-server 명령을 실행하십시오. mysql_secure_installation 명령을 사용하여 루트 사용자 비밀번호 설정과 같은 보안 설정을 작성하십시오. 필요에 따라 MySQL 구성 파일을 사용자 정의하십시오. MySQL 매개 변수를 조정하고 성능을 위해 데이터베이스를 최적화하십시오.

CentOS에서 IP 주소를 구성하는 단계 : 현재 네트워크 구성보기 : IP Addr 네트워크 구성 파일 편집 : Sudo vi/etc/ifcfg-eths 스크립트/IFCFG-ETH-Scripts 변경 IP 주소 : iPaddr = 라인 변경 서브넷 마스크 및 게이트웨이 (옵션) (옵션) 네트워크 주소 : Su Systemctl CTL CTL CTLCTCTCTCTC TH SYSTEMCCTL

Centos에서 Hadoop 분산 파일 시스템 (HDFS) 구성에 대한 일반적인 문제 및 솔루션 Centos에서 HadoophDFS 클러스터를 구축 할 때 일부 일반적인 잘못된 구성으로 인해 성능 저하, 데이터 손실이 발생할 수 있으며 심지어 클러스터조차 시작할 수 없습니다. 이 기사는 이러한 공통 문제와 이러한 함정을 피하고 HDFS 클러스터의 안정성과 효율적인 작동을 보장하는 데 도움이되는 솔루션을 요약합니다. 랙 인식 구성 오류 : 문제 : 랙-인식 정보가 올바르게 구성되지 않아 데이터 블록 복제본의 분포가 고르지 않고 네트워크로드가 증가합니다. 솔루션 : HDFS-Site.xml 파일에서 랙-인식 구성을 두 번 확인하고 HDFSDFSADMIN-PRINTTOPO를 사용하십시오.
