Login
网站首页 > 文章中心 > 其它

coreos安装php环境_Linux安装PHP环境

作者:小编 更新时间:2023-08-03 08:40:36 浏览量:319人看过

阿里云上的centos ⑦2怎么yum安装php ⑤6

因之前通过网易的 centos 镜像,将阿里云的 centos 升级到最新版了,乘自己的项目尚未开始正式开发,遂将所有的相应环境都升级到最高.

查看 centos 版本:

①.、删除之前的 php 版本:

Loaded plugins: langpacks

Repository base is listed more than once in the configuration

Repository updates is listed more than once in the configuration

Repository extras is listed more than once in the configuration

Repository centosplus is listed more than once in the configuration

No Match for argument: php-common

No Packages marked for removal

Retrieving

Preparing... ################################# [100%]

Resolving Dependencies

-- Running transaction check

... 【省略】

Warning: RPMDB altered outside of yum.

Installed:

Dependency Installed:

Complete!

以上显示安装成功!

检查phpinfo:

Virtual Directory Supportdisabled

Configuration File (php.ini) Path/etc

Loaded Configuration File/etc/php.ini

Scan this dir for additional .ini files/etc/php.d

Debug Buildno

Thread Safetydisabled

Zend Signal Handlingdisabled

Zend Memory Managerenabled

Zend Multibyte Supportdisabled

DTrace Supportenabled

This program makes use of the Zend Scripting Language Engine:

Configuration

Server Administratorxxxxxx@xxxxxx.com

Hostname:Portxxxx.xxxxx.xxx:0

Max RequestsPer Child: 0 - Keep Alive: on - Max Per Connection: 100

Virtual ServerYes

Server Root/etc/httpd

请linux高手解答搭建php环境问题,主要问题安装phpmyadmin,访问时出现403Forbidden错误,怎么解决?

这是我自己整理的你可以查考下

基本上没有什么包得

第一段:mysql安装:

①安装bison和cmake

yum install bison

注:需安装GCC,ncurses-devel.

wget

./configure

gmake

gmake install

chkconfig iptables off 禁用iptables(永久生效)

service iptables stop (临时生效)

提示:如果机器上已有自带的MySQL版本,最好先卸载自带的MySQL,以防以后使用的时候混淆.

卸载命令:yum remove mysql

如果不确定机器上是否自带有MySQL,也一样可以执行下卸载命令无妨.

/usr/sbin/groupadd mysql (如果有提示已存在,并不是错误)

/usr/sbin/useradd -g mysql mysql (如果有提示已存在,并不是错误)

mkdir -p /data/mysql

chown -R mysql:mysql /data/mysql

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/mysql

make

make install

cd /usr/local/mysql

cp ./support-files/my-huge.cnf /etc/my.cnf

在 [mysqld] 段增加

datadir = /data/mysql

max_connect_errors = 10000000

在 [mysqld] 段修改

./scripts/mysql_install_db --user=mysql

cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

service mysqld start

bin/mysqladmin -u root password 'password_for_root'

其中引号内的password_for_root是要设置的root密码

service mysqld restart

/usr/local/mysql/bin/mysql -uroot -p

show databases;

===========================================================================

第二段:apache安装

make;make install

groupadd apache

useradd -g apache -M -s /sbin/nologin apache

User daemon

Group daemon

User apache

Group apache

测试:首先,关闭 service iptables stop

curl (linux)

http://服务器IP(windows)

#vim /etc/rc.d/init.d/httpd

#chmod +x /etc/init.d/httpd

#设置httpd开机自启动

#chkconfig --add httpd

#这样,启动、停止、重启Apache就可以用以下方式了:

#/etc/init.d/httpd start

#/etc/init.d/httpd stop

#/etc/init.d/httpd restart

====================================================================

第三段:php安装:

yum install libjpeg*

yum install libpng*

make;make install

cp php.ini-production /usr/local/lib/php.ini

