当前位置:首页 » 编程语言 » yum安装apache与php

yum安装apache与php

发布时间: 2022-07-04 09:19:10

Ⅰ 怎么安装php环境

LAMP/LNMP 环境搭建

一.检查系统环境

1.确认centos版本

[root@localhost ~]# cat /etc/redhat-release

2.检查是否安装过apache

rpm -qa | grep httpd

或者:

apachectl -v

或者:

httpd -v

3.检查是否安装过Mysql

service mysqld start

如果未被识别则没有安装

如果系统安装过,或者安装失败,清理一下系统

4.清理Mysql痕迹

yum remove mysql

rm -f /etc/my.cnf

5.卸载Apache包

rpm -qa|grep httpd

注意:如果是新的系统或者你从来没有尝试安装过,则以上步骤省略

二.安装Apache、PHP、Mysql

停止防火墙服务

[root@localhost ~]# systemctl stop firewalld.service

禁用防火墙开机启动服务

[root@localhost ~]# systemctl disable firewalld.service

1.安装apache

[root@localhost ~]# yum -y install httpd

2.安装php

[root@localhost ~]# yum -y install php

3.安装php-fpm

[root@localhost ~]# yum -y install php-fpm

4.安装Mysql

[root@localhost ~]# yum -y install mysql

5.安装 mysql-server

[root@localhost ~]# yum install mariadb-server

CentOS 7+ 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了,entos7配置教程上,大多都是安装mariadb,因为centos7默认将mariadb视作mysql。

因为mysql被oracle收购后,原作者担心mysql闭源,所以又写了一个mariadb,这个数据库可以理解为mysql的分支。如果需要安装mariadb,只需通过yum就可。

6.安装 php-mysql

[root@localhost ~]# yum -y install php-mysql

三.安装基本常用扩展包

1.安装Apache扩展包

yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

2.安装PHP扩展包

yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-devel

3.安装Mysql扩展包

yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

四.配置Apache、mysql开机启动

重启Apache、mysql服务(注意这里和centos6有区别,Cenots7+不能使用6的方式)

systemctl start httpd.service #启动apache

systemctl stop httpd.service #停止apache

systemctl restart httpd.service #重启apache

systemctl enable httpd.service #设置apache开机启动

重启数据库

#启动MariaDB

[root@localhost ~]# systemctl start mariadb.service

#停止MariaDB

[root@localhost ~]# systemctl stop mariadb.service

#重启MariaDB

[root@localhost ~]# systemctl restart mariadb.service

#设置开机启动

[root@localhost ~]# systemctl enable mariadb.service

五.配置Mysql

初次安装mysql是没有密码的,我们要设置密码,mysql的默认账户为root

方式1:设置 MySQL 数据 root 账户的密码:

[root@localhost ~]# mysql_secure_installation

当出现如下提示时候直接按回车:

Enter current password for root

出现如下再次回车:

Set root password? [Y/n]

出现如下提示输入你需要设置的密码,这里输入了root,输入密码是不显示的,回车后再输入一次确认:

New password:

接下来还会有四个确认,分别是:

Remove anonymous users? [Y/n]

Disallow root login remotely? [Y/n]

Remove test database and access to it? [Y/n]

Reload privilege tables now? [Y/n]

直接回车即可。

方式2:进入mysql mysql -r

修改mysql密码:set password for 'root'@'localhost'=password('root');

mysql授权远程连接(navicat等): grant all on *.* to root identified by 'root';

六.测试环境

我们在浏览器地址栏输入http://ip/,正常显示,说明我们的lamp 环境搭建成功

七.安装nginx

yum install yum-priorities -y

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum install nginx

Nginx 版本号可变更http://nginx.org/packages/centos/7/noarch/RPMS/$版本

八.配置nginx

1.nginx启动,停止,重启

systemctl start nginx.service #启动nginx

systemctl stop nginx.service #停止

systemctl restart nginx.service #重启

