导航:首页 > 编程语言 > centosvimphp

centosvimphp

发布时间:2022-09-10 21:24:48

㈠ 如何在CentOS 6上通过YUM安装Nginx和php

在CentOS 6上通过YUM安装Nginx和PHP-FPM:
第一步,在/etc/yum.repos.d/目录下创建一个源配置文件nginx.repo:
cd /etc/yum.repos.d/
vim nginx.repo

填写如下内容:
[nginx]
name=nginx repo
baseurl=nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
保存,则会产生一个/etc/yum.repos.d/nginx.repo文件。

下面直接执行如下指令即可自动安装好Nginx:
yum install nginx -y
安装完成,下面直接就可以启动Nginx了:
/etc/init.d/nginx start
现在Nginx已经启动了,直接访问服务器就能看到Nginx欢迎页面了的。

㈡ 如何在 CentOS 7 / Ubuntu 15.04 上安装 PHP 框架 Laravel

在 CentOS 7 / Ubuntu 15.04 上安装 Laravel。如果你是一个 PHP Web 的开发者,你并不需要考虑如何在琳琅满目的现代 PHP 框架中选择,Laravel 是最轻松启动和运行的,它省时省力,能让你享受到 web 开发的乐趣。Laravel 信奉着一个普世的开发哲学,通过简单的指导创建出可维护代码是最优先的,你将保持着高速的开发效率,能够随时毫不畏惧更改你的代码来改进现有功能。
Laravel 安装并不繁琐,你只要跟着本文章一步步操作就能在 CentOS 7 或者 Ubuntu 15 服务器上安装。
1) 服务器要求
在安装 Laravel 前需要安装一些它的依赖前提条件,主要是一些基本的参数调整,比如升级系统到最新版本,sudo 权限和安装依赖包。
当你连接到你的服务器时,请确保你能通以下命令能成功的使用 EPEL 仓库并且升级你的服务器。
CentOS-7
#yum install epel-release
# rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#yum update
Ubuntu
#apt-get install python-software-properties
# add-apt-repository ppa:ondrej/php5
#apt-get update
#apt-get install -y php5 mcrypt php5-mcrypt php5-gd
2) 防火墙安装
系统防火墙和 SElinux 设置对于用于产品应用安全来说非常重要,当你使用测试服务器的时候可以关闭防火墙,用以下命令行设置 SELinux 成宽容模式(permissive)来保证安装程序不受它们的影响。
#setenforce0
3) Apache, MariaDB, PHP 安装
Laravel 安装程序需要完成安装 LAMP 整个环境,需要额外安装 OpenSSL、PDO,Mbstring 和 Tokenizer 等 PHP 扩展。如果 LAMP 已经运行在你的服务器上你可以跳过这一步,直接确认一些必要的 PHP 插件是否安装好。
要安装完整 AMP 你需要在自己的服务器上运行以下命令。
CentOS
#yum install httpd mariadb-server php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring
要在 CentOS 7 上实现 MySQL / Mariadb 服务开机自动启动,你需要运行以下命令。
#systemctl start httpd
#systemctl enable httpd
#systemctl start mysqld
#systemctl enable mysqld
在启动 MariaDB 服务之后,你需要运行以下命令配置一个足够安全的密码。
#mysql_secure_installation
Ubuntu
#apt-get install mysql-server apache2 libapache2-mod-php5 php5-mysql
4) 安装 Composer
在我们安装 Laravel 前,先让我们开始安装 composer。安装 composer 是安装 Laravel 的最重要步骤之一,因为 composer 能帮我们安装 Laravel 的各种依赖。
CentOS/Ubuntu
在 CentOS / Ubuntu 下运行以下命令来配置 composer 。
# curl -sS https://getcomposer.org/installer | php
#mv composer.phar /usr/local/bin/composer
#chmod+x /usr/local/bin/composer
composer installation
composer installation
5) 安装 Laravel
我们可以运行以下命令从 github 上下载 Laravel 的安装包。
#wget https://github.com/laravel/laravel/archive/develop.zip
运行以下命令解压安装包并且移动 document 的根目录。
# unzip develop.zip
#mv laravel-develop /var/www/
现在使用 compose 命令来安装目录下所有 Laravel 所需要的依赖。
#cd/var/www/laravel-develop/
# composer install
compose laravel
compose laravel
6) 密钥
为了加密服务器,我们使用以下命令来生成一个加密后的 32 位的密钥。
# php artisan key:generate
Application key []set successfully
现在把这个密钥放到 'app.php' 文件,如以下所示。
#vim/var/www/laravel-develop/config/app.php
Key encryption
Key encryption
7) 虚拟主机和所属用户
在 composer 安装好后,分配 document 根目录的权限和所属用户,如下所示。
#chmod775/var/www/laravel-develop/app/storage
#chown-R apache:apache /var/www/laravel-develop
用任意一款编辑器打开 apache 服务器的默认配置文件,在文件最后加上虚拟主机配置。
#vim/etc/httpd/conf/httpd.conf
ServerName laravel-develop
DocumentRoot/var/www/laravel/public
start Directory/var/www/laravel
AllowOverrideAll
Directory close
现在我们用以下命令重启 apache 服务器,打开浏览器查看 localhost 页面。
CentOS
#systemctl restart httpd
Ubuntu
# service apache2 restart
8) Laravel 5 网络访问
打开浏览器然后输入你配置的 IP 地址或者完整域名(Fully qualified domain name)你将会看到 Laravel 5 的默认页面。
Laravel Default
Laravel Default
总结
Laravel 框架对于开发网页应用来说是一个绝好的的工具。所以,看了这篇文章你将学会在 Ubuntu 15 和 CentOS 7 上安装 Laravel, 之后你就可以使用这个超棒的 PHP 框架提供的各种功能和舒适便捷性来进行你的开发工作。