我的情况 已经有了 如果没有追加下面那句前面不带#的

# LoadModule foo_module modules/mod_foo.so

#

再搜索AddType关键字 在那附近追加如下一句

AddType application/x-httpd-php .php .phtml

再搜索下面一段 把第二句DirectoryIndex的后面追加index.php

IfModule dir_module

DirectoryIndex index.html index.php

/IfModule

vi index.php

输入内容

php

phpinfo();

vim /etc/selinux/config

注释掉#SELINUX=enforcing 并追加SELINUX=disabled

修改完需重启服务器

不重启:

# setenforce 0

# setenforce 1

[root@RHEL mysql]# curl -I /index.php

或者你在你的浏览器里输入

vim phpmysql.php

echo "MySQL First Test:Success";

因为我们编译php的时候没有加--with-mysqli选项 所以不支持mysqli扩展

[root@RHEL htdocs]# curl /phpmysql.php

MySQL First Test:Success

好了 我这里成功了

你可以再浏览器里输入

=============================================================================

第四段:配置phpMyAdmin

cd /root

test -d /var/www || mkdir -p /var/www #判断是否存在此目录,不存在则创建

cp /var/www/phpMyAdmin/config.sample.inc.php /var/www/phpMyAdmin/config.inc.php

vi /var/www/phpMyAdmin/config.inc.php

yum install expect

复制产生的短语密码

[root@RHEL src]# vi /var/www/phpMyAdmin/config.inc.php

找到如下参数

chown -R root.apache /var/www/phpMyAdmin

vi extra/phpmyadmin.conf

加入内容

Alias /phpMyAdmin /var/www/phpMyAdmin

Location /phpMyAdmin

Order deny,allow

Deny from all

#这里改成你实际允许访问的ip

/Location

vi httpd.conf

追加:Include conf/extra/phpmyadmin.conf

如何在CentOS ⑦3上安装Apache,PHP ⑦1和M6767ySQL

①.初步说明

我会今天这一节添加EPEL repo来安装最新的phpMyAdmin,如下所示:

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

yum -y install epel-release

yum -y install nano

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

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

production environment.

Remove anonymous users? [Y/n] --ENTER

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

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 production environment.

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

- Dropping test database...

- Removing privileges on test database...

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] --ENTER

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 ~]#

yum -y install httpd

这里是安装过程的截图.

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

systemctl start httpd.service

systemctl enable httpd.service

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

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

firewall-cmd --reload

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

添加Remi CentOS存储库.

rpm -Uvh?

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

yum -y install yum-utils

并运行yum更新

yum update

yum -y install?php

yum -y install?php php-opcache

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

systemctl restart httpd.service

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

nano /var/www/html/info.php

phpinfo();?

现在我们在浏览器中调用该文件(例如 ):

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-mbstring?php-soap curl curl-devel

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

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

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

rm?/var/www/html/info.php

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/phpMyAdminDirectory /usr/share/phpMyAdmin/

IfModule mod_authz_core.c

# RequireAny

# Require ip ::1

# /RequireAny

Require all granted

IfModule !mod_authz_core.c

Order Deny,Allow

Deny from All

Allow from ::1

/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

之后,您可以访问下的phpMyAdmin :

VM的登录详细信息

Linux root密码是:howtoing.

Rhe MySQL的root密码是:howtoing

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

如何在Windows下配置搭建PHP环境

WAMP的安装配置的重点就是

PHP和Apache的绑定

PHP和MySQL的绑定

至于apache的安装没有什么技术要求,一直是NEXT,可以参考WAMP的APACHE的配置? ? ;

以下是详细步骤:

一.PHP和Apache的绑定

①修改D:/apache/httpd.conf

CTRL+F 搜索LoadModule ...

在LoadModule 的最后一行添加:

//将php作为apache的一个功能模块?

//找到php.ini文件的路径?

//配置httpd服务(apache)读取.php文件时,转交给php引擎解析