systemctl enable nginx.service #设置开机启动

  • 更改nginx端口号(根据自己需求)

  • cd /etc/nginx/conf.d/

    vim default.conf

    把listen 80改成listen 81

    3.访问http://ip:81即可看到nginx首页

    安装完成访问时候需要启动php-fpm,不重启访问会出现下载文件,重启命令如下

    systemctl start php-fpm.service #启动php-fpm

    systemctl enable php-fpm.service #设置开机启动

    4.更改nginx配置文件识别php

    vi /etc/nginx/conf.d/default.conf,把之前的#给去掉就可以了,顺手改一下

    location ~ .php$ {

    root html;

    fastcgi_pass 127.0.0.1:9000;

    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;

    include fastcgi_params;

    }

    方法二 安装nginx

    yum install nginx

    启动nginx,并设置为开机启动

    systemctl start nginx

    systemctl enable nginx

5.在 /usr/share/nginx/html中新建一个test.php

访问http://ip:81/test.php即可看到php页面

修改完成配置记得启动apache 和php-fpm 哦!

九.负载配置

upstream site{

server 172.16.170.138;

server 172.16.170.139;

}

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log /var/log/nginx/log/host.access.log main;

location / {

root /usr/share/nginx/html;

index index.html index.htm;

proxy_pass http://site;

}

apache 默认目录 /var/www/html

nginx 默认目录 /usr/share/nginx/html

升级php版本

centos7 默认安装php是5.4

查看yum的可安装的php版本列表

yum provides php

开始升级PHP更新源:

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum remove php-common -y #移除系统自带的php-common

php72版本

yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring

php56版本

yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring #安装依赖包

查看php版本

php -v

安装php fpm:

yum install php72w-fpm

yum provides php-fpm #因为我是准备搭建lnmp,所以安装php-fpm,这里会提示多个安装源,选择5.6版本的安装就可以了

yum install php56w-fpm-5.6.31-1.w7.x86_64 -y

systemctl start php-fpm.service 【启动】

systemctl enable php-fpm.service【开机自启动】

CentOS yum有时出现“Could not retrieve mirrorlist ”的解决办法——resolv.conf的配置

原因:没有配置resolv.conf

解决方法:

到/etc目录下配置resolv.conf加入nameserver IP,如:

nameserver 8.8.8.8

nameserver 8.8.4.4

search localdomain

保存再次运行上面的命令就可以。

https://blog.csdn.net/mao834099514/article/details/73470001

nginx目录 : /usr/share/nginx/html

/etc/nginx/conf.d/default.conf nginx配置目录

apache目录 : /var/www/html

/etc/httpd/conf/httpd.conf apache配置文件

nginx 配置域名

cd /etc/nginx

cp default.conf imooc.conf

修改server_name imooc.test.com 以及项目目录

配置虚拟域名 windows 访问需要在host增加 linuxip

ServerName www.nine.com

DocumentRoot "/var/www/html/learnlaravel/public"

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

关闭防火墙

setenforce 0

Ⅱ 麻烦帮我解释下yum 安装 Apache + PHP + MySQL的意思吧。我只知道是在线安装!

yum其实就是相当于一个软件,该软件的功能是帮助你快速安装你设置的安装源中存在的软件,并帮助你解决依赖关系。

你的安装源其实就是一系列网站地址,这些网址中保存了很多常用软件。当你输入命令时,该软件首先解析命令,然后去安装源中找相应的安装文件,自动帮你下载并安装。同时去自己的软件数据库中查找依赖,如果这些依赖的软件你的机器上还没有安装,则同时帮你安装。

好处是省掉了你去处理依赖的繁琐工作。

类似于360软件管家或qq软件管家,只是没有界面而已。

Ⅲ linux 怎么安装apache,mysql+php