㈢ centos如何修改php.ini

用ssh登陆 目前有两种工具可以助你完成该项工作

  1. filezilla ftp client 打开工具 文件》站点管理》填上相关信息


  2. secureCRT 文件》快速连接》填上相关信息

俩工具都支持ssh登陆 前提是你的服务器上装了ssh,

㈣ 阿里云默认centos7上怎么安装php

首先更新系统软件</str>
$ yum update
安装nginx</str></str>
1.安装nginx源
$ yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm2.安装nginx
$ yum install nginx
3.启动nginx
$ service nginx start
Redirecting to /bin/systemctl start nginx.service4.访问http://你的ip/
如果成功安装会出来nginx默认的欢迎界面
安装MySQL5.7.*
</str>
1.安装mysql源</str>
$ yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm2.安装mysql
$ yum install mysql-community-server
确认一下mysql的版本,有时可能会提示mysql5.63.安装mysql的开发包,以后会有用
$ yum install mysql-community-devel
4.启动mysql
$ service mysqld start
Redirecting to /bin/systemctl start mysqld.service5.查看mysql启动状态
$ service mysqld status
出现pid
证明启动成功
6.获取mysql默认生成的密码
$ grep 'temporary password' /var/log/mysqld.log2015-12-05T05:41:09.104758Z 1 [Note] A temporary password is generated for root@localhost: %G1Rgns!dD!v</str>
加粗的就是生成的密码
7.换成自己的密码
$ mysql -uroot -p
Enter password:输入上面的密码
成功输入后进入一下步,这里你估计会输入 好几次才进去8. 更换密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';这个密码一定要足够复杂,不然会不让你改,提示密码不合法;9.退出mysql;
mysql> quit;
10.用新密码再登录,试一下新密码
$ mysql -uroot -p
Enter password:输入你的新密码
11.确认密码正确后,退出mysql;
mysql> quit;
编译安装php7.0.0
</str>
</str>
1.下载php7源码包</str>
$ cd /root & wget -O php7.tar.gz http://cn2.php.net/get/php-7.0.1.tar.gz/from/this/mirror2.解压源码包</str>
$ tar -xvf php7.tar.gz
3.</str>
$ cd php-7.0.1
4.安装php依赖包</str>
</str>
$ yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel5.编译配置,这一步我们会遇到很多configure error,我们一一解决,基本都是相关软件开发包没有安装导致</str>
</str>
$ ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
configure error:
1.configure: error: xml2-config not found. Please check your libxml2 installation.
解决:
$ yum install libxml2 libxml2-devel
2.configure: error: Cannot find OpenSSL's <evp.h>
解决:
$ yum install openssl openssl-devel
3.configure: error: Please reinstall the BZip2 distribution解决:
$ yum install bzip2 bzip2-devel
4.configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/解决:
$ yum install libcurl libcurl-devel
5.If configure fails try --with-webp-dir=<DIR> configure: error: jpeglib.h not found.
解决:
$ yum install libjpeg libjpeg-devel
6.If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yesconfigure: error: png.h not found.
解决:
$ yum install libpng libpng-devel
7.If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yeschecking for png_write_image in -lpng... yesIf configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
解决:
$ yum install freetype freetype-devel
8.configure: error: Unable to locate gmp.h解决:
$ yum install gmp gmp-devel
9.configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:
$ yum install libmcrypt libmcrypt-devel
10.configure: error: Please reinstall readline - I cannot find readline.h解决:
$ yum install readline readline-devel
11.configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution解决:
$ yum install libxslt libxslt-devel
6.编译与安装
$ make && make install
这里要make好久,要耐心一下
7.添加 PHP 命令到环境变量
$ vim /etc/profile
在末尾加入
PATH=$PATH:/usr/local/php/bin
export PATH
要使改动立即生效执行
$ ./etc/profile

