Linux下Apache+Mysql+PHP的安装与配置
(1)Apache的安装与配置 思路:首先在官网下载APACHE源码,本系统下载版本为httpd-2.2.17.tar.gz,下面几步为在终端的配置命令 tar zxvf httpd-2.2.17.tar.gz cd httpd-2.2.17 ./configure --prefix=/usr/local/apache make make install service httpd sta
(1) Apache的安装与配置
思路:首先在官网下载APACHE源码,本系统下载版本为httpd-2.2.17.tar.gz,下面几步为在终端的配置命令
tar zxvf httpd-2.2.17.tar.gz
cd httpd-2.2.17
./configure --prefix=/usr/local/apache
make
make install
service httpd start
如果出现:
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 222.31.76.227 for ServerName [ OK ] |
说明安装成功!
如果希望apache开机自启动的话,可以通过以下命令在/etc/rc.d/rc.local加入自启动命令:
echo "service httpd start">>/etc/rc.d/rc.local
测试Apache
在/var/www/html目录下建立index.html文件
Welcome to Apache!! |
保存后,在浏览器上输入http://XXX.XXX.XXX.XXX(Web服务器的IP)查看结果
注意:iptables必须关闭或者将80端口加到iptables中
(2) Mysql-client的安装与配置
思路:由于MYSQL没有源码包可以下载,所以本系统使用MYSQL的二进制安装包,使用版本为mysql-5.5.10-linux2.6-x86_64.tar.gz,下面几步为在终端的配置命令(可直接粘贴)
tar zxvf mysql-5.5.10-linux2.6-x86_64.tar.gz
cd /usr/local
ln -s /home/software/mysql-5.5.10-linux2.6-x86_64 mysql
cd mysql/
vi INSTALL-BINARY
看到以下部分为安装步骤
To install and use a MySQL binary distribution, the basic command sequence looks like this: shell> groupadd mysql shell> useradd -r -g mysql mysql shell> cd /usr/local shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz shell> ln -s full-path-to-mysql-VERSION-OS mysql shell> cd mysql shell> chown -R mysql . shell> chgrp -R mysql . shell> scripts/mysql_install_db --user=mysql shell> chown -R root . shell> chown -R mysql data # Next command is optional shell> cp support-files/my-medium.cnf /etc/my.cnf shell> bin/mysqld_safe --user=mysql & # Next command is optional shell> cp support-files/mysql.server /etc/init.d/mysql.server //开机自启动(后面还需几步)
|
如果已经安装在安装操作系统时已经安装过MYSQL,那么前6步(高亮部分)目前已经完成
(需要注意的是 data目录下存放的就是一个又一个数据库,所以,必须将权限设置为mysql,否则,mysql本身进不去,配置就会失败)
chown -R mysql.mysql .
scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/
chown -R root .
chown -R mysql data
cp support-files/my-medium.cnf /etc/my.cnf
bin/mysqld_safe --user=mysql &
service mysqld start
若显示:
Starting MySQL.. [ OK ]
则说明mysql已成功启用!
使用 mysql_install_db --user=mysql 创建新的MySQL授权表,使用者为mysql
使用 mysqld_safe --user=mysql & 以用户名user_name或数字用户ID user_id运行mysqld服务器。(本文中的“用户”指系统登录账户,而不是 授权表中的MySQL用户)
让MYSQL自启动
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chkconfig --add mysqld
如果遇到以下问题:
启动MYSQL出错,提示:
Starting mysqld daemon with databases from /usr/local/mysql/data
STOPPING server from pid file /usr/local/mysql/data/xmcncn.pid
061103 15:25:32 mysqld ended
解决方法:
vi /etc/my.cnf
看看[mysqld]下有没有
port = 3306
添加上就可以了
touch /tmp/mysql.sock
killall -9 mysqld
/usr/local/mysql/bin/mysqld_safe -user=mysql &
成功启动
(3)php的安装与配置
首先,安装php前,以下包可能会需要安装:zlib-1.2.3.tar.gz、libpng-1.2.24.tar.gz、freetype-2.3.11.tar.gz、libtool-2.4.tar.gz、jpegsrc.v6b.tar.gz、autoconf-2.61.tar.gz、gd-2.0.35.tar.gz、libxml2-2.7.3.tar.gz
在官网下载php源码,本系统下载版本为php-5.3.6.tar,下面几步为在终端的配置命令(可直接粘贴)
cd /home/software/
tar -xvf php-5.3.6.tar
cd php-5.3.6
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-openssl-dir=/usr/lib/openssl --with-openssl
配置后若如下显示License,则说明成功,否侧可能还缺少上述的包。
… checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes … creating libtool appending configuration tag "CXX" to libtool
Generating files updating cache ./config.cache creating ./config.status … creating main/internal_functions.c creating main/internal_functions_cli.c +----------------------------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +-----------------------------------------------------------------------------------------+
Thank you for using PHP. |
make
make test //可以不做
make install
cp php.ini-development /etc/php.ini
vi /usr/local/apache/conf/httpd.conf
加入一句话:
AddType application/x-httpd-php .php |
cd /var/www/html
vi index.php
新建php测试代码为:
phpinfo(); ?> |
重启apache,重启前要先修改/etc/selinux/config,将SELINUX=enforcing 改成SELINUX=disabled:
vi /etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted |
service httpd restart
出现以下语句说明重启成功:
Stopping httpd: [ OK ] Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 222.31.76.227 for ServerName [ OK ] |
在浏览器输入http://XXX.XXX.XXX.XXX/index.php,若显示phpinfo信息说明php配置成功。
若能显示phpinfo信息,但发现无法连接数据库(没有MYSQL的信息),说明php与mysql相连的模块包没有安装成功,可尝试下载安装php-mysql的rpm包(php-mysql-5.1.6-27.el5.x86_64.rpm),安装它还需先安装php-pdo的rpm包(php-pdo-5.1.6-27.el5.x86_64.rpm),pdo就是专门用于连接php和mysql的。
在以后的web端配置安装时,若phpinfo的基本信息能正常显示,但缺少某个模块功能,可单独下载其对应的rpm包,安装即可。
在/var/www/html下新建一个test.php,用于测试连接远程数据库:
echo "Hello World!"; $db=mysql_connect("远程服务器IP","用户名","password") or die ("mysql connected failed! "); mysql_select_db("数据库名",$db); $sql="select * from users"; $result=mysql_fetch_row(mysql_query($sql)); print_r($result); ?> |