第1步:将光盘设备中的系统镜像挂载到/media/cdrom目录:
第2步:使用Vim文本编辑器创建Yum仓库的配置文件,下列具体参数含义可参考4.1.4小节:
第3步:接下来就要试试动手安装Apache服务程序啦,同学们需要注意使用yum命令安装软件时后面写的是服务程序的名字,而apache服务的软件包名称叫做httpd,直接执行yum install apache命令则是会报错误的。
第4步:将httpd服务程序启动并加入到开机启动项中,让Web服务程序能够随系统开机而启动运行:
详细的安装步骤和图片可以访问<Linux就该这么学>的网站,在课程的第10章节是专门介绍如何在linux 安装apache

Ⅳ 麻烦帮我解释下yum 安装 Apache + PHP + MySQL的意思吧。...


装这些东西,装这些的时候还要配置路径什么的,还不如只装一个WAMPSEVER ,它相当于你装了3个,而且它自带的MySQL数据库PHPMyadmin比MySQL容易操作,再装个EasyEclipse for PHP编写程序(或者DW),更好,就这两个软件解决你所有问题,而且没有配置问题

Ⅳ 如何在CentOS 6上通过YUM安装Nginx和PHP-FPM

1. 首先安装apachecentos可以直接yum安装apache 。
命令:yum install httpd //根据提示,输入Y安装即可成功安装

2. 然后启动apache,并且设置系统让 Apache 开机自动启动。
命令:
service httpd start //启动Apache
chkconfig httpd on //设置开机自启

3. 防火墙设置。关闭内核防火墙selinux,和iptables防火墙策略里设置运行网站的80端口,和数据库的3306端口。
命令:
vi /etc/selinux/config //关闭内核防火墙,将SELINUX=enforcing改成SELINUX=disabled
vi /etc/sysconfig/iptables //添加以下2个记录
-A INPUT -m state --state NEW -mtcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -mtcp -p tcp --dport 3306 -j ACCEPT

4. 安装mysql,此处也直接yum安装
命令:
yum install mysql mysql-server。//安装mysql
service mysqld start //安装完,用命令启动服务。
mysql_secure_installation //设置mysql密码,直接回车,根据提示输入Y,然后会让输入2次你想设置的密码,接下来的按照提示一直按y就行了。 最后出现:Thanksfor using MySQL!设置成功
chkconfig mysqld on //和apache一样设置开机自启
service mysqld restart //重启mysql

5. 安装PHP,和PHP组件,
命令:
yum install php
yum install php-mysql php-gd libjpeg*php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcryptphp-bcmath php-mhash libmcrypt
到此我们的apache、mysql、php都安装完了。在此重启一次apache和mysql
service httpd restart
service mysqld restart

6. apache默认网站目录是/var/www/html,在里面写个php测试页。
命令:
cd /var/www/html
vi ceshi.php

7. 测试,在浏览器地址栏里输入http://你的ip地址/ceshi.php,或者在本地浏览器输入:http://localhost/ceshi.php、http://127.0.0.1/ceshi.php也行。出现如下图php测试页,说明安装成功。向下拉看是否支持mysql。

END
注意事项
· 关闭selinux需要重启机器才能生效。也可以用命令setenforce 0 临时关闭selinux,这个是立即生效的。

Ⅵ centos安装apache mysql php用YUM安装与编译安装有什么区别

YUM安装:需要连接网络,依赖库可以自动补全;
编译安装:自己下载安装包,依赖包要自己补

Ⅶ linux安装完Apache和PHP后,为什么还是不能解析php网页啊

最简单的就是重启apache服务,不行的话就重装服务吧。
不行就用编译安装,不过很麻烦。
可以用yum的方式安装apache 然后再安装php。然后重启服务,注意文件的权限775。
还是不行的话,卸载所有服务,linux有一键安装的,你网络搜索wdcp

Ⅷ centos下,我怎么安装php和apache

查看是否有RPM包安装的这两个软件