$ source /etc/profile
查看环境变量
$ echo $PATH
查看php版本
$ php -v
8.配置php-fpm
$ cp php.ini-proction /etc/php.ini
$ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf$ cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf$ cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm$ chmod +x /etc/init.d/php-fpm
9.启动php-fpm
$ /etc/init.d/php-fpm start
配置nginx虚拟机,绑定域名</str>
1.
</str>
$ vim /etc/nginx/conf.d/php7.thinkcmf.com.conf这里可以把php7.thinkcmf.com.conf改成自己的域名把下面的内容复制到php7.thinkcmf.com.conf里server{
listen 80;
server_name php7.thinkcmf.com;
root /var/www/html/php7.thinkcmf.com; # 该项要修改为你准备存放相关网页的路径location / {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则if (!-e $request_filename)
{
#地址作为将参数rewrite到index.php上。
rewrite ^/(.*)$ /index.php/$1;
#若是子目录则使用下面这句,将subdir改成目录名称即可。
#rewrite ^/subdir/(.*)$ /subdir/index.php/$1;}
}
#proxy the php scripts to php-fpm
location ~ \.php {
include fastcgi_params;
##pathinfo支持start
#定义变量 $path_info ,用于存放pathinfo信息set $path_info "";
#定义变量 $real_script_name,用于存放真实地址set $real_script_name $fastcgi_script_name;#如果地址与引号内的正则表达式匹配
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {#将文件地址赋值给变量 $real_script_name
set $real_script_name $1;
#将文件地址后的参数赋值给变量 $path_info
set $path_info $2;
}
#配置fastcgi的一些参数
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;fastcgi_param SCRIPT_NAME $real_script_name;fastcgi_param PATH_INFO $path_info;
###pathinfo支持end
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
}
}
2.重启nginx
$ service nginx reload
3.
$ vim /var/www/html/php7.thinkcmf.com/index.php</str>
把下面的代码复制到这个文件 里
<?php
phpinfo();
4.查看访问http://php7.thinkcmf.com

㈤ 如何在 CentOS 7 / Ubuntu 15.04 上安装 PHP 框架 Laravel

CentOS-7
#yum install epel-release
# rpm -Uvh dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh mirror.webtatic.com/yum/el7/webtatic-release.rpm 黑客安全网
#yum update
Ubuntu
#apt-get install python-software-properties
# add-apt-repository ppa:ondrej/php5
#apt-get update
#apt-get install -y php5 mcrypt php5-mcrypt php5-gd
2) 防火墙安装
电脑系统防火墙和 SELinux 设置对付用于产物应用安全!来说很是重要,,当你操作测试服﹏务器的时候答允封锁防火墙,用以下呼吁行设置 SELinux 成宽容模式(permissive)来担保安装措施不受它们的影响。
#setenforce0
3) Apache, MariaDB, PHP 安装
Laravel 安装措施需要完成安装 LAMP 整个情况,需要特别安装 OpenSSL、PDO,Mbstring 和 Tokenizer 等 PHP 扩展。如果 LAMP 已经运行在你的服﹏务器上你答允跳过这一步,直接确认一些须要的 PHP 插件是否安装好。
要安装完整 AMP 你需要在本身的服﹏务器上运行以下呼吁。
CentOS
#yum install httpd mariadb-server php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring
要在 CentOS 7 上实现 MySQL! / Mariadb 处事开机自动启动,你需要运行以下呼吁。
#systemctl start httpd