핫 AI 도구

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

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

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

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

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

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

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

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

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

뜨거운 주제











DeepSeek은 웹 버전과 공식 웹 사이트의 두 가지 액세스 방법을 제공하는 강력한 지능형 검색 및 분석 도구입니다. 웹 버전은 편리하고 효율적이며 설치없이 사용할 수 있습니다. 개인이든 회사 사용자이든, DeepSeek를 통해 대규모 데이터를 쉽게 얻고 분석하여 업무 효율성을 향상시키고 의사 결정을 지원하며 혁신을 촉진 할 수 있습니다.

Docker 컨테이너를 사용하여 사전 컴파일 된 패키지 (Windows 사용자의 경우)를 사용하여 소스 (숙련 된 개발자)를 컴파일하는 것을 포함하여 DeepSeek를 설치하는 방법에는 여러 가지가 있습니다. 공식 문서는 신중하게 문서를 작성하고 불필요한 문제를 피하기 위해 완전히 준비합니다.

Linux 터미널에서 Python 버전을 보려고 할 때 Linux 터미널에서 Python 버전을 볼 때 권한 문제에 대한 솔루션 ... Python을 입력하십시오 ...

Bitget은 스팟 거래, 계약 거래 및 파생 상품을 포함한 다양한 거래 서비스를 제공하는 Cryptocurrency 교환입니다. 2018 년에 설립 된이 교환은 싱가포르에 본사를두고 있으며 사용자에게 안전하고 안정적인 거래 플랫폼을 제공하기 위해 노력하고 있습니다. Bitget은 BTC/USDT, ETH/USDT 및 XRP/USDT를 포함한 다양한 거래 쌍을 제공합니다. 또한 Exchange는 보안 및 유동성으로 유명하며 프리미엄 주문 유형, 레버리지 거래 및 24/7 고객 지원과 같은 다양한 기능을 제공합니다.

Gate.io는 사용자가 설치 패키지를 다운로드하여 장치에 설치하여 사용할 수있는 인기있는 cryptocurrency 교환입니다. 설치 패키지를 얻는 단계는 다음과 같습니다. Gate.io의 공식 웹 사이트를 방문하고 "다운로드"를 클릭하고 해당 운영 체제 (Windows, Mac 또는 Linux)를 선택하고 컴퓨터에 설치 패키지를 다운로드하십시오. 설치 중에 항 바이러스 소프트웨어 또는 방화벽을 일시적으로 비활성화하여 원활한 설치를 보장하는 것이 좋습니다. 완료 후 사용자는 GATE.IO 계정을 만들려면 사용을 시작해야합니다.

시스템이 다시 시작된 후 UnixSocket의 권한을 자동으로 설정하는 방법. 시스템이 다시 시작될 때마다 UnixSocket의 권한을 수정하려면 다음 명령을 실행해야합니다.

세계 최고의 디지털 자산 거래소 인 Ouyi Okx는 이제 안전하고 편리한 거래 경험을 제공하기 위해 공식 설치 패키지를 시작했습니다. OUYI의 OKX 설치 패키지는 브라우저를 통해 액세스 할 필요가 없습니다. 설치 프로세스는 간단하고 이해하기 쉽습니다. 사용자는 최신 버전의 설치 패키지를 다운로드하고 설치를 단계별로 완료하면됩니다.

1025 년의 가상 통화 앱 플랫폼. 순위는 시장 점유율, 사용자 경험, 보안, 거래 수수료 등과 같은 요소를 고려하지만 참조 용입니다.
