導航:首頁 > 編程語言 > 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相關的資料

熱點內容
華為交換機dhcp配置命令 瀏覽:315
androidbitmap縮小 瀏覽:271
單片機串口控制燈 瀏覽:84
大訊雲伺服器安裝視頻 瀏覽:784
華為演算法領先世界 瀏覽:654
linux路由重啟 瀏覽:566
php的模板編程 瀏覽:320
編譯器原理與實現書 瀏覽:709
dos選擇命令 瀏覽:17
apm固件編譯到單片機 瀏覽:121
聯通深藍卡都包含什麼app 瀏覽:264
如何判斷網路伺服器正常 瀏覽:651
路由器搭橋遠端伺服器地址是什麼 瀏覽:516
編譯動態庫時會連接依賴庫嗎 瀏覽:709
淘寶手機加密是隨機的嗎 瀏覽:675
解壓包子怎麼裝飾 瀏覽:587
四個數湊24演算法 瀏覽:679
哪一種不是vi編譯器的模式 瀏覽:171
xp在此處打開命令窗口 瀏覽:129
代碼編譯運行用什麼軟體 瀏覽:1000