#systemctl enable httpd
#systemctl start mysqld
#systemctl enable mysqld
在启动 MariaDB 处事之后,你需要运行以下呼吁配置一个足够安全!的密码。
#mysql_secure_installation
Ubuntu
#apt-get install mysql-server apache2 libapache2-mod-php5 php5-mysql
4) 安装 Composer
在我们安装 Laravel 前,先让我们开始安装 composer。安装 composer 是安装 Laravel 的最重要步调之一,因为 composer 能帮我们安装 Laravel 的各类依赖。
CentOS/Ubuntu
在 CentOS / Ubuntu 下运行以下呼吁来配置 composer 。
# curl -sS getcomposer.org/installer | php
#mv composer.phar /usr/local/bin/composer
#chmod+x /usr/local/bin/composer
composer installation
5) 安装 Laravel
我们答允运行以下呼吁从 github 上下载 Laravel 的安装包。
#wget github.com/laravel/laravel/archive/develop.zip
运行以下呼吁解压安装包而且移动 document 的根目录。
# unzip develop.zip
#mv laravel-develop /var/www/
此刻操作 compose 呼吁来安装目录下所有 Laravel 所需要的依赖。
#cd/var/www/laravel-develop/
# composer install
compose laravel
6) 密钥
为了加密服﹏务器,我们操作以下呼吁来生成一个加密后的 32 位的密钥。
# php artisan key:generate
Application key []set successfully
此刻把这个密钥放到 'app.php' 文件,如以下所示。
#vim/var/www/laravel-develop/config/app.php
Key encryption
7) 虚拟主_机和所属用户
在 composer 安装好后,分派 document 根目录的权限和所属用户,如下所示。
#chmod775/var/www/laravel-develop/app/storage
#chown-R apache:apache /var/www/laravel-develop
用任意一款编辑器打开 apache 服﹏务器的默认配置文件,在文件最后加上虚拟主_机配置。
#vim/etc/httpd/conf/httpd.conf
ServerName laravel-develop
DocumentRoot/var/www/laravel/public
start Directory/var/www/laravel
AllowOverrideAll
Directory close
此刻我们用以下呼吁重启 apache 服﹏务器,打开浏览器检察 localhost 页面。
CentOS
#systemctl restart httpd
Ubuntu
# service apache2 restart
8) Laravel 5 网络会见
打开浏览器然后输入你配置的 IP 地点或者完整域名(Fully qualified domain name)你将会看到 Laravel 5 的默认页面。
Laravel Default

㈥ centos 7系统 如何在vim编辑器中编辑一段php版的hello world 并运行成功!

  1. php需要搭建运行环境

  2. 一般常用的比如lamplnmp

  3. 这些都是在linux下的

  4. 当然windows也有,比如phpstudy

  5. 综上,请先在centos7下搭建运行环境,然后访问

  6. 希望可以帮助你,请采纳,谢谢

㈦ 安装centos时自动安装的php怎么卸载

