设为首页 收藏本站
查看: 788|回复: 0

[经验分享] CentOS7.2 安装LNMP-PHP分页代码

[复制链接]

尚未签到

发表于 2019-2-16 09:52:02 | 显示全部楼层 |阅读模式
安装Nginx
Step 1: Turn off Apache
  Shut dowm Apache. Remember: This will bring down any current website that are hosted on the server
service httpd stop  Now we need to remove Apache from the boot cycle, so that it doesn't try to start up during server boot:
systemctl disable httpd  If you want Apache to start on boot again, you can easily correct this previous command by running:
systemctl enable httpdStep 2: Install Nignx
  First,we need to add the CentOS EPEL package so that we can install NGINX:
yum install epel-release  此时,可以显示软件包是否存在
yum list nginx*  Now that our repository is installed on the server, we can now use yum to install Nginx, like so:
yum -y install nginxStart Nginx:
service nginx start// 或者systemctl start nginx.serviceWhat if you see a 'test faild' error message for ngix.conf?
  You may be dealing with an IP address issue. By default, Nginx listens for both IPV4 and IPV6. If your server doesn't support IPV6, however, the test will fail.
  You can fix this by opening up the configuration file:
vi /etc/nginx/nginx.config  Comment out the following line:
listen [::]:80 default_server;  So it looks like this:
# listen [::]:80 default_server;  Close and save the file, then try to start the server again:
service nginx start// orsystemctl start nginx.service  If you don't see any errors, you're good to go.
Configure the server to start Nginx upon reboot:
systemctl enable nginx  You should now be able to see an nginx test page by going to your server's IP address in your browser.
如果你是在VMware虚机种的CentOS安装Nginx,本机无法访问,查看防火请firewall
systemctl status  firewall.service  如果防火墙开启,需要我们配置开发端口
firewall-cmd --zone=public --add-port=80/tcp --permanent  含义:
  --zone 作用域
  --add-port=80/tcp 添加端口,格式为: 端口/协议
  --permanent 永久生效,否则重启后失效
  重启防火墙
systemctl stop firewall.servicesystemctl start firewall.service  ps: https://www.godaddy.com/garage/how-to-install-and-configure-nginx-on-centos-7/
  ps: https://blog.csdn.net/harris135/article/details/74167910
安装MariaDB
Step1 Installing MariaDB
  We'll use Yum install the MariaDB package, pressing y when promped to confirm that we wish to proceed:
yum install mariadb-server  Once the installation is complete, we'll start the daemon with the following command:
systemctl start mariadb.service  systemctl doesn't display the outcome of all service management commands, so to be sure we succeeded, we'll use the following command:
systemctl status mariadb.service  If mariaDB has successfully started, the output should contain "Active:active(running)" and the final line should look something like:
  
Dec 01 19:06:20 centos-512mb-sfo2-01 systemd[1]: Started MariaDB database server.  Next,let's take a moment to ensure that MariaDB start at boot,using the systemctl enable command,which will create the necessary symlinks:
systemctl enable mariadb  output
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
Step3 Securing the MariaDB Server
  MariaDB includes a security script to change some of the less secure default options for things like remote root logins and sample users.Use this command to run the security script:
mysql_secure_installation  The script provides a detailed explanation for every step. The first prompts asks for the root password, which hasn't been set so we'll press ENTER as it recommends. Next, we'll be prompted to set that root password, whick we'll do.
Step4 Testing the Installation
mysqladmin -u root -p version  You should see output similar to this:
mysqladmin  Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Server version          5.5.50-MariaDBProtocol version        10Connection              Localhost via UNIX socketUNIX socket             /var/lib/mysql/mysql.sockUptime:                 4 min 4 secThreads: 1  Questions: 42  Slow queries: 0  Opens: 1  Flush tables: 2  Open tables: 27  Queries per second avg: 0.172  ps:https://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-centos-7
安装PHP7.2
Step1 Turn on EPEL repo, enter:
yum install epel-releaseyum install http://rpms.remirepo.net/enterprise/remi-release-7.rpmyum install yum-utilsStep2 Turn on Remi repo i.e.remi-php72:
  Enable remi repo,run
yum-config-manager --enable remi-php72Step3 Refresh repository
yum update // 此命令可能更新时间长,可逃过此执行  search for php 7.2 packages and modules with more command / gerp command / egerp command:
yum search php72 | moreyum search php72 | egerp 'fpm|gd|mysql|memcache'  Sample outputs
php72-php-fpm.x86_64 : PHP FastCGI Process Managerphp72-php-gd.x86_64 : A module for PHP applications for using the gd graphicsphp72-php-mysqlnd.x86_64 : A module for PHP applications that use MySQLphp72-php-pecl-mysql.x86_64 : MySQL database access functionsphp72-php-pecl-mysql-xdevapi.x86_64 : MySQL database access functionsStep4 Install php 7.2
yum install php72  You must install "PHP FastCGI Process Manager" called php72-php-fpm along with commonly used modules:
yum install php72-php-fpm php72-php-gd php72-php-json php72-php-mbstring php72-php-mysqlnd php72-php-xml php72-php-xmlrpc php72-php-opcache  Check PHP version:
php72 -vPHP 7.2.1 (cli) (built: Jan  3 2018 07:51:38) ( NTS )Copyright (c) 1997-2017 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies    with Zend OPcache v7.2.1, Copyright (c) 1999-2017, by Zend Technologies  List install moduels:
php72 --moduelsStep5 Turn on PHP fpm for nginx
systemctl enable php72-php-fpm.service  Sample ouputs:
Created symlink from /etc/systemd/system/multi-user.target.wants/php72-php-fpm.service to /usr/lib/systemd/system/php72-php-fpm.service.Commands to control PHP fpm:
systemctl start php72-php-fpm.servicesystemctl stop php72-php-fpm.servicesystemctl restart php72-php-fpm.servicesystemctl status php72-php-fpm.serviceConfigure Nginx for using with php 7.2
  Find out nginx service user and group names using egrep command:
egrep '^(user|group)' /etc/nginx/nginx.conf  Edit vi /etc/opt/remi/php72/php-fpm.d/www.conf:
vi /etc/opt/remi/php72/php-fpm.d/www.conf  Set user and group to nginx:
user = nginxgroup = nginx  Save and close the file. Restart php-fpm service:
systemctl restart php72-fpm.serviceUpdate you nginx config
vi /etc/nginx/conf.d/default.conf  Edit/Add as follows in server section:
## enable php support ##    location ~ \.php$ {        root /usr/share/nginx/html;        fastcgi_pass   127.0.0.1:9000;        fastcgi_index  index.php;        include        fastcgi_params;        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;    }  Save and close file.Restart the nginx server:
systemctl restart nginx  Create a test script called foo.php an /usr/share/nginx/html/
vi /usr/share/nginx/html/foo.php  Append the following code:

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-673000-1-1.html 上篇帖子: 在虚拟机上安装CenTOS 6.10系统 下篇帖子: centos7 安装debuginfo调试glibc源码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表