Centos 6.5 搭建php环境(nginx+mariadb+php7),centosnginx
Centos 6.5 搭建php环境(nginx+mariadb+php7),centosnginx
php小菜一枚,第一次写bolg,有什么不对的地方,还请各位大大指出
1.mariaDb
vim /etc/<span>yum</span>.repos.d/MariaDB.repo
<span class="o">[mariadb<span class="o">] <span class="nv">name <span class="o">= MariaDB <span class="nv">baseurl <span class="o">= http://yum.mariadb.org/5.5/centos5-x86 <span class="nv">gpgkey<span class="o">=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB <span class="nv">gpgcheck<span class="o">=1<br /><br />sudo yum install MariaDB-server MariaDB-client<br />#启动MariaDB<br /></span></span></span></span></span></span></span></span></span></span>sudo /etc/init.d/mysql start
通过在创建MariaDB.repo,可以实现yum安装
对应不同linux版本配置文件,和详细方法可以参考下面链接
https://mariadb.com/kb/zh-cn/installing-mariadb-with-yum/
https://downloads.mariadb.org/mariadb/repositories/#mirror=opencas
2.nginx
<span>#此命令可以一键安装开发工具包<br />yum</span> -y groupinstall <span>"</span><span>Development Tools</span><span>"</span> <span>"</span><span>Development Libraries</span><span>"</span>
#创建www组与www用户
groupadd www
useradd -g www -s /usr/sbin/nologin www
# 安装Nginx
tar zxvf nginx-1.9.9.tar.gz
cd nginx-1.9.9.tar.gz/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
#启动Nginx
/usr/local/nginx/sbin/nginx
#测试配置文件是否正确
/usr/local/nginx/sbin/nginx -t
还可以通过service命令来操作nginx服务,如下
1.先创建一个文件,里面写入以下shell脚本如:
文件
#!/bin/<span>bash # nginx Startup script </span><span>for</span><span> the Nginx HTTP Server # # chkconfig: </span>- <span>85</span> <span>15</span><span> # description: Nginx is a high</span>-<span>performance web and proxy server. # It has a lot of features, but it</span><span>'</span><span>s not for everyone.</span> <span># processname: nginx # pidfile: </span>/var/run/<span>nginx.pid # config: </span>/usr/local/nginx/conf/<span>nginx.conf nginxd</span>=/usr/local/nginx/sbin/<span>nginx nginx_config</span>=/usr/local/nginx/conf/<span>nginx.conf nginx_pid</span>=/var/run/<span>nginx.pid RETVAL</span>=<span>0</span><span> prog</span>=<span>"</span><span>nginx</span><span>"</span><span> # Source </span><span>function</span><span> library. . </span>/etc/rc.d/init.d/<span>functions # Source networking configuration. . </span>/etc/sysconfig/<span>network # Check that networking is up. [ ${NETWORKING} </span>= <span>"</span><span>no</span><span>"</span> ] && exit <span>0</span><span> [ </span>-x $nginxd ] || exit <span>0</span><span> # Start nginx daemons functions. start() { </span><span>if</span> [ -e $nginx_pid ];<span>then</span> <span>echo</span> <span>"</span><span>nginx already running....</span><span>"</span><span> exit </span><span>1</span> <span>fi</span> <span>echo</span> -n $<span>"</span><span>Starting $prog: </span><span>"</span><span> daemon $nginxd </span>-<span>c ${nginx_config} RETVAL</span>=$? <span>echo</span><span> [ $RETVAL </span>= <span>0</span> ] && <span>touch</span> /var/lock/subsys/<span>nginx return $RETVAL } # Stop nginx daemons functions. stop() { </span><span>echo</span> -n $<span>"</span><span>Stopping $prog: </span><span>"</span><span> killproc $nginxd RETVAL</span>=$? <span>echo</span><span> [ $RETVAL </span>= <span>0</span> ] && <span>rm</span> -f /var/lock/subsys/nginx /var/run/<span>nginx.pid } # reload nginx service functions. reload() { </span><span>echo</span> -n $<span>"</span><span>Reloading $prog: </span><span>"</span><span> #</span><span>kill</span> -HUP `<span>cat</span><span> ${nginx_pid}` killproc $nginxd </span>-<span>HUP RETVAL</span>=$? <span>echo</span><span> } # See how we were called. </span><span>case</span> <span>"</span><span>$1</span><span>"</span> <span>in</span><span> start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL</span>=$?<span> ;; </span>*<span>) </span><span>echo</span> $<span>"</span><span>Usage: $prog {start|stop|restart|reload|status|help}</span><span>"</span><span> exit </span><span>1</span> <span>esac</span><span> exit $RETVAL</span>
2.把这个文件复制到/etc/init.d目录下
#cp ./nginx /etc/init.d
3.修改这个文件为可执行的权限
#chmod +x /etc/init.d/nginx
4.把这个可执行文件加到服务服务中去
#chkconfig --add nginx
之后就可以使用 service 命令来管理了!
3.php
<span>#安装前先更新所需要的模块 # </span><span>yum</span> -y <span>install</span> libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-<span>devel # </span><span>wget</span> https:<span>//</span><span>downloads.php.net/~ab/php-7.0.0RC1.tar.gz</span> # <span>tar</span> zxvf php-<span>7.0</span>.0RC1.<span>tar</span><span>.gz # cd php</span>-<span>7.0</span><span>.0RC1 # .</span>/configure --prefix=/usr/local/<span>php \ </span>--with-<span>curl \ </span>--with-freetype-<span>dir</span><span> \ </span>--with-<span>gd \ </span>--with-<span>gettext \ </span>--with-iconv-<span>dir</span><span> \ </span>--with-<span>kerberos \ </span>--with-libdir=<span>lib64 \ </span>--with-libxml-<span>dir</span><span> \ </span>--with-<span>mysqli \ </span>--with-<span>openssl \ </span>--with-pcre-<span>regex \ </span>--with-pdo-<span>mysql \ </span>--with-pdo-<span>sqlite \ </span>--with-<span>pear \ </span>--with-png-<span>dir</span><span> \ </span>--with-<span>xmlrpc \ </span>--with-<span>xsl \ </span>--with-<span>zlib \ </span>--enable-<span>fpm \ </span>--enable-<span>bcmath \ </span>--enable-<span>libxml \ </span>--enable-inline-<span>optimization \ </span>--enable-gd-native-<span>ttf \ </span>--enable-<span>mbregex \ </span>--enable-<span>mbstring \ </span>--enable-<span>opcache \ </span>--enable-<span>pcntl \ </span>--enable-<span>shmop \ </span>--enable-<span>soap \ </span>--enable-<span>sockets \ </span>--enable-<span>sysvsem \ </span>--enable-<span>xml \ </span>--enable-<span>zip</span><span> # 编译安装 # </span><span>make</span> && <span>make</span> <span>install</span><span> # 配置文件 # </span><span>cp</span> php.ini-development /usr/local/php/lib/<span>php.ini # </span><span>cp</span> /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-<span>fpm.conf # </span><span>cp</span> /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/<span>www.conf # </span><span>cp</span> -R ./sapi/fpm/php-fpm /etc/init.d/php-<span>fpm # 启动 # </span>/etc/init.d/php-<span>fpm # 查看是否启动 </span><span>ps</span> aux | <span>grep</span> php
修改nginx配置,监听*.php的文件
# vim /usr/local/nginx/conf/nginx.conf
简单配置如下:
<span>user www www; worker_processes </span><span>10</span><span>; #error_log </span>/data/logs/<span>nginx_error.log crit; #pid logs</span>/<span>nginx.pid; #Specifies the value </span><span>for</span> maximum <span>file</span><span> descriptors that can be opened by this process. worker_rlimit_nofile </span><span>51200</span><span>; events { use epoll; worker_connections </span><span>51200</span><span>; } http { include mime.types; default_type application</span>/octet-<span>stream; #charset gbk; server_names_hash_bucket_size </span><span>128</span><span>; client_header_buffer_size 32k; large_client_header_buffers </span><span>4</span><span> 32k; #client_max_body_size 8m; server_tokens off; expires 1h; sendfile on; tcp_nopush on; keepalive_timeout </span><span>60</span><span>; tcp_nodelay on; error_page </span><span>404</span> /<span>404</span><span>.jpg; fastcgi_connect_timeout </span><span>20</span><span>; fastcgi_send_timeout </span><span>30</span><span>; fastcgi_read_timeout </span><span>120</span><span>; fastcgi_buffer_size 256k; fastcgi_buffers </span><span>8</span><span> 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_temp_path </span>/dev/<span>shm; </span><span>gzip</span><span> on; gzip_min_length </span><span>2048</span><span>; gzip_buffers </span><span>4</span><span> 16k; gzip_http_version </span><span>1.1</span><span>; gzip_types text</span>/plain text/css application/xml application/x-<span>javascript ; log_format access </span><span>'</span><span>$remote_addr - $remote_user [$time_local] "$request" </span><span>'</span> <span>'</span><span>$status $body_bytes_sent "$http_referer" </span><span>'</span> <span>'</span><span>"$http_user_agent" $http_x_forwarded_for</span><span>'</span><span>; server { listen </span><span>80</span><span>; server_name localhost; #charset koi8</span>-<span>r; #access_log logs</span>/<span>host.access.log main; location </span>/<span> { root html; index index.html index.htm index.php; } #rewrite index.php</span>/^(.*)$ idex.php?s=/$<span>1</span> <span>last</span><span> ; #error_page </span><span>404</span> /<span>404</span><span>.html; # redirect server error pages to the static page </span>/<span>50x.html # error_page </span><span>500</span> <span>502</span> <span>503</span> <span>504</span> /<span>50x.html; location </span>= /<span>50x.html { root html; } location </span>~<span> \.php$ { fastcgi_pass </span><span>127.0</span>.<span>0.1</span>:<span>9000</span><span>; fastcgi_index index.php; include fastcgi.conf; } } ################# include ################### # include block_ips.conf ; # include vhost</span><span>/*</span><span>.conf ; #强制域名访问对应域名的conf # server { # listen 80 default ; # server_name _; # return 404; # } } </span>
最后phpinfo(),成功

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

CentOS Platform Hadoop Distributed File System (HDFS) Performance Optimization Guide Optimizing HDFS Performance is a multi-faceted issue, and multiple parameters need to be adjusted for specific situations. The following are some key optimization strategies: 1. Memory management adjusts the NameNode and DataNode memory configuration: reasonably configure the HADOOP_NAMENODE_OPTS and HADOOP_DATANODE_OPTS environment variables according to the actual memory size of the server to optimize memory utilization. Enable large page memory: For high memory consumption applications (such as HDFS), enabling large page memory can reduce memory page allocation and management overhead and improve efficiency. 2. Disk I/O optimization uses high-speed storage

Detailed explanation of MongoDB efficient backup strategy under CentOS system This article will introduce in detail the various strategies for implementing MongoDB backup on CentOS system to ensure data security and business continuity. We will cover manual backups, timed backups, automated script backups, and backup methods in Docker container environments, and provide best practices for backup file management. Manual backup: Use the mongodump command to perform manual full backup, for example: mongodump-hlocalhost:27017-u username-p password-d database name-o/backup directory This command will export the data and metadata of the specified database to the specified backup directory.