CentOS 5/get/php-5.3.6.tar.bz2/from/this/mirror # tar -xjf php-5.3.6.tar.bz2 配置安装参数 ./configure --build=i686-RedHat-linux-gnu --host=i686-redhat-linux-gnu --target=i686-RedHat-linux-gnu --with-apxs2=/usr/sbin/apxs --prefix=/usr/local --exec-prefix=/usr/local --with-exec-dir=/usr/local/bin --sysconfdir=/etc --libdir=/usr/local/lib/php --with-libdir=lib --sbindir=/usr/local/sbin --sharedstatedir=/usr/com --datadir=/usr/local/share --includedir=/usr/local/include --libexecdir=/usr/local/libexec --localstatedir=/var --cache-file=../config.cache --mandir=/usr/local/share/man --infodir=/usr/local/share/info --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-pic --with-curl=shared --with-freetype-dir --with-png-dir --with-gettext --with-gmp --with-iconv --with-jpeg-dir --with-png-dir --with-openssl --with-layout=GNU --with-libxml-dir --with-pcre-regex=/usr --with-mcrypt=shared --with-mhash --with-zlib --with-bz2=shared --with-pdo-mysql --with-mysql --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pgsql --with-pdo-pgsql --with-sqlite=shared --with-pdo-sqlite=shared --enable-sqlite-utf8 --with-kerberos --with-imap --with-imap-ssl --with-pear --with-gd --enable-gd-native-ttf --enable-calendar=shared --enable-exif --enable-ftp --enable-sockets --enable-bcmath --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-intl --enable-mbstring --enable-zend-multibyte --enable-zip --without-unixODBC --disable-tokenizer 非RHEL/CentOS系统可以省略 --build,--host,--target 参数,程序会自动判断(linux一般为i686-pc-linux-gnu)。如果没安装pgsql或者不需要pgsql的支持可以删除相关参数(共2个)。 bz2, calendar, curl, mcrypt, pdo_sqlite, sqlite 这些模块采用动态编译,可采用下面将会提到的方法加载。编译并安装 # make && make install 安装结果摘要,里面有几个主要的安装路径变量 libtool: install: warning: remember to run `libtool --finish /usr/local/src/php-5.3.6/libs [activating mole `php5 in /etc/httpd/conf/httpd.conf] Installing PHP CLI binary: /usr/local/bin/ Installing PHP CLI man page: /usr/local/share/man/man1/ Installing shared extensions: /usr/local/lib/php/20090626/ Installing build environment: /usr/local/lib/php/build/ Installing header files: /usr/local/include/php/ Installing helper programs: /usr/local/bin/ program: phpize program: php-config Installing man pages: /usr/local/share/man/man1/ Installing PEAR environment: /usr/local/share/pear/ 貌似要运行一次libtool --finish ....,不过我运行后也没什么奇特效果~ 更新httpd配置文件以便apache能解析php文件 # vim /etc/httpd/conf/httpd.conf 添加以下内容 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 如果在卸载原有PHP之前没备份php.ini文件,那么可以从PHP编译目录中把 php.ini-proction 拷贝到 /etc目录下并改名为 php.ini # mv /usr/local/src/php-5.3.6/php.ini-proction /etc/php.ini 添加或者更新相关设置,比如: extension_dir = "/usr/local/lib/php/20090626" # 以下六个模块可根据需要添加 extension = bz2.so extension = calendar.so extension = curl.so extension = mcrypt.so extension = pdo_sqlite.so extension = sqlite.so max_execution_time = 30 max_input_time = 60 memory_limit = 128M variables_order = "EGPCS" register_globals = Off register_long_arrays = Off post_max_size = 30M upload_max_filesize = 30M mbstring.internal_encoding = UTF-8 date.timezone = Asia/Chongqing 测试结果。在 /var/www/html 下面新建一个文件 phpinfo.php ,里面包含内容 Php代码 <?php phpinfo(); ?> 重启apache服务 # service httpd restart

㈧ 怎么安装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 #设置开机启动

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

㈨ centos怎么编辑wp-config.php

进入当前文件目录
vim ./wp-config.php
开始编辑
i 小写字母i,在光标位置插入
a 小写字母a,在光标的下一个位置插入开始编辑
编辑结束后按 esc 可执行其他操作
:wq 保存编辑文件并退出
:wq! 强制保存编辑文件并推出
:q 退出
:q! 强制退出编辑器
:w 保存

㈩ 如何在Centos的linux操作系统安装php的memcache扩展

准备工作:
1、一台linux的服务器

2、下载相应版本的php源码,知道自己php的版本并且知道phpize的位置

3、懂基本的linux解压命令和编译
操作步骤:
1、通过ssh登陆到我们的服务器,找到我们的phpize位置,如果不知道下载跟目前使用版本相同的php源码重新编译一下
2、下载memcached的源码包,并解压安装

wgettar -zxvf memcache-3.0.8.tgz #解压cd memcache-3.0.8 #进入源码包/usr/local/php/bin/phpize #执行phpize./configure --with-php-config=/usr/local/php/php-config #准备编译make && make install #编译安装

3、配置php.ini文件在最后面添加扩展进去

vim /etc/php.iniextension=memcache.so

4、重启web服务器,我用的是apache

service httpd restart

5、编写一个phpinfo文件去查看有没有安装成功

阅读全文

与centosvimphp相关的资料

热点内容
编译动态库时会连接依赖库吗 浏览:706
淘宝手机加密是随机的吗 浏览:672
解压包子怎么装饰 浏览:585
四个数凑24算法 浏览:676
哪一种不是vi编译器的模式 浏览:168
xp在此处打开命令窗口 浏览:128
代码编译运行用什么软件 浏览:997
动态库在程序编译时会被连接到 浏览:760
python超简单编程 浏览:259
获取命令方 浏览:976
怎样制作文件夹和图片 浏览:58
调研编译写信息 浏览:861
python冯诺依曼 浏览:419
同时安装多个app有什么影响 浏览:254
奥术杀戮命令宏 浏览:184
用sdes加密明文字母e 浏览:361
单片机原理及应用试题 浏览:425
易语言开启指定文件夹 浏览:40
马思纯参加密室大逃脱 浏览:322
文件夹冬季浇筑温度 浏览:712