rpm -qa |grep httpd #查看是否安装APACHE
rpm -qa |grep hph #查看是否安装php
如果有安装的话执行上两条命令时会显示已相应经安装的文件名,如果什么都没显示的话就说明没有安装
查看是否有编译安装的这两个软件
find / -name apaceh
find / -name php
如果有安装的话会有文件显示,没有显示的话说明没安装
要安装这两个软件最方便的就是将这台机器连上网然后执行以下两条命令
yum install apache
yum install php

Ⅸ 如何在CentOS 7.3上安装Apache,PHP 7.1和M6767ySQL

1初步说明

在本教程中,我使用IP地址为192.168.1.100的hostname server1.example.com 。 这些设置可能会有所不同,因此您必须在适当的情况下更换它们。

我会在这里添加EPEL repo来安装最新的phpMyAdmin,如下所示:

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release

要在shell上编辑文件,我将安装nano编辑器。 如果您喜欢vi进行文件编辑,请跳过此步骤。

yum -y install nano

2安装MySQL / MariaDB

MariaDB是原始MySQL开发人员Monty Widenius的MySQL分支。 MariaDB与MySQL兼容,我选择使用MariaDB而不是MySQL。 运行此命令以安装MariaDB:

yum -y install mariadb-server mariadb

然后,我们为MySQL创建系统启动链接(以便每当系统启动时,MySQL自动启动)并启动MySQL服务器:

systemctl start mariadb.service
systemctl enable mariadb.service

设置MySQL根帐户的密码:

mysql_secure_installation

[root@server1 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): <--ENTER
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n]
New password: <--yourmariadbpassword
Re-enter new password: <--yourmariadbpassword
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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
proction environment.

Remove anonymous users? [Y/n] <--ENTER
... Success!

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] <--ENTER
... Success!

By default, MariaDB 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 proction environment.

Remove test database and access to it? [Y/n] <--ENTER
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <--ENTER
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@server1 ~]#

3安装Apache

CentOS 7附带apache 2.4。 Apache可以直接作为CentOS 7软件包使用,因此我们可以这样安装:

yum -y install httpd

这里是安装过程的截图。

现在配置您的系统启动Apache启动时...

systemctl start httpd.service

systemctl enable httpd.service

为了能够从外部访问Web服务器,我们必须打开防火墙中的HTTP(80)和HTTPS(443)端口。 CentOS上的默认防火墙是firewalld,可以使用firewalld-cmd命令配置。

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

现在将您的浏览器指向服务器的IP地址,在我的情况下为http://192.168.1.100 ,您应该看到Apache占位符页面:

4安装PHP

CentOS附带的PHP版本相当旧(PHP 5.4),因此,我将在此步骤中显示一些选项,从Remi存储库安装更新的PHP版本,如PHP 7.0或7.1。

添加Remi CentOS存储库。

rpm -Uvhhttp://rpms.remirepo.net/enterprise/remi-release-7.rpm

安装yum-utils,因为我们需要yum-config-manager实用程序。

yum -y install yum-utils

并运行yum更新

yum update

现在您必须选择要在服务器上使用哪个PHP版本。 如果你喜欢使用PHP 5.4,那么继续下一个命令。 要安装PHP 7.0,请遵循第4.1章和PHP 7.1中的命令,使用第4.2章。

要安装PHP 5.4,请运行以下命令:

yum -y installphp

4.1安装PHP 7.0(可选)

我们可以安装PHP 7.0和Apache PHP 7.0模块,如下所示:

yum-config-manager --enable remi-php70

yum -y installphp php-opcache

4.2安装PHP 7.1(可选)

如果要使用PHP 7.1,请使用:

yum-config-manager --enable remi-php71

yum -y installphp php-opcache

在这个例子中,在可下载的虚拟机中,我将使用PHP 7.1。

我们必须重新启动Apache来应用更改:

systemctl restart httpd.service

5测试PHP /获取有关您的PHP安装的详细信息

