阅读量:235
7、启动并设置Apache开机自启:

systemctl start httpd systemctl enable httpd
8、浏览器访问验证:在浏览器中访问/,应显示Apache默认的欢迎页面,如果无法访问,请检查防火墙设置。
二、安装MySQL数据库
1、准备安装包:下载MySQL安装包并将其传到服务器上。
2、安装环境依赖包:
yum -y install perl
3、配置软件模块:解压并配置MySQL。
cd /opt/ tar zxvf mysql-5.7.24.tar.gz cd mysql-5.7.24/ cmake . make && make install
4、创建MySQL用户:
mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.7.24/ --datadir=/usr/local/mysql/data
5、修改MySQL配置文件:编辑/etc/my.cnf文件,根据需要进行调整。
6、更改MySQL安装目录和配置文件的属主属组:
chown -R mysql:mysql /usr/local/mysql
7、设置路径环境变量:编辑/etc/profile文件,添加以下内容:
export PATH=$PATH:/usr/local/mysql/bin
8、初始化数据库:

mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
9、添加MySQL系统服务:复制MySQL启动脚本到/etc/init.d/目录,并设置为开机自启动。
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld systemctl enable mysqld
10、启动MySQL服务:
systemctl start mysqld
11、修改MySQL登录密码:登录MySQL并修改初始密码。
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
12、授权远程登录:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
三、安装PHP解析环境
1、将安装PHP所需软件包传到/opt 目录:下载PHP安装包并将其传到服务器上。
2、安装GD库和相关程序:
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel xz xz-devel gd gd-devel libmcrypt libmcrypt-devel
3、配置PHP软件模块:解压并配置PHP。
cd /opt/
tar zxvf php-7.4.0.tar.gz
cd php-7.4.0/
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php \
--with-config-file-scan-dir=/usr/local/php/etc \
--disable-all \
--enable-maintainer-zlib \
--enable-maintainer-openssl \
--with-zlib-dir \
--with-zlib-lib \
--enable-mbstring \
--enable-ftp \
--enable-mbregex \
--enable-mysqlnd \
--with-curl \
--enable-embedded-zlib \
--with-libdir=lib \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-gd \
--with-bz2 \
--enable-gd-native-ttf \
--with-freetype-dir=/usr/include/freetype2 \
--with-jpeg-dir=/usr/include \
--with-png-dir=/usr/include \
--enable-gd-jit-ft-dir=enabled \
--with-mhash \
--enable-json \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-config-file-path=/usr/local/php/etc \
--sysconfdir=/usr/local/php/etc \
--with-pcre-regex=yes \
--with-pcre-dir=/usr/local/php \
--with-zlib=/usr \
--with-libxml-dir=/usr \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-option-checking=fatal \
--enable-sigchild \
--enable-trans-sigs \
--with-mime-magic \
--without-pear \
--with-gettext \
--with-system-tzdata \
--with-curl \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--with-gd \
--enable-intl \
--enable-calendar \
--with-ctype=yes \
--enable-cli \
--with-iconv=yes \
--enable-session \
--enable-tokenizer \
--enable-wddx \
--enable-xmlreader \
--enable-xmlwriter \
--with-xmlrpc \
--enable-shmop \
--enable-simplexml \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-sysvshmht \
--enable-bpfilter \
--enable-dbx \
--enable-exif \
--enable-ftp \
--enable-fileinfo \
--enable-filter \
--enable-ipv6 \
--enable-json \
--enable-hash \
--enable-libgen \
--enable-dom \
--with-readline \
--with-libedit \
--with-openssl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-curl \
--enable-mysqlnd \
--with-pdo_mysql=mysqlnd \
--with-pdo_sqlite=enabled \
--with-sqlite3=enabled \
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-freetype-dir=/usr/include/freetype2 \
--with-xpm-dir=no \
--with-xpm-include=no \
--with-xpm-lib=no \
--enable-static \
--enable-shared \
--enable-debug \
--disable-rpath \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-option-checking=fattal
以上内容就是解答有关“服务器安装lamp”的详细内容了,我相信这篇文章可以为您解决一些疑惑,有任何问题欢迎留言反馈,谢谢阅读。