Home php教程 php手册 centos6服务器YUM安装LNMP(LINUX+NGINX+MYSQL+PHP)

centos6服务器YUM安装LNMP(LINUX+NGINX+MYSQL+PHP)

Jun 12, 2016 pm 08:06 PM
centos6 linux lnmp mysql nginx php yum code Install Open source server programming programming language

Posted by murray

之前都用的lamp,这次配置一个lnmp来看看,试试Nginx是不是好用

关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加

shutdown -r now #重启系统

安装ngnix

安装GCC编译器及相关工具
yum -y install gcc gcc-c++ autoconf automake
安装模块依赖的库
yum -y install zlib zlib-devel openssl openssl–devel pcre pcre-devel
更新系统时间
ntpdate time.nist.gov
让对时服务开机启动
chkconfig ntpd on

如果需要编译安装最新的
获取ngnix版本
wget http://nginx.org/download/nginx-1.0.14.tar.gz
tar zxvf nginx-1.0.14.tar.gz
cd nginx-1.0.14

直接yum安装
yum install -y nginx
将安装在/usr/share/nginx/
启动nginx
service ngnix start

安装PHP

cd /etc/yum.repos.d
wget http://dev.centos.org/centos/5/CentOS-Testing.repo
rpm –import http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

yum install -y php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm

#启动php-fpm
/etc/rc.d/init.d/php-fpm start
设置自动启动
chkconfig php-fpm on

配置nginx支持php
cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
vi /etc/nginx/nginx.conf
#修改nginx运行账号为:nginx组的nginx用户
user nginx nginx;

cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak
vi /etc/nginx/conf.d/default.conf
#增加index.php
index index.php index.html index.htm;
取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径

配置php-fpm
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak
vi /etc/php-fpm.d/www.conf
#修改用户为nginx
user = nginx
#修改组为nginx
group = nginx

安装MYSQL
yum -y install mysql mysql-server
启动mysql
service mysqld start
chkconfig mysqld on #设为开机启动

为root账户设置密码
mysql_secure_installation

重启所有服务
service mysqld restart
service nginx restart
/etc/rc.d/init.d/php-fpm restart
测试成功

安装ssh服务器和subversion服务器
yum install -y openssh-server
yum install -y subversion

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP: An Introduction to the Server-Side Scripting Language PHP: An Introduction to the Server-Side Scripting Language Apr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

How to compile vscode How to compile vscode Apr 16, 2025 am 07:51 AM

Compiling code in VSCode is divided into 5 steps: Install the C extension; create the "main.cpp" file in the project folder; configure the compiler (such as MinGW); compile the code with the shortcut key ("Ctrl Shift B") or the "Build" button; run the compiled program with the shortcut key ("F5") or the "Run" button.

How to automatically type vscode How to automatically type vscode Apr 16, 2025 am 07:30 AM

By using shortcut keys or configuration settings, you can implement automatic code typography in Visual Studio Code: Shortcut key typography: Windows/Linux: Ctrl K, Ctrl F; macOS: Cmd K, Cmd F Configuration Settings Typeset: Search and enable "editor.formatOnType", automatically type the current line every time you type a character Advanced typography options: Customize typography rules (e.g., indent size, line length), and select the desired typography (e.g., Prettier, ESLint)

MySQL: Database Management System vs. Programming Language MySQL: Database Management System vs. Programming Language Apr 16, 2025 am 12:19 AM

MySQL is not only a database management system (DBMS) but also closely related to programming languages. 1) As a DBMS, MySQL is used to store, organize and retrieve data, and optimizing indexes can improve query performance. 2) Combining SQL with programming languages, embedded in Python, using ORM tools such as SQLAlchemy can simplify operations. 3) Performance optimization includes indexing, querying, caching, library and table division and transaction management.

How to search for vscode How to search for vscode Apr 16, 2025 am 06:30 AM

Search in VSCode: Use the shortcut key Ctrl F or menu edit > Find. Enter the search content. Configure optional search options: full word matching, case sensitivity, or regular expressions. Click the Find Next button or press Enter to start the search. Search results are displayed in the Editor panel and the Find Results view, supporting advanced search features (Find Files, Regular Expressions, Range Search, and Symbol Search).

See all articles