默认网站的文档根目录是/ var / www / html。 我们将在该目录中创建一个小型的PHP文件(info.php),并在浏览器中调用它来测试PHP安装。 该文件将显示有关我们的PHP安装的许多有用的细节,例如安装的PHP版本。

nano /var/www/html/info.php

<?php
phpinfo();?>

现在我们在浏览器中调用该文件(例如http://192.168.1.100/info.php ):

如您所见,PHP 7.1正在工作,它正在通过Apache 2.0处理程序,如Server API行所示。 如果您进一步向下滚动,您将看到在PHP中已启用的所有模块。 MySQL没有列出,这意味着我们还没有在PHP中支持MySQL。

6在PHP中获取MySQL支持

要在PHP中获得MySQL支持,我们可以安装php71w-mysql包。 安装一些其他PHP模块是一个好主意,也可能需要它们用于应用程序。 您可以搜索可用的PHP5模块,如下所示:

yum search php

选择您需要的并安装它们:

yum -y install php-mysql

在下一步中,我将安装一些常见的PHP模块,CMS系统如Wordpress,Joomla和Drupal所需:

yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstringphp-soap curl curl-devel

现在重新启动Apache Web服务器:

systemctl restart httpd.service

现在在您的浏览器中重新加载http://192.168.1.100/info.php并再次向下滚动到模块部分。 你现在应该找到很多新的模块,如Curl等。

如果您不再需要php信息输出,那么为了安全起见,请删除该文件。

rm/var/www/html/info.php

7 phpMyAdmin安装

phpMyAdmin是一个Web界面,您可以通过它来管理MySQL数据库。
phpMyAdmin现在可以安装如下:

yum -y install phpMyAdmin

现在我们配置phpMyAdmin。 我们更改Apache配置,以便phpMyAdmin不仅允许从localhost进行连接(通过注释<RequireAny>节并添加“要求所有已授予”行):

nano /etc/httpd/conf.d/phpMyAdmin.conf

[...]
Alias /phpMyAdmin /usr/share/phpMyAdminAlias /phpmyadmin /usr/share/phpMyAdmin<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8

<IfMole mod_authz_core.c>
# Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
Require all granted
</IfMole>
<IfMole !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfMole>
</Directory>
<Directory /usr/share/phpMyAdmin/>
Options none AllowOverride Limit
Require all granted</Directory>

[...]

接下来,我们将phpMyAdmin中的身份验证从cookie更改为http :

nano /etc/phpMyAdmin/config.inc.php

[...]$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?[...]

重新启动Apache:

systemctl restart httpd.service

之后,您可以访问http://192.168.1.100/phpmyadmin/下的phpMyAdmin :

8作为虚拟机下载

此设置可用于以ova / ovf格式(与VMWare和Virtualbox兼容)的虚拟机下载,以了解用户的身份。

VM的登录详细信息

  • Linux root密码是:howtoing。

  • Rhe MySQL的root密码是:howtoing

  • 请在第一次登录时更改两个密码。

  • 虚拟机的IP地址为192.168.1.100

Ⅹ 如何在Fedora 13下使用Yum来安装Apache+PHP+MySQL

yum install httpd php mysql-server;
service httpd start;
service mysqld start;

热点内容
手机网页缓存视频 发布:2025-02-03 23:38:48 浏览:832
agnes算法 发布:2025-02-03 23:38:05 浏览:35
私密上传在哪 发布:2025-02-03 23:33:04 浏览:1002
切冰解压 发布:2025-02-03 23:30:36 浏览:768
解压搅拌声 发布:2025-02-03 23:11:35 浏览:838
服务器硬盘误拔了怎么办 发布:2025-02-03 23:05:26 浏览:874
易手遥控连接密码是多少 发布:2025-02-03 22:44:26 浏览:172
sql安装程序配置服务器失败 发布:2025-02-03 22:44:25 浏览:594
可以写脚本的点击器 发布:2025-02-03 22:44:22 浏览:622
c算法代码 发布:2025-02-03 22:42:20 浏览:866