ADDType?application/x-httpd-php?.php

至此完成PHP和Apache的绑定的重要步骤,可选修改项:

①.)端口号:

若是安装过其他的服务器软件(IIS,Nginx等),建议修改;

默认的是Apache/htdocs,为了方便管理PHP后期的项目,新建其他目录代替

注意:DocumentRoot "****" 的值和一致,并且目录需要手动新建?

DocumentRoot?"D:/Apache/htdocs"

Directory?"D:/Apache/htdocs"#

#?Possible?values?for?the?Options?directive?are?"None",?"All",

#?or?any?combination?of:

#?Indexes?Includes?FollowSymLinks?SymLinksifOwnerMatch?ExecCGI?MultiViews

#?Note?that?"MultiViews"?must?be?named?*explicitly*?---?"Options?All"

#?doesn't?give?it?to?you.

#?The?Options?directive?is?both?complicated?and?important.?Please?see

#?

#?for?more?information.

Options?Indexes?FollowSymLinks

#?AllowOverride?controls?what?directives?may?be?placed?in?.htaccess?files.

#?It?can?be?"All",?"None",?or?any?combination?of?the?keywords:

#?Options?FileInfo?AuthConfig?Limit

AllowOverride?All

#?Controls?who?can?get?stuff?from?this?server.

Order?allow,deny

Allow?from?all

默认的只用index.html,可添加index.php default.php...........:

当读取的目录中若是存在设置的任一文件名,则直接读取对应的文件,这也是为什么index.php存在时,不再显示目录结构

IfModule?dir_moduleDirectoryIndex?index.php?index.html/IfModule

①.) CTRL+F 搜索到extension_dir='/ext'

extension=php_mysql.dll

extension=php_mbstring.dll

extension=php_mysqli.dll

extension=php_pdo_mysql.dll

之前的';'删除.分别对应支持php调用gd、mysql、mb_函数的库;(在此其实也完成了PHP和MySQL的绑定;)修改完后,保存退出,重启apache服务;

在显示的扩展中CTRL+F搜索MySQL,能搜索到即表示成功!

注意:

D:/apache/htdocs是apache的默认解析目录,就是对应的根目录,若是修改了,在对应的目录下进行相应的操作.

怎么安装PHP环境?

LAMP/LNMP 环境搭建

一.检查系统环境

①确认centos版本

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

rpm -qa | grep httpd

或者:

apachectl -v

httpd -v

如果未被识别则没有安装

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

yum remove mysql

rm -f /etc/my.cnf

rpm -qa|grep httpd

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

二.安装Apache、PHP、Mysql

停止防火墙服务

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

禁用防火墙开机启动服务

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

①安装apache

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

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

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

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

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

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

三.安装基本常用扩展包

①安装Apache扩展包

yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

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

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

四.配置Apache、mysql开机启动

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

出现如下再次回车:

出现如下提示输入你需要设置的密码,这里输入了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]

直接回车即可.

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

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

六.测试环境

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

七.安装nginx

yum install yum-priorities -y

yum install nginx

Nginx 版本号可变更版本

八.配置nginx

①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

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

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

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

location ~ .php$ {

root html;

fastcgi_index index.php;

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

include fastcgi_params;

}

方法二 安装nginx

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

systemctl start nginx

systemctl enable nginx

vim /etc/nginx/conf.d/default.conf

访问即可看到php页面

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

九.负载配置

upstream site{

server {

server_name localhost;

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

location / {

root /usr/share/nginx/html;

index index.html index.htm;

proxy_pass ;

apache 默认目录 /var/www/html

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

升级php版本

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

yum provides php

开始升级PHP更新源:

rpm -Uvh

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

查看php版本

php -v

安装php fpm:

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,如:

search localdomain

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

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

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

Options Indexes FollowSymLinks

AllowOverride All

关闭防火墙

setenforce 0

安装PHP 在Windows环境下出现如下错误,该怎么解决?

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章